MikeW
MikeW

Reputation: 4809

Can I make a FlexMobile project pure as3?

I've got an as3-robotlegs (signals) app that I want to run as a mobile project. I've discovered I can't have a pure as3 entry class ie.

this works fine for a Flash professional or pure as3 project

    public class TestX extends Sprite
{
    protected var context:ApplicationContext;
    use namespace mx_internal;


    public function TestX()
    {
        LoaderConfig.mx_internal::_url = loaderInfo.url;
        LoaderConfig.mx_internal::_parameters = loaderInfo.parameters;
        context = new ApplicationContext(this);     <---
        this.stage.nativeWindow.visible = true;
    }
}

now for FlexMobile I need to do something like this in index.mxml

    <fx:Declarations>
        <context:SignalCafeContext contextView="{this}"/>   <----
    </fx:Declarations>

But do I really need to convert all my flash components to Flex UIComponent or is there a way I can use pure as3 (no mxml) in a FlexMobile project?

Thanks

Edit:

Took me a few days to churn through these great answers... all of them correct as I far as I can tell, I found amy's publishing arbitrary swfs works great, i found it easier to go with a pure actionscript mobile project

Upvotes: 2

Views: 716

Answers (3)

Jason Sturges
Jason Sturges

Reputation: 15955

Command-line Adobe AIR Developer Tool (ADT) can package a SWF for mobile.

This way, any monolithic SWF created from various toolchains may be packaged for mobile.

  • Download AIR 3.5 SDK.
  • Assure JRE, or use the one from Flash Builder.
  • Execute adt to package your SWF to an IPA:

    adt -package -target [ipa-test | ipa-debug | ipa-app-store | ipa-ad-hoc]
        -keystore iosPrivateKey.p12 -storetype pkcs12 -storepass qwerty12
        -provisioning-profile ios.mobileprovision
        HelloWorld.ipa
        HelloWorld-app.xml
        HelloWorld.swf icons Default.png
    

Otherwise, Flash Builder 4.6 has pure ActionScript mobile projects:

  • Select File » New ActionScript Mobile Project

    new-actionscript-mobile-project

  • Although a Flex SDK is referenced for AIR, the project will be pure ActionScript.

    project-location

  • Choose mobile settings.

    mobile-settings

  • Assure all references are merged in to code.

    built-settings

  • Which will stub your project as:

    package
    {
        import flash.display.Sprite;
        import flash.display.StageAlign;
        import flash.display.StageScaleMode;
    
        public class X extends Sprite
        {
            public function X()
            {
                super();
    
                // support autoOrients
                stage.align = StageAlign.TOP_LEFT;
                stage.scaleMode = StageScaleMode.NO_SCALE;
            }
        }
    }
    

Upvotes: 4

Amy Blankenship
Amy Blankenship

Reputation: 6961

You can just take your swf and publish it for mobile, using these steps.

  • Create a new ActionScript Mobile Project and give it a name.
  • Go to Project -> Properties -> Builders.
  • Uncheck the “Flex” builder (but leave the “AIR application.xml Builder”)
  • Now copy your arbitrary swf (ie: myapp.swf) into the bin-debug folder.
  • Create an ActionScript class with the same name as the swf, (ie: myapp.as) in the default package space.
  • Right click on the myapp.as file and click on “Set as Default Application”
  • Now it will generate a myapp-app.xml, go and open and edit as you like.
  • Click on run configuration and package your app for you the platform you want.
  • Repeat steps to add more SWFs to package.

You can also find steps to go back and forth between Flash Pro and Flash Builder here.

Upvotes: 1

JeffryHouser
JeffryHouser

Reputation: 39408

But do I really need to convert all my flash components to Flex UIComponent or is there a way I can use pure as3 (no mxml) in a FlexMobile project?

In Flash Builder 4.6 you can create an ActionScript Mobile project; which should do what you want. Creating a Flex Mobile project, assumes you will have dependencies on the Flex Framework and imposes some specific patterns on you, such as having your main application file be an MXML file that extends Application.

Upvotes: 3

Related Questions