Expert: Mike Dixon Date: 6/28/2008 Subject: Flash 8
Question Is it possible to click attached movieclips in Flash 8?
I have one movieclip on the scene. When I click on it I attache another one with "movieclip.attach". Problem is how do I click that second movieclip?
I've tried this code wich doesn't work:
on(press)
{attachMovie("box","box",1)}
box.onPress=function(){trace("box")}
Answer Nerijus,
You need to assign an unique identifire to new movieclips created with attachMovie. In your example where it is hard coded, it is simple -
attachMovie("box","newBox",1);
newBox will be the name of the newly created clip, and you will use this to contol it - newBox.onPress = function(){
Usually attachMovie is used dynamically and the new name is made by attaching "i" to the name - "box", "box"+i. I recommend reading the flash help on this method, as you will at some point need to create these dynamically and will need to generate higher levels also. It will help you understand exactly how it works. This method is very powerful to the experienced coder. Definately one of the most useful methods in AS2...