Can I make a FlexMobile project pure as3? - actionscript-3

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

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
Although a Flex SDK is referenced for AIR, the project will be pure ActionScript.
Choose mobile settings.
Assure all references are merged in to code.
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;
}
}
}

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.

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.

Related

AS3. Class flash.system::Worker could not be found

I can't solve the problem with the Worker class in ActionScript project. I get:
VerifyError: Error #1014: Class flash.system::Worker could not be found
As i searched, VerifyError means that the SWC file is corrupted. How should i fix it ?
Code is simple (Variable of worker Declared) and no additional code except this worker exists.
Tried updating playerglobal SWC with the newest 16 version. Tried updating my Adobe flash professional 5.5, Flash player.
In my projects settings the latest player i can choose to work with is "Flash player 10.2". How could i update it ? or is it the latest ?
import flash.System.Worker;
public class workerService extends Sprite {
var worker:Worker;
public function workerService() {
}
}
Thanks in advance.
That's because the worker class got implemented in Flash Player version 11.4. I'm not sure how to update the SDK in Flash 5.5 though, but maybe this link helps:
https://helpx.adobe.com/x-productkb/multi/overlay-air-sdk-flash-professional1.html
Or just use an ide like flashdevelop.
Add compile flag "swf-version=17" to your flash project and install the latest FlashPlayer.
Add Additional compiler arguments in properties as show in below image

swc cannot show public members in flash builder

I'm trying to create an as3 library (.swc), but weird thing happened. In flash builder 4.7, I can only see the classes of the swc just created, but cannot see the public members. The swc is totally ok to be used, but it doesn't show the public members in package explorer in flash builder 4.7. Does any one know how to fix? Thanks.

Package flash game to AIR mobile (IPA)

I have a complicated game project using multiple libraries, swc, assets, etc. The output is a two swf files (shell with the menu and the game itself). Packing in IPA (iOS) does not work immediately because of a lot of problems and settings ANT. But build as swfs work fine.
Is it possible to create a separate mobile as3 project, which will load the first swf to full screen, which will load the second swf, and then build it? How best to do this? Or are there other options?
Try this:
Compile a copy of your main game swf as an swc.
In a copy of your menu swf, point it to the game swc and in the place you would normally go through the motions of loading the external game swf, just directly add a new instance of the root game class:
// Before:
var ldr:Loader = new Loader();
... other stuff, progress monitoring, etc. ...
var mcGame:MovieClip = ldr.content as MovieClip;
// After - one line:
import my.game.namespace;
var mcGame:GameClass = new GameClass();
Compile this updated menu project as a swc.
In your mobile app, add an instance of the root class of the menu stage:
// Constructor for root class of mobile app
public function AppRoot() {
this.addChild(new GameMenu());
}
Now everything is bundled in a single compiled project.

flash cs5: compiling fla with huge internal library takes YEARS !

by using flash cs5 with a huge internal image library (over 300+ small png-files) i need more than 90seconds for each compiling action! the as code is pretty well, also my computer (quad core, 4gigs of ram). i've found out, that by exporting the files to "stage 1" (bild 1 in my screenshot) flash starts to hang around, but i don't know why...
.
how to speed this process up ?
__________________________________________________________________________________________________________________________________________
__________________________________________________________________________________________________________________________________________
my solution did not work:
so i've played around and ended up creating *.as-files for each single bitmap, but the speed-result is the same (maybe 10% - 15% faster than before)...
package
{
import flash.display.*;
dynamic public class MY_BITMAP_NAME extends BitmapData
{
public function MY_BITMAP_NAME(width:int = 500, height:int = 135)
{
super(width, height);
return;
}
}
}
i can not work fast enough to debug my project files :-(
The solution would be to move your assets inside a precompiled SWC library that you will only recompile when they change.
Building the library:
create a new FLA and move in your Bitmaps,
each image needs to have a linkage class name and be exported in first frame; you don't have to create an AS class, Flash will generate them,
in the publish settings, "Flash" tab, check "Export SWC",
this SWC library will be published in the same location as the SWF; in CS4-5 you can't prevent the SWF creation.
Using the library
in your main FLA publish settings, "Flash" tab, open the Advanced Actionscript 3 settings dialog,
in the "Library path" tab you can add the assets library SWC; make sure the "Link Type" is "Merged into code",
SWC content will be available in your main FLA as if they were in the library.
It is worth noting that:
you must instantiate these assets by code (ie. new AssetName): they will not appear in your main FLA's Library panel and you can not drop them on the timeline,
only assets you explicitly reference in your code will be available at run time; if you are using getDefinitionByName() you must still import the assets somewhere in your code. For instance you can declare an Array containing all your assets classes (ex: var assets:Array = [AssetClass1, AssetClass2,...]).
if these 300+ images don't change too often, you could create a second .fla, where you only put the images in the library. Then you publish that .fla as a swc file (You can set this in the publish settings).
And you use that swc in your original .fla (that now has no images anymore), where you have your code (using the swc means, in the publish settings -> actionscript settings, you set the swc as a library reference).
This way, Flash only has to compile your code and simply takes the already compiled images from the swc. It then should compile much faster.
ctrl+enter, that will compile all things in library and the AS code.
most situation that use just change little things, and then compile it.
it would waste much time that no need to waste.
you can export some thing that would not always be changed to SWC file, and to to publish setting,
add SWC file into your Fla. or move you Fla project to Flash build, compile use less time more than in flash ide.

mx.collections missing? ArrayCollection() in Flex4 (Flash Builder 4)

I have some code that uses an ArrayCollection, it imports:
import mx.collections.ArrayCollection;
then:
static protected var myAC:ArrayCollection = new ArrayCollection();
Seems straightforward, but in my project the import (and thus ArrayCollection) are not found/defined!
I am using Flash Builder 4 (Flex 4) - it's an ActionScript project, and project properties is set to Flex SDK 4.0. Everything should be default settings.
When I type "import mx." and press control-space (autocomplete), I see a list of choices such as core, geom and several others, but no 'collections'.
I must be missing something?
By default, an "ActionScript Project" does not include the framework.swc which contains the flex packages such as mx.collections. If you really want to use ArrayCollection, you'll have add the swc and its corresponding resource bundle swc to your project library path. They are located at:
${FLEX_SDK_HOME}/frameworks/libs/framework.swc
${FLEX_SDK_HOME}/frameworks/locale/${locale}/framework_rb.swc
Export your project to zip
Update to FlashBuilder 4.1
Import your project from zip
Forget about your error)