3 Replies Latest reply on Jun 12, 2012 11:07 PM by GameDesignProfessor

    Can I port existing ActionScript project to an iOS Flex mobile project?

    GameDesignProfessor Level 1

      Hello yall,

      I want to port an existing ActionScript game over to an iOS Flex mobile Project.

       

      Is there an example of this on the Adobe site?

       

      Can someone give me an example, if it is possible, to call the files from the .mxml file?

       

      My build path is set for the shared source files.

       

      Here is my Action Script code from my Application file in the Action Script project:

       

      I have the shared source folder in the build path.

       

      package

      {

      import Puzzle.*;

       

      import flash.display.Sprite;

      import flash.display.StageAspectRatio;

      import flash.display.StageOrientation;

      import flash.events.Event;

      import flash.system.Capabilities;

       

      // The following metadata specifies the size and properties of the canvas that

      // this application should occupy on the BlackBerry PlayBook screen.

      [SWF(width="1024", height="600", backgroundColor="#000000", frameRate="60")]

       

      public class KnockemOff_Mobile_iOS extends Sprite

      {

      // Backbuffer information

      //private var backBuffer:BitmapData;

       

      public function KnockemOff_Mobile_iOS()

      {

      trace (flash.system.Capabilities.version);

      trace (flash.system.Capabilities.os);

      trace (flash.system.Capabilities.playerType);

       

       

      // Initialize the game when stage is ready

      if(stage)

      init();

      else

      addEventListener(Event.ADDED_TO_STAGE, init);

      //GameIFace.IGameController().stage.

      var ver:String = flash.system.Capabilities.version.substr(0,3);

      if (ver == "AND")

      {

      GameIFace.IGameController().stage.setOrientation(StageOrientation.DEFAULT);

       

      }

       

       

      }

      private function init(e:Event = null):void

      {

      // Set stage

      GameIFace.IGameController().stage = stage;

       

      // Initilize game controller

      GameIFace.IGameController().Init();

       

      // Show the stage

      //GameIFace.IGameController().stage.nativeWindow.visible = true;

       

      if (GameIFace.isDebug)

      {

      // Start splash screen

      GameIFace.IGameController().stateMachine.ChangeState(

      GameIFace.IGameController().stateMachine.CONST_STATESplashState);

      }

      else

      {

      // show Ad

      GameIFace.IGameController().stateMachine.ChangeState(

      GameIFace.IGameController().stateMachine.CONST_STATEAdState);

      }

      }

      }     

      }

       

       

      I took what is inside the Package{…} And applied that within the <fx:Script> tags(indicator)

       

      But received 1131:Classes must not be nested

      Took it out of the public class and received Multiple Constructor error.

      Found a discussion on multiple constructors here: http://forums.adobe.com/message/405432

       

      But would really like to avoid a bunch of guessing and and patching.


       

      Thanks

        • 1. Re: Can I port existing ActionScript project to an iOS Flex mobile project?
          drkstr_1 Level 4

          If you will not be using any of the Flex framework in your project, I would suggest creating an "Actionscript Mobile Project" instead. That being said, you can add Sprites to a SpriteVisualElement or a UIComponent (not a base class of UIComponent). I can't speak towards your error since you did not post any relevent code.

          • 2. Re: Can I port existing ActionScript project to an iOS Flex mobile project?
            GameDesignProfessor Level 1

            Thanks for the help!

             

            Here is the current code:

             

            <?xml version="1.0" encoding="utf-8"?>

            <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"

                           xmlns:s="library://ns.adobe.com/flex/spark" applicationDPI="160" minWidth="1024" minHeight="600">

             

                <s:layout>

                    <s:HorizontalLayout/>

                </s:layout>

                <fx:Script>

                    <![CDATA[

            //package

            //{

                        import Puzzle.*;

             

                        import flash.display.Sprite;

                        import flash.display.StageAspectRatio;

                        import flash.display.StageOrientation;

                        import flash.events.Event;

                        import flash.system.Capabilities;

             

                        // The following metadata specifies the size and properties of the canvas that

                        // this application should occupy on the iOS screen.

                        [SWF(width="1024", height="600", backgroundColor="#000000", frameRate="60")]

             

                    //    public class KnockemOff_Mobile_iOS extends Sprite

                    //    {

                            // Backbuffer information

                            //private var backBuffer:BitmapData;

             

                            public function KnockemOff_Mobile_iOS()

                            {

                                trace (flash.system.Capabilities.version);

                                trace (flash.system.Capabilities.os);

                                trace (flash.system.Capabilities.playerType);

             

             

                                // Initialize the game when stage is ready

                                if(stage)

                                    init();

                                else

                                    addEventListener(Event.ADDED_TO_STAGE, init);

                                //GameIFace.IGameController().stage.

                                var ver:String = flash.system.Capabilities.version.substr(0,3);

                                if (ver == "AND")

                                {

                                    //                [SWF(width="1024", height="600", backgroundColor="#000000", frameRate="60")]

                                    GameIFace.IGameController().stage.setAspectRatio(StageAspectRatio.LANDSCAPE);

                                    //GameIFace.IGameController().stage.setOrientation(StageOrientation.DEFAULT);

             

                                }

             

                            }

                            private function init(e:Event = null):void

                            {           

                                // Set stage

                                GameIFace.IGameController().stage = stage;

             

                                // Initilize game controller

                                GameIFace.IGameController().Init();

             

                                // Show the stage

                                //GameIFace.IGameController().stage.nativeWindow.visible = true;

             

                                if (GameIFace.isDebug)

                                {

                                    // Start splash screen

                                    GameIFace.IGameController().stateMachine.ChangeState(

                                        GameIFace.IGameController().stateMachine.CONST_STATESplashState);

                                }

                                else

                                {

                                    // show Ad

                                    GameIFace.IGameController().stateMachine.ChangeState(

                                        GameIFace.IGameController().stateMachine.CONST_STATEAdState);

                                }

                            }

            //            }

            //}

             

                    ]]>

                </fx:Script>

             

                <fx:Declarations>

                    <!-- Place non-visual elements (e.g., services, value objects) here -->

                </fx:Declarations>

             

             

            </s:Application>

             

            Here is the Error:

            Multiple markers at this line:

            -KnockemOff_Mobile_iOS

            -Multiple constructor definitions found. Constructor may not be defined in <Script/> code.

             

            I am using Flex for iOS.  I thought flex was the only project that compiled iOS projects.

             

            Thanks

            • 3. Re: Can I port existing ActionScript project to an iOS Flex mobile project?
              GameDesignProfessor Level 1

              Went with Action Script and it works Thanks again.