Duplicating a display object in AS3


Handy for an interface where an item is clicked on to form a copy, like drag and drop:

var targetClass:Class = Object(displayObjectToClone).constructor;
var duplicate:DisplayObject = new targetClass();
this.addChild(duplicate);

More on this at:

http://actionscript-blog.imaginationdev.com/3/duplicate-movie-clip-flash-action-script-2-vs-action-script-3/

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s