开发者

Import Flash AS3 Game to Flash Builder 4.5

Probably this is a newbie question :开发者_如何学Go) 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


  1. Using Flash Builder 4.5 to package applications for Apple iOS devices.
  2. Using Flash Builder 4.5 to package applications for Google Android devices.
  3. Using Flash Builder 4.5 to package applications for BlackBerry Tablet OS.

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);
        }
    }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜