Clients Login
Search tips and advanced search
Lets Socialize
Hybrid Mindset on Twitter  Hybrid Mindset on LinkedIn  Hybrid Mindset on Facebook  Hybrid Mindset RSS Feed 
Want to be a guest blogger? Sign up and share your thoughts...
Blog Page Heading
Featured Blog

My PushButton Engine Experience Week 3...7

Serialization, Serialization...

Posted Date: 2010-08-24   Posted Time: 01:24:59
Print Blog PostPrint  Tweet Blog PostTweet This Comment On Blog PostComment 

Blog Posts

View All

Rendering Embedded SWFs On iOS Devices Using AIR 2.6

Created: Tuesday, April 5, 2011 @ 01:24 PM  

My initial attempts at this were not successful. I kept getting a warning saying "Uncompiled Actionscript" (see pic below). This is do to the fact that you can not access any swf data that is not compiled to bytecode from an iOS app compiled using ADT from the AIR 2.6 sdk.




I was embedding swfs with movieclip symbols within them by using the embed metadata tag. (i.e. [Embed(source="MidevileAssetBundle.swf", mimeType="application/octet-stream")] ). When running your swf on anything besides an iOS device this is an easy way to embed a bundle of swf assets that can be pulled out later at runtime. So I found a solution using class level metadata embedding.


Class Level Metadata Embedding





You can embed assets using a class level embed tag. There is one other benefit here besides the fact that it can be rendered on iOS devices. You can define the exact class that your embedded asset extends keeping file size down. This is nice because if you do traditional variable instance Embedding it uses the flex framework classes to embed assets using classes from the mx.core package.  Using this method you can embed assets using just AS3 instead of having a dependency on the flex framework.


PBE Embedded Resource




With PushButton Engine you embed resources using member variables defined on a class that extends ResourceBundle. Those member variables are then automatically registered with the PBE ResourceManager using reflection. So to use the class level embedded classes that we created above you just define a member variable with the type being the asset class name and add a "ResourceType" metadata tag with the name of the resource and the resourceType class name that will be used when registering the resource with the PBE ResourceManager. That simple, hope this saves someone else days of research.


If you have a image that you want to embed instead of a symbol in another swf you can use the same technique just change the class that your asset extends from MovieClip to flash.display.Bitmap. Then change the className on the ResourceType metadata tag to "com.pblabs.engine.resource.ImageResource"


**In order for this to work with PBE I had to make a few minor changes to the base ResourceBundle class of PBE.  Also make sure you include the word "ResourceType" in the additional compiler arguments
"-keep-as3-metadata+=SWF,TypeHint,EditorData,Embed,ResourceType"




Categories
 Twitter Feed
@hybridmindset