Actionscript 3 Answers: targeting
- Started
- Last post
- 3 Responses
- CyBrain
I've asked so many questions I decided it was time to provide an answer for a recent thread I started.
I was having a ton of issues targeting movie clips. I was able to set up a file with an array of 5 movie clips and then another one not in the array. I was able to target a specific movieclip in the array, the one outside the array and any of them from a button class. It might sound pretty noobish, but if you're starting out in AS3 like me this might help. I put in a lot of comments. It's an FLA with two symbols that have linkage, a document class and a button class.
Here's my document class:
http://pastebin.com/f39920fabbutton class:
http://pastebin.com/d51774cceSource files.
http://talesfromthehead.com/rand…Finished page:
http://talesfromthehead.com/rand…
- Pupsipu0
yea it's either that or getChildByName() and getChildByIndex(). It's also in that kirupa AS3 Tips thread if you start reading it from the beginning. And congratulations.
- airey0
thanks mate!
- NONEIS0
OK, so here's the thing. You need to wait for your classes to initialize before trying to use MovieClips that are on your stage.
In your constructor for the document class, add an event listener for ADDED_TO_STAGE, make that call a function that does your set up code. No need for an array unless you really want one, you can simply use the instance names if you wait for that event to fire, or store them into private vars which is far better.