ActionScript 3.0 :: Change Properties Of Instance Instantiated By A For Loop
Nov 8, 2009[Code]....
five instances, five different numbers on theText. Five different names for each instance.
[Code]....
five instances, five different numbers on theText. Five different names for each instance.
I am running a for loop to bring in movie clips from an array, and I have a couple buttons that I want to affect the properties of all of the mcs. The buttons (labelsOff_btn, labelsOn_btn, increaseSize_btn, decreaseSize_btn) are only affecting the second-to-last item on the list, although the drag functions targeting the same mcs (thIcon) are working for everything. Code is pasted below:
[Code]...
I have a little bit of code that makes a nifty kaleidoscope effect, but I would like to take it one step further by having each star in the kaleidoscope gradually shift color as it expands outwards. Right now, I create randomly colored "star" movieclips by drawing 6 different triangles within the movieclip, and then add those individual "star" movieclips to a "stars" array.
What I'd like to do is use a "for...in" loop to grab the .color property of each of the "star" movieclips and change it slightly (using colorTransform?) at each ENTER_FRAME. How can I go in and access the star.color property (or is it star.transform.colorTransform?) of each of the movieclip objects that are now stored in my "stars" array?
Would it be:
Code:
for (var i in stars){stars[i].transform.colorTransform = myColorTransform;
}OR
for (var i in stars){stars[i].star.transform.colorTransform = myColorTransform;
}
I have a class with constructor and overloaded methods in it. When i try to import that class using blazeds i get an error saying [RPC Fault faultString="Unable to create a new instance of type 'some class'." faultCode="Server.ResourceUnavailable" faultDetail="Types cannot be instantiated without a public, no arguments constructor."] How to import class having overloaded methods using blazeds
View 1 RepliesI am wrapping my brain around OOP in AS2. I am making two posts on two different subjects. My question here is: when should I use local instance variables, and when should I attach new properties to the instance object? (Feel free to correct my terminology.) Let's say I have a class for a scrolling background, which scrolls when I mouse over its edge. I want to put these values somewhere:
1) How wide is the border in which a mouseOver makes it scroll? This is basically a semi-constant I set it up once and keep it the same, unless the user changes it in an options menu to make the border wider or narrower. Call this scrollBorderWidth.
2) How fast is the background scrolling now? I want to track this so I can smoothly change the scroll speed over several frames. This is often changed. Call this scrollSpeed.
It seems I have two ways I can store and access these values and darned if I know which is better practice. METHOD A: Make them local variables in the class, so the scrolling background instance has them as local vars. I set them up thusly:
[Code]....
Just been playing around with the tutorials, on the Set properties/Get properties. Everything is all cool, except the "instance name" aspect. I dnt really understand that too well. Is it possible to change an Mc Name dynamically? If you look at my FLA when you hit the top left red button you will get a trace of the mcName as "square". Now if you input a new mc Name on the right hand side, you will see it change on the left hand side. But i want to know why it doesnt remain as the new mc Name, it still goes back to square.
View 3 RepliesI am using this code to iterate through the contents of a movieclip which contains instances of "alien2" - my alien. I have each alien in a movieclip called squadron1. They all have their own layer and follow a motion path to recreate the attack sequence in Galaga. I can add action script to them by right clicking on them, but when I do this test below I can't call any MovieClip methods on them. It is my intention to add a function to each one via code to make it detect bullets, look for the player etc, but at the moment all I can do is add the code to each one individually on the stage.
Code:
var target;
for(var item in _root){
if(_root[item] instanceof MovieClip ){
target = _root[item];
[Code] .....
Why I can't set properties to instance names with Array
Code: Select all// instance names:
// a1_mc, a2_mc
var allElements = new Array("a1_mc","a2_mc");
allElements.x = 250;
alllements.y = 250;
I'm having a little trouble with the properties of an instance of a specific class. Here's and example of the code I am using:
Code:
package {
import flash.display.MovieClip;
import flash.events.*;
public dynamic class Circle1 extends MovieClip {
private var _root:Object;
[Code] .....
This is in the class code for Circle1. Now here is the error that is being displayed int he Output Box when I try to run the file:
Code:
TypeError: Error #1010: A term is undefined and has no properties.
at Circle1/eFrame()
Here's the code that creates the two class instances as children on the Main Time Line:
Code:
if (spaceDown) {
var newCircle1:Circle1=new Circle1();
addChild(newCircle1);
} if (enterDown) {
var newCircle2:Circle2=new Circle2();
addChild(newCircle2);
}
EnterDown is a defined variable for the key press of Enter, and spaceDown is a defined variable for the key press of Space.
Through searching the various forums I have found that Loaders are not dynamic and hence you can not apply custom properties to each instance of them. I miss the old way (as2 way of attachingMovieClip) that you load dynamic content, at least you can apply custom properties, and you can always reference them for each object.What I'm trying to do is load a group of Images via XML. Each one of those images have a set of information that is associated with them (name, description, etc). I have the images loading in and positioning just fine, however when trying to have a tooltip show the name on Mouse Over, I'm not able to achieve this.
In short. I want to be able to store information for each item so that I can access it. Is there a way to do this in AS3 with a Loader or is there another route I can go? If I do this with Arrays, how do I store the Index of the specific item so I can use that in reference to the position in each array?** Should I use getChildIndex() in the function for the Event Listener to reference the data stored in the arrays for each item? If so, how do I do so? ***
PHP Code:
num = 0;var titleArray:new Array();function createImage(){ var thumb:Loader = new Loader; thumb.load(new URLRequest(url);
[code].....
I have a Matrix which I recycle and use for drawing DisplayObject instances onto a Bitmap. At the moment, I reset the Matrix before I render each item, like this:
_matrix.a = 1;
_matrix.b = 0;
_matrix.c = 0;
_matrix.d = 1;
_matrix.tx = 0;
_matrix.ty = 0;
Would it be better to do the above, or to simply do this?:
_matrix = new Matrix();
Generally I would say the former, however I'm unsure if in the case of Matrix there is some heavy stuff going on for each of those properties that I reset (mathematically).
on my timeline i create a new instance of the class FirstClass with the following
code:
var firstObject:FirstClass = new FirstClass();
the class looks like this:
package {
public class FirstClass extends MovieClip {
public function FirstClass() {
[Code]....
On my timeline i would like to acces the x position of the object tempObject
I'm building a small game. On my document class i create a instances of the class Character and Level with the following code:
//add the Level
level = new TileGrid();
level.y = 100;
[code].....
I would like to loop through every property of a movie clip. how to do this and I can only get one level down. If someone could let me know that would be great. here's how I am checking the first level:
[AS]function checkOb(ob){
for (var i in ob){
trace(i+":"+ob[i])
}
}
I have twenty objects in the stage, everyone is name: unit1... unit2... and so on to 20.I wanted to use a loop to modify for example, the alpha values of everyone at the same time. So I used a name like unit1, unit2 so I thougt I could use a loop to assign the alpha values...
"unit" + i.alpha = 0;
Trying to loop File properties, but loop does not iterate
[Code].....
Why is this? Works for everything else I have tried...
i have 10 movieclips mc1_mc-mc5_mc and coin1_mc-coin5_mc on stage i aded listeners in for lop tat is working.when i click mc1_mc i want to make coin2_mc-coin5_mc invisible and coin1_mc and if i press mc2_mc then coin2_mc should wil b visible others invisible.i used folowing code but when i click any movieclip every objects in stage is becoming invisible.
Code:
for (var i=1; i<6; i++)
{
["mc"+i+"_mc"]addEventListener(MouseEvent.CLICK,clicked);
}
[Code]....
I'm trying to figure out a way to use a loop to cycle through all the properties of a DisplayObject and class extended off of it, like in using a for(... in ...) loop on Objects.
View 3 RepliesI was wondering if it was possible to use a for (or for each) loop to trace the properties of an event to the output window. I know I can trace the event in one go, like this:
[Code]...
I have 35 movieclips, named s1, s2, s3 etc, depending on the value of currentDisplay, I would like to set a movieclip visible property to true while the others are set to false, I have tried the following:
Code:
for (i=1; i<36; i++){
trace(i);[code]....
but I receive an error message: 1083: Syntax error: dot is unexpected. I assume it is referring to the dot before visible.
What I did was simple: I loaded a swf into an empty MovieClip[code]...
background.swf's stage was set up with 300X200 aspect-ratio, but it was further larger than that size when I tested it.[code]...
I was doing a project for class and all of a sudden i cannot change anything in my brush properties except color. the stroke, style, scale, cap, join is all locked. i was using it fine earlier and it works for all the other tools but only the brush isnt working.
View 1 RepliesIs there a way to change a graphic, but keep the properties across frames such as size and positioning, so that the new graphic does everything the same? That's pretty much all I can ask since I don't really know where to start.
View 1 RepliesIs it possible to change the background of a certain layer in flash using code.
View 4 RepliesWhat I have done is create a preloader that loads an SWF file. I used the same preloading technique used at this site [url]...
What I want to do is when the browser window resizes I want to change the swf files height and width properties to the size of the window.
Is this possible or should I approach the preloader differently so that my main swf gets loaded by the browser so I can use javascript to change its properties.
I have a text whitch I created with: createTextField command. Somehow I figured out how to change the text's color and size but I'm still not able to change it's font although I used the command text.textFont=arial; (I used Arial too).
Basically I wanted a list with command that you can change text properties..
how do i make a movie clip move right 5 pixels every time i press SPACE with actionscript 3?how do i change under properties for input text box, paragraph, behavior and make the password characters be black circles or dots instead of asterisks in flash cs4?how do i take a screen shot of the microsoft windows login screen when I switch on the computer?how do i test movie in full screen in flash cs4 or publish it in internet explorer and have the trace("blah") command or output shown there?
View 2 Repliesif i have several instances of a mc with names such as BR1, BR2... BR10 or whatever, how do i write a for loop that will cycle through them all?
View 3 RepliesHow would i go about changing properties of a Combo Box?
There are two things I would like to change that differs from an orginal Combo Box.
1. Make it so some of the labels within the Combo Box are unselectable, yet are still displayed.
2. Make the colour of certain labels different.
I currently have a scene in Flash CS4 that consists of an image layer1 (converted to a motion tween), image layer2 (converted to a motion tween), an actionscript 3.0 layer, and a hotspot layer. Let's say the animation is 10 frames long for simplicity. At frame1 I want the visibility of image layer 1 turned on and the visiblity of image layer 2 off. Then, I want to spin image layer 1 and 2 simaltaneously (I know how to do this with motion tweens of course) but mid-spin, say at Frame 5, I wish to turn on the visiblity of image layer 2 and turn off the visibility of image layer 1.
How do i change the visiblity properties of my image layers with actionscipt? I assume there is a class I need to load and then change the properties of the image layers in the actionscript layer at the corresponding frames I wish those properties to change.