AS3 Can I duplicate a Shape object?

I am trying to make the shape available for duplication. Here's an explanation of what I did, what I'm trying to do, and where I got stuck:

  • I drew the shape manually in the Flash IDE (brush).
  • A new movie clip containing a form has been created; export as a class.
  • Create an instance of the class (var mc: MovieClip = new shapeMovieClip ()).
  • Add the link to the shape in mc that I want (var myShape: Shape = mc.getChildAt (0) as the shape;
  • This works fine, and now I have my form, but how can I duplicate it without creating the parent MovieClip class - is this possible?

I tried to create a new shape and use the copyFrom () graphical method without any effect, I believe that this method simply copies the draw calls when they are made on the specified graph, and instead I just have a link to the form that is already drawn.

Now I am expanding the movieclip as a sprite, creating an instance, pulling the shape out of the parent and keeping its link, and then nullifying the sprite. Does anyone know a better, easier strategy for duplicating shapes this way?

+3
source share
2 answers

, . , , , BitmapData ( rasterisation) Bitmap ( ). :

var base:Sprite = new shapeMovieClip();
var bmd:BitmapData = new BitmapData(base.width, base.height, true, 0);
bmd.draw(base);
var clip1:Bitmap = new Bitmap(bmd);
var clip2:Bitmap = new Bitmap(bmd);

, . Bitmap.smoothing ( ), , , , - mip -. , . ( ), , ( ).

+1

, - Google, :

var shapeonstage:Shape = shapeMadeInIDE;
var g:Vector.<IGraphicsData> = shapeonstage.graphics.readGraphicsData();

var shapecopy:Shape = new Shape();
shapecopy.graphics.drawGraphicsData(g)

. . , looooong .

UPDATE:

, , AND , swf.

Shape , Flash Rendering - . Shape , Shape .

:

  • fla .
  • 10 .
  • ( " 1" )
  • ( , bmp )
  • - 5
  • .

, , , SOMETIMES .

, , , , :)

+1

All Articles