Reputation: 363
Probably this is a newbie question :) But I have some Flash games built in AS3. And I want to import it to Flash Builder 4.5 to create Andorid, iOS version of these games.
Is it possible to import this games to Flash Builder and just run something like "compile for Android"?
If is possible, how can I do that?
Best, Flavio
Upvotes: 0
Views: 1108
Reputation: 17217
if most or all of your .swf was created on the timeline instead of portable code, you can simply create a wrapper and/or preloader to load that .swf and add it to the display list. something like this:
package
{
//Imports
import flash.display.Loader;
import flash.display.Sprite;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.events.Event;
import flash.events.ProgressEvent;
import flash.net.URLRequest;
//Class
[SWF(backgroundColor = "0x444444")]
public class SwfAirWrapper extends Sprite
{
//Constructor
public function SwfAirWrapper()
{
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;
stage.frameRate = 60;
init();
}
//Initialize
private function init():void
{
var swfLoader:Loader = new Loader();
swfLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, loaderCompleteEventHandler);
swfLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, loaderProgressEventHandler);
swfLoader.load(new URLRequest("MyGame.swf");
}
//Loader Progress Event Handler
private function loaderProgressEventHandler(evt:ProgressEvent):void
{
//preloader stuff goes here
//IE: evt.bytesTotal / evt.bytesLoaded * 100)
}
//Loader Complete Event Handler
private function loaderCompleteEventHandler(evt:Event):void
{
//Load complete stuff goes here
//IE: addChild(evt.currentTarget.content);
}
}
}
or if you don't want a preloader you could simply embed your swf. something like this:
package
{
//Imports
import flash.display.DisplayObject;
import flash.display.Sprite;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
//Class
[SWF(backgroundColor = "0x444444")]
public class SwfAirWrapper extends Sprite
{
//Variables
[Embed(source = "mySwf.swf")]
private var EmbeddedSwf:Class;
//Constructor
public function SwfAirWrapper()
{
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;
stage.frameRate = 60;
init();
}
//Initialize
private function init():void
{
var mySwf:DisplayObject = new EmbeddedSwf();
addChild(mySwf);
}
}
}
Upvotes: 1