1 Reply Latest reply on Feb 11, 2012 2:52 PM by rob_hart60

    How to import package into Flex project

    rob_hart60

      Hi, I'm very new to Flex and have recently as part of a university project created a game using Flixel. And I'm currently thinking I'd like to see what my game looks like exported as an Air app (With a view of testing on my iPad in the future). And I've realised (though I may be wrong!?) to be able to convert my game that currently only uses .as class files as an Air app they first need to run via a Flex application. Which is why I'm here, I've spent the whole day trying to figure it out and Googling endlessly, getting nowhere!

       

      The code that shows where I'm at is below...

      MXML file:

       

      <?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" 
                                       xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="800" minHeight="600">
        
        <fx:Script source="FlixelExample.as">
                          <![CDATA[
                import FlixelExample;
        
                private var myDemo:FlixelExample = new FlixelExample();
        
                protected function application1_creationCompleteHandler(event:FlexEvent):void
                {
                this.addElement(myDemo);
                }
                          ]]>
        </fx:Script>
        
        <fx:Declarations>
        <!-- Place non-visual elements (e.g., services, value objects) here -->
        </fx:Declarations>
      </s:Application>
      

       

      I was hoping to link it with a .as file that initialises the game...

      .as file:

       

      package
      {
                import org.flixel.*; 
                import com.flixelexample.MenuState;
      
                [SWF(width="800", height="600", backgroundColor="#333333", framerate="60")]
      
                public class FlixelExample extends FlxGame
                {
                          public function FlixelExample()
                          {
        super(800,600,MenuState,1);
                                    FlxG.debug = true;
                          }
                }
      }
      

       

      I'm starting to wonder if I'm on the wrong track for what I'm trying to achieve. The thread that I've been using to help get it to work from can be seen here http://forums.adobe.com/message/2872998 if you look at post 3 when I saw this I thought it would work, unfortunately it didn't.

       

      Any help would be much appreciated!

      Rob

        • 1. Re: How to import package into Flex project
          rob_hart60 Level 1

          I finally found a solution that works via http://forums.adobe.com/thread/830358

           

          Basically this is what the mxml file looks like:

           

          "FlixelExample" being the .as file that start the game I created.

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

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

                                           xmlns:s="library://ns.adobe.com/flex/spark"

                                           xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="800" minHeight="600"

                                           applicationComplete="init();">

           

            <fx:Script>

                              private var object:FlixelExample;

                              private function init():void {

                                        object = new FlixelExample();

                                        stage.addChild(object);

                              }

            </fx:Script>

           

            <fx:Declarations>

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

            </fx:Declarations>

          </s:WindowedApplication>

           

           

          Thanks,

          Rob