I’m using format.SVG to import SVG images. I need to instantiate the images on demand and I am wondering what would be the best way for doing this?
At the moment I’m pre rendering all needed SVG in a init script. This gives me a list of Shapes. Now, when I need one I use copyFrom on a Sprite.graphcis to copy the shape and with that instantiating it.
This seems faster then using format.SVG on demand, but, is this the best way of doing this?
That seems like an alright solution, if it’s working for you. Otherwise you can also use
bitmapData.draw to commit the graphics to a
graphics should also work
Thanks for your reply!
The reason I was wondering about this is because the bitmaps seem to be a shared resource. I don’t belief - but am not 100% certain - that bitmapData gets copied or processed, it’s just referenced. Based on the function name: copyFrom, i’m assuming that the grahpics are copied - and maybe even processed/rendered after doing that. But then again, semantics can be misleading
If the graphcis get copied and/or processed with each call to copyFrom and Bitmaps only get referenced… Then instead of making a list of Shapes, i can better make a list of bitmapData’s and use.those to instantiate from
Does anyone perhaps know if copyFrom makes a new copy of the graphics data and renders its own version.?, or does it just get referenced, or just maybe it has something like a cache system that only rerenders when needed?? If it’s efficient I will gladly use it, otherwise perhaps go for the bitmapData.!
Thanks in advanced for any help!
It makes a copy of all the draw instructions, but the instance will end up with its own bitmap render, so if you want to reuse graphics a lot, that’s a point in the
Yes, I do want to reuse the graphics a lot! I will setup my program to use bitmapData.draw!