开发者

Displaying multiple copies of same external movie clip

开发者 https://www.devze.com 2023-03-31 05:10 出处:网络
It\'s easy to share bitmap data between multiple Images: // target and source are instances of the mx.controls.Image class

It's easy to share bitmap data between multiple Images:

// target and source are instances of the mx.controls.Image class
var content_copy:Bitmap = new Bitmap((source.content as Bitmap).bitmapData)开发者_开发技巧;
target.load(content_copy);

But how to do the same thing for movie clips with vector grapics? The only way I've found is to load movie clip using byte data of another movie clip as the source.

target.load(source.content.loaderInfo.bytes);

But it actually duplicates the content.


There is no way to share the content (in ActionScript memory, whether it happens in runtime memory I'm not sure), but if you just want to avoid loading it twice, your existing solution of loading the bytes is the best solution.

However, if the MovieClip doesn't need to be interactive, you could draw it to a BitmapData and share that BitmapData. Obviously, whether this actually optimizes your memory profile depends on how many instances you need as well as the complexity of the vector data.

0

精彩评论

暂无评论...
验证码 换一张
取 消