ActionScript 3.0 :: Refer To Instance Names Inside A For Loop?

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


Similar Posts:


ActionScript 2.0 :: Refer Certain Variable And Instance Names Within Loops?

Aug 18, 2010

Trying to set up a world of warcraft like hotkey setup for an RPG i'm making for a school project, where you drag spells from the spellbook onto the hotkeys. Understand all the concepts, however, instead of doing a ridiculous amount of if statements, I want to loop the functions. Unfortunately, I don't know how to refer to certain variable and instance names within loops. I shall show you what I have:

ActionScript Code:
for(var i; i<2; i++){
spellbook_inst["spell_"+i+"_inst"].onPress = function(){
this.startDrag();
_root.hold_spell_position_inst._x = this._x;
_root.hold_spell_position_inst._y = this._y;
}}

The "spells" (i.e., icons you drag from the spellbook) are all named spell_(number)_inst, and are movieclips within the spellbook_inst movieclip. I want the drag function to be available for all spells. At the moment, I don't get any syntax errors, but nothing happens, so I presume I have referred to it incorrectly.

View 2 Replies

Actionscript 3 :: Refer To An Instance From Inside It's Own Code In Adobe Flash?

May 16, 2010

In Adobe Flash, I have a movie clip that is added to the stage when the keyboard is pressed. I want it to travel across the screen and disappear once it reaches the edge of the stage. At the moment I use this but the image appears and then stops. Here is my code:

addEventListener(Event.ADDED_TO_STAGE,runtime);
var c = 0
function runtime(){

[code]....

View 2 Replies

ActionScript 3.0 :: Loop Through Children And Add Them Instance Names?

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

Actionscript 3.0 :: For Loop Iterating Instance Names?

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

ActionScript 3.0 :: Loop Through Childrens And Add Them Instance Names?

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

ActionScript 2.0 :: Array Instance Names - Call In A For Loop?

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

Flash :: Instance Names Inside Button?

Sep 2, 2011

I've created a button in Flash, and inside that I have a TextField and a MovieClip, both with instance names set. They cover all 4 frames of the button, with no keyframes.I found I couldn't access the objects using the instance names I'd set, so I used this piece of code to see what's going on:

var obj:DisplayObject = this.m_graphics.btnChange.upState;
for ( var i:int = 0; i < obj.numChildren; i++ )
{

[code]....

View 1 Replies

ActionScript 3.0 :: Instance Names - Get The Values That The User Will Enter Into Matrix By A Loop

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

AS3 :: Image - Add A Child Inside A Newly Created Instance, Inside Of A Loop?

Feb 2, 2005

I am trying to create a gallery where each thumb is housed inside of it's own movie clip that will have more data, but it keeps failing because it won't let me refer to the newly created instance of the movie clip. Below is what I am trying to do.

var xml:XML;
var xmlReq:URLRequest = new URLRequest("xml.xml");
var xmlLoader:URLLoader = new URLLoader();

[code]....

View 2 Replies

AS3 :: Add A Child Inside A Newly Created Instance, Inside Of A Loop?

Jun 6, 2010

I am trying to create a gallery where each thumb is housed inside of it's own movie clip that will have more data, but it keeps failing because it won't let me refer to the newly created instance of the movie clip. Below is what I am trying to do.

var xml:XML;
var xmlReq:URLRequest = new URLRequest("xml.xml");
var xmlLoader:URLLoader = new URLLoader();

[Code]....

It dies every time on that last line. How do I refer to that vidThumbn instance so I can add the imageLoader? I don't know what I'm missing. It feels like it should work.

View 2 Replies

ActionScript 3.0 :: Variables' Names Inside A Loop?

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

ActionScript 3.0 :: Loop Video Inside .flv Playback Instance?

Sep 11, 2008

I have a movie clip that needs to loop inside a movie clip in Flash. Would someone post the code to paste into the ActionScript window? The .flv has no skin on it. I have done this so that I can put the video file outside of the Flash movie.

View 2 Replies

ActionScript 3.0 :: Instance Names And Variable Names: It Goes Deeper

Mar 20, 2011

I started a thread about a reference to a symbol House, in the output window, which was: House_1. A lot of people said some useful things about that. All day I've been thinking about it, and I came to the conclusion that I don't understand things, at a very basic level.

Consider:I make a movieclip which I give the Symbol name Drawer. (I don't export it for AcitonScript.)On the stage I manually place two instances of this Symbol. The first one I give the Instance Name drawer (in the properties panel). The second one I leave nameless.Now if I trace the names of both these clips, by

trace(this.getChildAt(0).name);
trace(this.getChildAt(1).name);

the output window gives me

drawer
instance2

Now I know that the so-called "instance name" which I gave in the Properties Panel (drawer) is, in reality, a variable name which Flash gives my first instance behind the scenes. And instance2 is a name that Flash gives my second instance. What exactly the nature of that name is, I do not know.My point is: both names (drawer and instance2) are the .name property of these movieclips. Otherwise I could not have traced them through asking for the .name property, in the above. Yet only the first of these two can be manipulated:

drawer.x can be set;
instance2.x can (as we know) not be set.

But...why? What is the real difference between these two kinds of names? How can they both be the .name property of their underlying movieclip, yet be of such a different nature? What IS the nature of the instance2 name? If it's a String, how come the .name property of one movieclip can be a variable name, while the .name property of another (but identical) movieclip is a String?

I've searched every bit of web page on the net I could find. But it looks as if nobody addresses this issue. We all just work with it - but it makes no bloody sense. A name property = a name property, you'd think. Whether Flash set it or I set it should not make a difference. The x property of a clip, for example, does not change in nature according to who set it - me or Flash.So, again, just to emphasize the problem: how can a property (the name property) of a movieclip change in NATURE depending on who set it? After it's been set, shouldn't the name property of a clip be of exactly the same nature as the name property of another clip?

View 8 Replies

ActionScript 3.0 :: Refer To An Instance On The Stage If

Feb 9, 2009

How can I refer to an instance on the stage if:

- I added it to the stage using the GUI
- I wrote its implementation in an external AS file

I can't assign it a instance name otherwise I get this error: Code: ReferenceError: Error #1056: Cannot create property myInstance on MyClassName.

View 4 Replies

ActionScript 2.0 :: Use A String Var To Refer To A Mc Instance Name?

Feb 12, 2009

i am having problems referencing an mc's instance name via a string var. I think the solution would be simple, but i have been trying different things for a while

ActionScript Code:
var hitarea:Array = new Array;
function populatehitareas()

[code].....

View 9 Replies

ActionScript 2.0 :: Can't Refer To An Instance Of A Movieclip

Feb 19, 2009

the second bit of code "mc_inst1.onRollOver..." works, but the first bit of code, which tries to loop through all movie clip instances, will not work.I think this is because myReference is a String. But can anyone suggest how else I should construct my reference to the instance name?

Code:
for (var a:Number = 1; a<myCount; a++) {
myReference="mc_inst"+a;
var myClip:MovieClip = myReference;

[code]....

View 5 Replies

Flash :: Refer To Text Field By Class Instance Name?

Jun 17, 2011

I need to populate the text field tField (defined on stage) that resides inside ParentClass (MovieClip with same class name). I want to be able to set tField.text to whatever I want from AnotherClass. How do I do it?

View 2 Replies

ActionScript 3.0 :: Refer To Instance / Movie Clips (relative Route

Aug 21, 2009

so i finally decided to jump to as3 from as2! (yes, it took me some time XD) I have a better understanding of as3 after reading tutorials, however i have a problem/doubt: I have 2 movieclips on my main timeline with the name of the instances: OBJ_1 and OBJ_2. both have animations. OBJ_1 has a stop on its 1st frame; OBJ_2 has an action in its last frame:

[Code]...

View 9 Replies

ActionScript 3.0 :: Main Class Path Without Carring Around Instance Refer?

Jan 6, 2007

I spent my holyday in studing new Flash 9, very good, powerfull but I doesn't find anymore my root, in teory is transformed in stage.root but it doesn't work.I want to understand if I make a mistake in my code or in my approach.I make a simple example with a few object containers.In the firsts lines of the constructor of the mail class I create the style class named tf and then the interface class called interf.Here is my class

Code:
package test {
import flash.display.Sprite;
import test.tf;[code]....

how to get the tf1 Object that as to be in stage.root.mytf.tf1 as some documentation say? If you doesn't comment that line you have an error. Obviously you can carry with you the object because is a small object with a few nidification but It seems to me very very bad for performance and code.

View 2 Replies

ActionScript 2.0 :: Using A Loop To Refer To Movieclips

Jun 29, 2010

I have 6 movieclips named answer1, answer2, etc. I also have a for loop where I want to assign functions to each one programatically. In my loop if I'm using var i, I wanted to refer to each movieclip with something like answer + i to refer to answer1 (assuming i = 1, for example). However, I don't know the syntax to do this.

Here's a rough shot of my code:

ActionScript Code:
for (i=1; i<7; i++) {
"answer"+i.onPress = function() {
this.startDrag();

[Code].....

View 4 Replies

Actionscript 3 :: Switch / Case To Evaluate The Current Frame - What Instance Should Refer To

Jan 12, 2010

I'm trying to make a menusystem that will jump to specific frames depending on what frame I'm currently on. I have made a switch/case to evaluate the current frame. I have managed to find this code to get the current frame but I need an instance of my entire flash movie it seems? I have tried this (psudo code sort of). var frame = myClip.currentFrame; I then proceed to test frame in the switch/case statement. (All this is an event for a mouse event listener BTW). Now how can I refer to myClip?

View 1 Replies

ActionScript 3.0 :: Refer To The Main Timeline From Inside MC

Feb 28, 2009

I have a frame label on the main timeline called "History" I have a movieclip on the stage. Inside that movie clip I have a button.

I want to refer back to History from the button within the clip. Tried everything.

View 2 Replies

ActionScript 3.0 :: Refer To MC (main_mc) Inside Of Which Put McLoader?

Apr 4, 2011

im new at the forums and still learning. My problem should be fairly easy to solve, anyhow:I have got a AS3 fla. file with a mc (main_mc) on stage, I am importing an SWF (a galery) into my fla. problem is that the import code i got tells flash that the loader (mcLoader) is placed right on stage and I want it to be placed inside my MC (main_mc). Hope you guys get my problem, here i the code:

so basicly all I need is how to refer to my MC (main_mc) inside of which i put my mcLoader (which the galery will load inside of)

[Code]...

View 1 Replies

ActionScript 3.0 :: Refer To A Button Inside A Symbol?

May 20, 2011

I have made a dropdown menu on the main timeline as a symbol. I need to create listeners to the buttons on the dropdown menu to make the main timeline go to a specific frame.

View 6 Replies

ActionScript 2.0 :: Refer To All Movie Clips In An Array Inside Of An If Condition?

Jul 10, 2011

What I want is: when the "hero" touches an enemy, all enemies should be removed. The problem is that when the hero touches an enemy it only removes that enemy. This only happens when its inside of an "if" condition. I made another example using buttons and worked perfect. let me show you the examples: in this case I made a button to create some movie clips inside an array:

ActionScript Code:
i = 0
myArray = []
boton1_btn.onPress = function(){

[Code]....

in the dieEnemies() function it only remove the one enemy the hero is hitting. What should I do to make all enemies being removed?

View 4 Replies

ActionScript 2.0 :: Refer To The Button Inside The Movieclip After Attach It Onto The Stage Using AttachMovie?

Nov 17, 2003

I had a movieclip which contained a button in it exported as "mc". Then I attach this movie clip onto the stage using: _root.attachMovie("mc", "link1", 1); But i couldn't find it with AS. I mean, how can i refer to the button inside the movieclip after I attach it onto the stage using attachMovie?

View 2 Replies

ActionScript 3.0 :: Refer The Main Time Line Or Stage From Inside The Class?

Apr 13, 2009

how to refer the main time line or stage from inside the class.

class sample{
function sample(){
trace(root); // its displaying as null
}
}

in actionscript 2 we use _root for this... in actionscript3 if we use root...why its not working inside the class....?

View 1 Replies

Flash :: Play Movie Clip Instance Inside Of Button Instance?

Apr 16, 2011

I placed a movie clip instance inside a button, and I want this movie clip to play when the button is released. I'm using this code on the frame containing the button:

function playMovie(event:MouseEvent)
{
this.theButton.theMC.gotoAndPlay(3);

[code].....

View 2 Replies

ActionScript 2.0 :: Use Instance Names Such As '1-1'

Mar 17, 2010

I have a grid 8 columns, 3 rows.I used instance names such as 1-1, 1-2, 2-1, 2-2, ect to easily identify each cell. I can call the movieclips within them without a problem by doing this["1-1"].gotoAndPlay(1); but how do I go about calling them when I can't use "this"? "1-1".gotoAndPlay(1); does not work.

View 2 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved