Jonathan Dumaine
Jonathan Dumaine

Reputation: 5756

Duplicate MovieClip in AIR/AS3

Has anyone noticed how creating new instances of a MovieClip (and likely other objects as well) in AIR causes some strange effects? If you use Senocular's method by grabbing the object constructor and creating a new instance of the MovieClip, you end up with a new MovieClip with 0 frames. I don't want to draw bitmapData's of every frame into an array, does anyone have a suggestion for making a real duplicate of a MovieClip? (i.e. not just a strong reference).

Upvotes: 3

Views: 2583

Answers (2)

Kefik
Kefik

Reputation: 101

I second, any approach involving getDefinition/getDefinitionByName/object contructor trick does not work inside Adobe AIR (3.7, possibly others).

var movieClipShallow : MovieClip = loader.getMovieClip(url);
var constructor: Class = (movieClipShallow as Object).constructor;
var anotherInstance: MovieClip = new constructor();

movieClipShallow contains different width/height/numFrames/etc. than anotherInstance

I currently do not have solution for that :(

Upvotes: 0

James Hay
James Hay

Reputation: 12720

i'd personally use flash.utils:

getQualifiedClassName(value:*):String

and

getDefinitionByName(name:String):Object

And create an instance using the Class object

I'm sure there may be a reason why Senocular has used this method, but it may be worth trying replacing that line using these two methods to see if it solves any issues you are having.

Upvotes: 2

Related Questions