2

I built a game in Flash Professional and pure AS3. Now I wanted to port it to iOS using Air 2.6. I do this by first creating the SWC file from Flash and then I compile and package the game using the command line. This works fine except that I can't use some of the Assets that I created in Flash Professional.

For example I have created a MovieClip in Flash Professional that's linked to the class file MainMenu.as. Within this MovieClip there is another MovieClip with the instance name background_mc. I declared the variable name in the AS file but when I run the SWF file the value of background_mc is null. However, when I delete the .as file background_mc can obviously be found. What am I doing wrong?

Mr Higgins
  • 66
  • 4
  • A declared var such as var somevar:Object still has a null value. Until you use the new command it will stay null var somevar:object = new Object( ); or somevar = new Object( ); – The_asMan May 23 '11 at 21:49
  • Yes of course, but the new keyword shouldn't be used because the implementation already exists because it's created in the Flash Professional GUI. – Mr Higgins May 24 '11 at 11:45

1 Answers1

1

Okay, I found a solution:
1. All MovieClips need to have "Export for ActionScript" checked.
2. The exported Classes must not be connected to a actual .as file.
3. If a class needs ActionScript-Logic implement a .as file and inherit your MovieClip from that file.

No idea if that's the "right" way but it works and it's not too time consuming. Remember to create the swc file and to call the super(); constructor in your constructors.

Mr Higgins
  • 66
  • 4