The main view of the MC to create replication and access to the production and database combined with the Flash site is also a more important link.
The creation of the MC:
The code is as follows |
Copy Code |
Common way to create a movie clip named MC2---------------- var mc2:sprite = new Sprite (); Like C #, Initializes an instance of Mc2.graphics.beginFill (0XFFCC00); Set Fill Color Mc2.graphics.drawCircle (50, 50, 40); Draw a Circle Mc2.buttonmode = true; AddChild (MC2); Add MC2 to the movie |
Replication of MC:
When a MC1 movie clip already exists in the movie
Use the copied method to create a MC1 copy movie clip named MC3------------
Gets the fully qualified class name of the base class of the MC1 object
The code is as follows |
Copy Code |
var classnamestr:string = Getqualifiedclassname (MC1); Class object reference to the class that gets classnamestr var classname:class = Getdefinitionbyname (classnamestr) as Class; var mc3:sprite = new ClassName () as Sprite; Instantiate a movie clip AddChild (MC3); Add MC3 to the current movie |
Copy n mc1 movie clips in a circular fashion
Create N-mc1 copy movie clips using a looping method-----------------
The code is as follows |
Copy Code |
var shells:array = new Array (); for (var i:int = 0; i<6; i++) { var mc:sprite = new ClassName () as Sprite; Instantiate a movie clip mc.x = i * 150; Set Display location MC.Y = + I * 20; Set Display location AddChild (MC); Add the MC to the current movie Shells.push (MC)//Add MC to array for access to replicated MC } |
Access to MC:
Normal access
Like the MC3, to set the x-coordinate of the lower MC3.
mc3.x = 100;
Like the MC3, to set the x-coordinate of the lower MC3.
mc3.x = 100; Loop method to create N-mc1 copy movie clips access
Use the Loop method to set the contents of the mc11txt of the N mc1 replica you just created
The I here is because the previous statement has been made, so the use here is no longer declared
The code is as follows |
Copy Code |
for (i = 0;i<6;i++) { Shells[i].mc11.mc11txt.text = "This is the first" + i;//control by Shells[0]~shells[num] to control, so it is similar to n multiple MC instance name } |
The above writing is still stuck in the as2.0 of the writing only, but has been biased to 3.0.