In Flash builder, I want to create an "Actionscript Project" that uses the mx datagrid component. Unfortunately the mx/spark components don't seem to be available unless your project is a "flex project". Is there a way around this? (I really don't like using that mxml mark-up, and just want to write pure code)
thanks!
In ActionScript Build Path, you have to manually add SWC libraries outside Flex library as shown below (add additional libraries as per your requirement):
Related
It seems that in Flash, you can load an SWF (CS-built) with Loader. To load the same (CS-built) SWF in Flex, you need SWFLoader.
The thing is, I am creating an SWF-loading framework and I want it to be cross-compatible, both with Flash CS and Flex. Is this possible, or do I need 2 versions of my code?
Yes it's possible to use the SWFLoader class with (at least) CS5.5; you need to download the Flex SDK and declare the Flex libraries for use inside the authoring tool.
In other words, you have to add this path inside the "Library Paths":
...\flexsdk\frameworks\libs
then you can use all Flex libraries with CS5.5.
I have a flex component that is using mostly mx and actionscript code. I am using it fine in my AIR application, however, I need to be able to use certain Air libraries within this component, so I need to make it Air 'aware' or compatible.
For example, I need to get a reference to the current active window, so it looks like I need to use NativeApplication.activeWindow.
But when I type this in to my component actionscript class, it does not know about NativeApplication. So it seems I have to do something to that project to enable Air classes, unless there is another approach?
Do you use Flash Builder and Flex Library Project to compile your component?
If yes, there is a checkbox "Include Adobe AIR libraries" in the project properties. Open Project > Properties > Flex Library Compiler and check "Include Adobe AIR libraries".
Need to import the libraries into your code like this:
import flash.display.NativeWindow;
import flash.display.NativeWindowSystemChrome;
import flash.display.NativeWindowInitOptions;
Then the application can use it.
is it possible to move a flex mxml project into flash?
i have the project complete in mxml with actionscript but due to the fact that flex is limited in its visual animations ( no timeline! ) i would prefer to switch to using flash.
the project is relatively huge, all done in mxml and i cant just re-create it in flash, it will take months!
what do you think? is there a conversion ability or a use of flex component inside flash? if so, how?
Thanks.
There is no conversion utility, but as noted in the comments you can build your animation in the Flash authoring tool and import it to Flex (Flash Builder.)
The way you do this will depend on what type of animation you're trying to do. If it's just a simple path or the animation of some type of built in shape you'll want to export the animation to FXG to easily import it into Flex. Select the object you're trying to export and hit file->export->Export Selection. In the export window select "Adobe FXG" as the export format. Try this article for more information.
If you're building an animation that needs to be controlled via scripting or is more complicated you'll need to export it as Flash content (SWF or SWC are fine.) Then load the object in to your Flex application dynamically and script it accordingly. Be aware that cross-swf scripting security issues may arise if you use a swf loaded at run time.
You might consider converting the Flex project into a Flex library project and placing the resulting swc into the class path of the Flash project.
The internet says to add
import fl.controls.Combobox
But Flex says that there is no class called fl.controls
Which is the equivalent class in flex?
You cannot import fl.* classes to a Flex application, and you cannot import mx.* classes to a Flash application - those are platform specific if you will. Only flash.* classes can be used irrespective of the platform.
Use the flex combo box as already suggested, or export the flash combo box to an SWC and give it a shot.
This shouldn't be an issue if you're using Flex as just an editor - that is if you're not compiling your AS files using Flex. The only problem would be that you won't get auto-complete for fl classes. You can just ignore the flex errors and compile it using flash.
mx.controls.ComboBox
Is it possible to use Flex 3 component/code inside Flash (cs4) SWF file ?
I know its possible in the opposite direction.
With my minimal testing it seems you can't use Flex components when building a "pure AS3" project. (Can we start calling it PAS3 or something? Like "passé". Or "pastry". :)
I did this admittedly limited testing by creating a test project with one AS class as the "document class", which would instantiate and addChild one mx.controls.Button. I copied the whole mx package from the path mentioned by hasseg into the project source path.
This is what I found out:
By removing the use of mx_internal from a certain Version.as file, I got Flash IDE to compile my test project without warning. Nothing showed up on the stage though.
Using Flex Builder (and the flex compiler, obviously) I also managed to compile the project without errors. I put breakpoints in the code and watched it build itself in the debugger. The components were instantiated flawlessly, but still nothing showed up on the stage. This swf also crashed the browser numerous times.
I haven't used Flex code in a "pure AS3" project myself, but I don't see why you couldn't do that.
You can download the Flex SDK and get the Flex components from there, both as an swc file (under /frameworks/libs) and as AS3 source code (under /frameworks/projects/framework/src).
It looks like this can be done after all: http://labs.wichers.nu/2007/12/25/using-flex-compiled-code-within-flash/
In general you need to use MXML to initialise the Flex framework and use Flex components.
Mike Chambers from Adobe says:
There is not support for using the Flex Framework in an AS only project. While it is theoretically possible, you would have to manually bootstrap a lot of the application initialization code that Flex handles (something which would be rather complex). - Source
To see how complex, you can tell the compiler to keep the intermediate AS3 files that it generates from the MXML. Open your AS3 project properties and set -keep-generated-actionscript as an argument to the compiler. Compile your project then look in the obj/generated folder. Using Flex 4, I get 13 small files the main of which extends spark.components.Application and overrides a few methods.
So it's possible but you probably wouldn't want to do it. Flex is meant to make your life easier, not harder.