-
variable issues
i have a variable called loopCount that adds 1 to itself each time the movie loops. i have a second variable based on loopCount (called packButton) that adds loopCounts number to the word 'pack'. for example, if this time around loopCount = 5, then packButton would be 'pack5'. based on what is stored in packButton, i want to make active and visible a corresponding button. each button is stored in a movie clip with an instance name of allPacks (so button with instance name of pack1 is inside movie clip allPacks). what i have used is:
Code:
loopCount++;
packButton = "pack"+loopCount;
//trace(loopCount);
//trace(packButton);
_root.allPacks.packButton._visible=true;
_root.allPacks.packButton.enabled=true;
my traces show loopCount and packButton are working properly, but my final two lines of code to make the corresponding buttons work are failing. anyone have any idea what i am doing wrong? i would be most appreciative for any input!
Last edited by neddyoats; 05-13-2009 at 02:21 PM.
Mindsucker
-
When you know are.
I think what you're trying to do is make a reference to the button named "pack5", located within the allPacks MovieClip. You setup a dynamic reference like this...
PHP Code:
_root.allPacks["pack" + loopCount]._visible=true; _root.allPacks["pack" + loopCount].enabled=true;
Alternatively, if you want to use your packButton variable you can do it like this.
PHP Code:
_root.allPacks[packButton]._visible=true;
And for future reference, if you need to make a dynamic reference to a movieclip within the same object you place a "this" before the square brackets. Like this...
PHP Code:
this["pack" + loopCount]._visible = true;
I remember taking a while to figure that one out.
-
you are my hero! Thanks for taking the time to explain different variations on how to do it.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|