Flash as 3.0 MC Create replication and Access instance

Source: Internet
Author: User
Tags addchild

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.