Jump to content

Search In
  • More options...
Find results that contain...
Find results in...
ICOM Productions

Bug: Blitmask and Air in Flash Professional CS5 [SOLVED]

Recommended Posts

Hi Jack and fellow greensock-ers,


First of all, Jack, it's been an absolute dream to work with your code. Very easy to understand, implement, and modify where needed (Don't worry! I haven't mangled anything too terribly yet!). I've learned a LOT from poking around in your code, and now use your setDefault technique in just about all of my own work as well. That's only a small part of the learning you've afforded me through working with your code - thank you very much for your hard work and dedication to the community.


That said, I've run into a bit of an odd snag and haven't been able to get to the bottom of it myself.


I'm attempting to use your work in an air application that I'm publishing from within Flash Professional CS5. (Note that I've removed some info from file paths in the error text)



ArgumentError: Error #2015: Invalid BitmapData.
at flash.display::BitmapData/ctor()
at flash.display::BitmapData()
at com.greensock::BlitMask/_captureTargetBitmap()[...\GreenSock\bonus-all-v11\AS3\com\greensock\BlitMask.as:218]
at com.greensock::BlitMask/update()[...\GreenSock\bonus-all-v11\AS3\com\greensock\BlitMask.as:266]


This error is occurring in a rather large application I'm building for my company, which unfortunately I can't send directly, so I'm trying to replicate the issue in a test fla at the moment, but can't seem to do in a stripped down fashion. Any general pointers on what might be causing this while I try to replicate? I have a feeling that somehow I've caused BlitMask to try and fire an update before it has masked any content, although I can't determine where I might be doing this.


The other option is that because this app was built originally as a Flash Professional SWF project (and only in the last week and a half of the build did our client request functionality that was previously dismissed that only air or a c# wrapper would provide...), I've got something horribly backwards in regard to AIR (this is my first time working in AIR without working in mxml) but can't seem to determine what the issue is. I'll keep digging, but any thoughts you have on this would be greatly appreciated.


Thanks again for your hard work and excellent code,


Link to comment
Share on other sites

Further information - upon commenting all references to Blitmask out of the app, no further errors were present, so I'm guessing something isn't playing nice between AIR framework and the way I'm using blitmask. That said, I really like Blitmask's performance and functionality - it's pretty central to the pan/zoom functionality of the app, so I'll continue to develop for flash player until I find the trouble.


Still have had no luck reproducing in a test fla, but I'll keep at it. I am using FlashBuilder to manage the classes and project overall, and my AS is in classes rather than in the swf. Going to try this approach again -> maybe it was something I did or didn't do in converting to AIR export settings.


Thanks again Jack,



Link to comment
Share on other sites

Hmmm...my best guess is that you're setting the BlitMask's width or height to a negative value (which wouldn't make sense of course). I just uploaded a new version of BlitMask that will throw a more informative error if that happens. Please download it and give it a shot.


And thanks for the kind words, by the way. It's always nice to hear from a fellow developer who found some inspiration in the code.


If you're still having trouble, maybe you could post your project somewhere and PM me the link so that I could download it and publish it to see the issue. Again, my best guess is that you're using a negative width or height somewhere.

Link to comment
Share on other sites

Eureka! Found the problem!


I downloaded the latest BlitMask, which still threw the same error, which got me thinking "What if they're not negative, but undefined!"


Somehow, the stage was throwing resize events prior to stage.stageWidth and stageHeight being available, or the stage having content. They must have been undefined/null when my resize handler was first fired.


Updated the stage resize handler to check that the BlitMask instance exists and that the stage has content before worrying about resizing, and it seems peachy. (And we seem to get a statistically significant increase in execution speed to boot!) [Edit]


Strangely enough, this error only pops up when exporting for Air - everything worked fine with the same resize handler when exporting for Flash Player 10.


I'm guessing that Air must handle calculating the stage width/height differently, firing resize events before the stage width/height are set initially, or that the Flash Player has some inbuilt logic to avoid these situations that Air is missing.. Too weird!


Thank you for the help sir! You truly are a scholar and a gentleman, and your spirit of generosity and willingness to assist are inspirational, much like your code.


I'm cooking some pretty neat functionality into TransformManager that I'd like to share with you when complete, to return the generosity and good-will you've shown. I would provide it in hopes that it inspires you to completely re-write and greensockematize (greensockify?) my work for future inclusion - is this something you'd be interested in, and if so, where would be best to send the modified source?




Link to comment
Share on other sites

Phew! Glad you figured it out. Yeah, having an undefined width or height would be a problem :)


As for sharing your TransformManager edits, absolutely - I'd love to see them. Shoot me an e-mail or a PM here in the forums with a link to your stuff. I'll do my best to "greensockify" it :ugeek:


Rock on.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.