ActionScript 2.0 :: Object Names In For Loop?
Jan 6, 2003
I have 8 text boxes (called h1, h2 etc) that I want to do things with, the code below is just to make them all invisible when the movie loads,this works:
for (b=1; b<9; b++) {
_root["h"+b]._visible = false;
}
[code]....
View 1 Replies
Similar Posts:
Jun 8, 2011
i was searching for the solution all over the internet but could not find the way to solve this problem . I have a loop in which i want to assign one property value ( in this case value of several numeric stepper components) to one array spot. Unfortunetaly i cant figure out how to change the property name acording to number of the loop. Here is an example.
Code:
hours0.value = 5;
hours1.value = 6;
[code].....
View 4 Replies
Apr 13, 2009
I'm trying to imitate the spining preloader that fades as it rotates and I can't remember how to name each of the lines that are created with this code so I can later add the script to modifiy their independent alpha as it turns.
I don't know wether I need to create another function or what to do...
var numLines:Number = 12;
var extRadAsterisc:Number = 20;
var intRadAsterisc:Number = 10;
var centreX:Number = 110;
[Code].....
View 2 Replies
Nov 30, 2011
I have a few functions that accept several parameters. [code]...
Is there a way to loop through all the params (without knowing how many or their names) and put them in some kind of an array with their names, so I'd get an associative array [code]...
View 2 Replies
Jul 19, 2009
i want to query about a point here,
Now, When i make a loop for example a "for" loop
ActionScript Code:
var i:int;
for (i=0;i<4;i++){
// Looping Code For 4 Times
}
in the looping code, when i use a variable, for example "myVar"
Can i make the variable name be "myVar0" in the first time looping, and the name be "myVar1" in the second time looping, and so on ..
View 6 Replies
Jan 14, 2010
how could I make a simple loop which loops through the childrens of specific movie clip and add each of them instance name lets say "iname", since I have movie clip in which childrens are not added by code.
And if I'm sure I could acces those childrens then by code like iname.x = 100?
View 6 Replies
Jan 24, 2010
I can't create new variables within a for loop:
ActionScript Code:
for(var i:int = 0; i<numBtn; i++) {
var this['menuBtn'+i] = new Sprite();
}
This doesn't work, saying I need an identifier before 'this'.
What I am trying to do is to make a dynamic menu, and the number of buttons depend on how many files there are in a directory, as each button links to each file;I get this value (numBtn in my example) from a php script, and I need to make a menu depending on it, but I can't seem to make it so that when I add a new file into that directory, a new button comes up on the menu and I don't have to change my flash file.
View 9 Replies
Dec 19, 2008
Still learning how to use for loops, I want to set a huge range of Boolean Variable to false. like:
var met0:Boolean = false;
var met1:Boolean = false;
var met2:Boolean = false;
etc... etc...
how can I dynamically name variables inside a for loop and set its data type? I know how to with movieclips but can't get it to work with variables
View 4 Replies
May 10, 2010
I have a few MCs named fruit1, fruit2, fruit3, all instanced off a MC...I would like to loop to shorten my code and just loop through and stop all of them at once... My Code:
for (var i:Number=1; i<=7;i++){
fruit[i].stop();
}
I get an 1120: Access of undefined property fruit.I want the result of my loop to do:
fruit1.stop();
fruit2.stop();
etc..
View 4 Replies
Mar 13, 2009
[code]I've tried some various things (including "this"), but basically, I need to loop through data held in arrays to create several dynamically named functions on the the fly.
View 1 Replies
Jan 7, 2010
How can I create several tweens with different names in a for-loop?
I want to create one tween named tween0, one tween named tween1 etc. up to tween9.
Like this: (This doesn't work)
Code:
for(i=0; i<10; i++) {
var ["tween" + i]:Tween = new Tween(...);
}
View 2 Replies
Jan 14, 2010
how could I make a simple loop which loops through the childrens of specific movie clip and add each of them instance name lets say "iname", since I have movie clip in which childrens are not added by code.
P.S.: And if I'm sure I could acces those childrens then by code like iname.x = 100?
View 2 Replies
Mar 29, 2012
I have this:
Code:
function onAdd(e:Event){
switch (getQualifiedClassName(e.target))
[code].....
View 5 Replies
Mar 21, 2009
im trying to run a loop and assign all my new movie clipswith different names. i have tried .name and ._name they dont seemto be working..
for (var i = 1; i<=5; i++) {
imageName = new ImageMovie();
this.addChild(imageName);
[code].....
View 1 Replies
Jun 24, 2009
am trying to load xml and make button for its length, and try to make function for each button i have i make buttons and i give them a unique name , but i can't make function for every one?here is the code
/////////////////////////////
var xmlLoader:URLLoader = new URLLoader();var my_Arr:Array= new Array();var arr_posX:Array =new Array();//= ["350","350","350","350"]var arr_posY:Array=new Array();//= ["80","120","160","200"]xmlLoader.addEventListener(Event.COMPLETE, showXML);xmlLoader.load(new URLRequest("Models.xml"));function showXML(e:Event):void { XML.ignoreWhitespace = true; var songs:XML = new XML(e.target.data);
[code]....
View 3 Replies
Jun 3, 2010
I have several movie clips labeled thumb0, thumb1, thumb2, etc.
How do I refer to these instance names inside a for loop? I want to do something like:
//DISPLAY THE THUMBNAILSfor(var thumbCount:int = 0; thumbCount < loadedThumbs.length; thumbCount++) { ["thumb" + thumbCount].visible = true;
}
View 8 Replies
Oct 4, 2011
im trying to load xml and make button for its length, and try to make function for each button i have i make buttons and i give them a unique name , but i can't make function for every one ?
/////////////////////////////
var xmlLoader:URLLoader = new URLLoader();var my_Arr:Array= new Array();var arr_posX:Array =new Array();//= ["350","350","350","350"]var arr_posY:Array=new Array();//= ["80","120","160","200"]xmlLoader.addEventListener(Event.COMPLETE, showXML);xmlLoader.load(new URLRequest("Models.xml"));function showXML(e:Event):void { XML.ignoreWhitespace = true; var songs:XML = new XML(e.target.data);
[code]....
View 2 Replies
Jan 3, 2006
I have 35 textboxes with the names "t1" to "t35". How would I call these names in a for loop? I have tried this with no luck:
[Code]...
I know I'm doing something wrong with the ("t"+i) but I dont know how how to combine a string and number like that.
View 7 Replies
Jul 6, 2003
okay here's my code
Code:
onClipEvent (enterFrame) {
for (z; z<4; z++) {[code]....
how do you turn the s[z] into something like s1 - s2 or s3 ? i just want different movie clip names for each loop..
View 2 Replies
Jul 12, 2009
The problem is referencing object names dynamically in AS3, in a loop. Example. I have an array called c4 which i would like to reference like this:
I have a number
var x:Number = 4
How can I do something like
trace(["c"+x].length);
(I know this is wrong!)
Same with other objects
E.g. Movieclip called mc4
["mc"+x].x = 100;
View 3 Replies
Jun 23, 2010
I have an for each loop that creates a new textField for each item and I need to know how you can give each textField a unique name so it can be targeted later on.Here is the relevent code:
Code:
var i:int = 1;
for each (var titleElement:XML in titleList) {
[code].....
View 3 Replies
Jul 28, 2010
I need to make a loop that can create (and use) incremented variable names. Basically I need to dynamically create a certain number of sprites and datagrids then I need to add these dynamically created datagrids and sprites to the stage. So the static code (which works, but I think is NOT the right way to go) would look something like this (I'm leaving out a bunch of stuff but this should give you the right idea):
[Code]....
But I can't figure out the syntax and how to make it work... This MUST be possible! My knowledge is pretty thin in actionscript,
View 5 Replies
Sep 1, 2010
I have a simple array of movie clips ("box1" "box6") that I have created on the stage. I then have a simple onRollOver function that is iterated for each of these movie clips, as shown below. As it is now it's working fine, but I can forsee two potential problems for when I use larger arrays and apply this technique to my real working files.
If I were to have many more movie clips, the first line of code would be much longer as it lists each movie clip instance name. Is there a way to use, for example, a for loop to include all these movie clips in the array without having to type out all their names? As you can see here, I have used a simple numerically-incremented naming process. I think the problem may be that I am using movie clips with instance names assigned on the stage and not created through ActionScript.The function as I have created it makes all the movie clips gotoAndStop(1) and then the one that has been rolled over goes to frame 2. Is there a way of making all the movie clips in the array except the one that has been rolled over gotoAndStop(1), ie. is it possible to exclude the rolled-over movie clip from the first part of the function? Here it works just fine as it is, but I'm thinking that maybe when I start using more complex functions with tweens etc it may cause problems. Or not?
[Code]...
View 5 Replies
Aug 23, 2010
i have a simple matrix form that consist of 3*3 textfields. my problem is how to get the values that the user will enter into it by a loop, i mean not using a long way such:
[Code]...
View 7 Replies
Jul 3, 2006
i am trying to create a loop that will put a list of names from external sources into a number of Arrays .so what i did is :
Code:
for (i=0; i<4; i++) {
this["loadVarsText"+i] = new LoadVars();
this["loadVarsText"+i].onLoad = function(success) {
[code].....
and i dont understand why it is not working, and how can i fix it?
View 3 Replies
Jan 17, 2012
Let's say I have a class which looks like this :
public class MyClass
{
public var attribute1;
public var attribute2;
}
and I'd like to get attribute1 and attribute2 as strings. I tried this :
var test:MyClass = new MyClass();
for (var key:String in test)
{
trace(test[key]);
}
but it does not work, it never goes in the loop. How can I do what I want to do ?
View 2 Replies
Apr 22, 2011
Given an XML object: <column label="Name" datafield="userName" width="70" />, how do I extract the NAME of the properties rather than the values, e.g. ["label", "datafield", "width"]?
ActionScript Code:
for (var pname:* in column.@*)
{
trace(pname);
}
Returns "0", "1", "2", and "for each" returns "Name", "userName", "70".
What I really want is "label", "datafield", and "width", hopefully without the overhead of actually parsing the xmlString.
View 1 Replies
Dec 4, 2009
I mean the value returned by:
trace(e.target.name); (tried on a MouseEvent object)
or
trace(myTextField.name); (on a textField object).
In my Flash application, I notice that tracing the name of an event object returns "instance26", indicating that this is the 26th (or 27th depending on the base of indexing) object created since the app initialized. Basically what I'm curious about is, firstly, is this instance value subject to change when the app is ported to other platforms (if different versions of the Flash player process instructions in a different order or fashion) and secondly, how can I find what object contains "instance0" or (if the instance indexing begins at base 1), "instance1"?
View 1 Replies
Jul 20, 2011
If I have a swf file, is it possible to retrieve object names and types (some kind of reflection) somehow?
View 1 Replies
Apr 10, 2009
Code:
for (var i=1; i < 13; i++) {
var box = new kutu();
addChild(box);
}
The code it adds 12 times object called "box".. but if I want different names for each object? For example make the name for each
Code:
name = "box_"+i;
View 5 Replies