Author Topic: Importing package into Flex project  (Read 1032 times)

@robhmedia

  • Member
  • **
  • Posts: 8
  • Karma: +0/-0
    • View Profile
Importing package into Flex project
« on: Fri, Feb 10, 2012 »
Hi, I have a game made as part of a uni project working nicely as is. I'm curious to see what it looks like as an air app on my iPad and having some difficulties. The first problem I'm having is when I try 'Add/Change Project Type' the selection 'Convert To Flex Desktop Project' is greyed out. Some trial and error later and I realised to be able to click on that option the project needs to be running via an actual Flex project as opposed to just the class files I'm currently working with.

So I've gone about creating a Flex project and I've been attempting linking it to the .as files without success. Some sample code below;

Flex project file:
Code: [Select]
<?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="955" minHeight="600">

<fx:Script>
<![CDATA[
import FlixelExample;
]]>
</fx:Script>

<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
</s:Application>

Which is supposed to link to the following class file:
Code: [Select]
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;
}
}
}
Then after this code in theory I was hoping it would run as normal. :P (Wishful thinking!)

I don't get any errors and I've checked and checked again the files are in the correct locations etc, all that's happening is a blank white window appearing. This is my first Flixel project so I'm forever learning new things atm. If your interested you can see the game in its current state (Without the Air attempt) via Facebook https://www.facebook.com/pages/Interchange-Game-Demo/226780087410314

Any advice would be greatly appreciated!
Many thanks,
Rob
« Last Edit: Fri, Feb 10, 2012 by @robhmedia »

@robhmedia

  • Member
  • **
  • Posts: 8
  • Karma: +0/-0
    • View Profile
Re: Importing package into Flex project
« Reply #1 on: Sat, Feb 11, 2012 »
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.

Code: [Select]
<?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