Schemaphic Systems Blog

Sharing experiences in Flash, Flex and AIR

Clone Sprite in AS3.0

with one comment

A simple way to clone a sprite:

*  @usage : var newSprite:Sprite= cloneSprite( existingSprite );
*  @params- target:Sprite- existing Sprite which needs to be cloned
public function cloneSprite( target:Sprite ):Sprite
     // create clone
     var targetClass:Class = Object( target ).constructor;
     var clone:Sprite = new targetClass();
     return clone;

Written by Deepanjan Das

February 1, 2011 at 8:56 AM

One Response

Subscribe to comments with RSS.

  1. Hmm, it seems like all this does in instanciate another blank Sprite, or whatever subclass “target” happens to be. It doesn’t transfer any important properties of the original target such as position or children, so I wouldn’t call it a “clone”. It wouldn’t be of any use for making a copy of a Sprite that was created in the Flash Authoring Tool, for example.


    May 18, 2012 at 6:15 PM

Leave a Reply

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

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

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s

%d bloggers like this: