TwelvestoneFlash

AS3 - accessing a PNG on the stage in actionscript


Sign in

  • Waiting for Godot ( 730 k posts )
    Just conversation.
  • Thunder Dome ( 23 k posts )
    Photoshop Tennis and Collabs.
  • Photography ( 5.1 k posts )
    For all you shutterbugs, sh...
  • Flash ( 18 k posts )
    ActionScripting to tweens, ...
  • Front End ( 5.9 k posts )
    general front end design an...
  • Back End ( 9.7 k posts )
    serverside scripting, progr...
  • Projects and Theory ( 12 k posts )
    This forum is for discussio...
  • FAQ ( 269 posts )
    All those nagging questions...
  • Design ( 17 k posts )
    graphics & all aspects of g...
  • Purgatory ( 3.6 k posts )
    12stone Jail, feel free to ...
DontBogartMe
 
2010-02-17

I have a few library clips that are masked videos, but the first frame is a PNG, also masked. Nothing has instance names.

I want to be able to work with that PNG in script, but I can't figure out how to work out which child it is from the display list for each lib clip.

I've set up a simple demo running this code: for(var n:Number = 0; n < Test.numChildren; n++){ var objkisplayObject = Test.getChildAt(n); trace("obj - " + obj + ", mask: " + obj.mask); }

on the stage is one instance of a library clip. In the clip are two layers, one is a shape that is the mask, the other is a PNG.

The output is: > obj - [object Shape], mask: null obj - [object Shape], mask: null

So the PNG is coming back as a Shape, and the mask value isn't filled in for masks set up on the stage it seems.

Anyone got any ideas?

I could just wrap the PNGs in an MC, give that an instance name and grab childAt(0) on that wrapper MC, but this would seem a useful thing to be able to do.

lithium
 
2010-02-18

this is to do with the way flash compresses things at compile time.

because the "bitmap" on the stage is only ever able to be used in that one instance, it is not created as a bitmap, but rather as a shape.

If you give that bitmap a linkage ID in the library, thereby making it a dynamically instantiatable object, it will retain its bitmap status, and you will see an "[Object Bitmap]" show up in your output window when you run your code

DontBogartMe
 
2010-02-18

so I guess it also resolves the mask so that also disappears, interesting. Kind of annoying cos it means I have to either edit something (albeit trivial) in the IDE or get the designers to do so. On the other hand I changed my approach to my problem here and don't actually need to do this anymore. Thanks for the 'splanation Lith.

Sorry, you must be a member to post to a conversation. Either log in or sign up to get involved.
TwelvestoneFlash

AS3 - accessing a PNG on the stage in actionscript