Today, we found that addchild () is a few useful things. If you do not have attachmovie to copy a movie, you need to create a new movie scene. as3.0 unifies the creation of new XXX.
First, create a new video clip named Mc. Face this video clip in the library and select
Add the code in the first frame of the scene to display it:
VaR A: MC = new MC ();
Addchild ();
It is very simple to show that it is very different from the attachmovie () usage of as 2.0.
Suppose we want to copy Multiple balls:
For (var I: Int = 0; I <3; I ++)
{Var A: MC = new MC ();
Addchild (a); // Add to container
A. X = I * A. width; // different coordinates are displayed.
}
When we want to delete a video, we will perform a simple test:
BTN. addeventlistener (mouseevent. Click, del)
For (var I: Int = 0; I <3; I ++)
{
VaR A: MC = new MC ();
Addchild ();
A. Name = "A" + I;
}
For (var j: Int = 0; j <3; j ++)
{
VaR B: mymc = new mymc ();
Addchild (B );
B. Name = "B" + J;
B. x = J * B. width;
B. Y = J * B. width;
}
VaR T: Int = 0;
Function del (Event: mouseevent): void
{
If (T <3)
{Removechild (getchildbyname ("B" + T ));
T ++;
}
Else {
Trace ("deleted ");
}
}
Create a button to listen. When the mouse receives a message, it deletes one button every time until it is deleted.