How about using FLEX 3 component inside Flash file? - apache-flex

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.

Related

Flex - Source Size vs. Compile Size

Could you explain why a Flash Builder source folder - no larger than 2 MB - compiles into a SWF exceeding 15 MB with debugging turned off (exported release build)?
There is only 1 embedded image at about 93k - no other images. The application is not that complicated, basically calls are made to a MySQL db to display information, as well as store information. I have used drop shadows and borders, but all standard to Flash Builder. Some custom classes and one custom skin.
Thank you...
Here is listing of the files:
.DS_Store
mx_4.5.1.21328.swz
Main.html
playerProductInstall.swf
Main.swf > 15 MB
rpc_4.5.1.21328.swz
amf_config.ini
services
assets
skins
charts_4.5.1.21328.swz
spark_4.5.1.21328.swz
framework_4.5.1.21328.swz
sparkskins_4.5.1.21328.swz
gateway.php
swfobject.js
history
textLayout_2.0.0.232.swz
This seems pretty large to me.
When you say "Debugging Turned Off" what does that mean? Did you export a release build? Or did you just press the "play" button to run your code instead of the "Debug" button?
Do you have the Flex Framework linkage type set to RSL (AKA External) or Merge into Code?
Are you using an external libraries (SWC)? A framework, such as RobotLegs or Swiz, could add to the size of the SWF; but will probably not be located in the source folder.
Well, well...thought I'd revisit this since I found the problem - a font in a css file with embed set to 'true'. This font wasn't even being used, so I removed it and the css file completely (not in use either). They probably got inserted way early in the project. Code now hovering around 1 MB and less than that for the export build. Hope this helps someone. Cheers!
Flex is a collection of ActionScript classes and components, so when you build an app based on Flex, some of these classes get embedded into your application.
Something as simple as a <s:Button means that the byte code of spark.components.Button has to be included into your application along with your custom code, it's not part of the runtime.

Moving Flex MXML Application into Flash

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.

Flash Builder 4 code navigation disables for imported maven projects

has anyone encountered the following trouble with Flash Builder 4 Eclipse plugin: after I import some flash projects from poms (import -> existing maven projects) and set their type to flex library or flex project manually, flash builder code navigation stops working for these projects - you cant' click on method name to go to its definition, can't open a class using ctrl+shift+t and so forth. The projects compile and run fine and code navigation works for any projects created anew in the same workspace. Any ideas will be appreciated, thank you.
Not sure if this applies to you, but make sure all your .as files have spaces instead of tabs. Code navigation in FB doesn't like tabs.
This bug (defect or whatever you want to call it) is one of a few caused by the diminished cooperation between the vendors of the maven-eclipse-plugin and thus flexmojos-maven-plugin (indirectly) and M2Eclipse plugins (... without pointing the finger at any in particular).
You can however still get them all to work and get back the FlashBuilder/Eclipse goodness:
http://blog.darrenbishop.com/2011/02/darren-on-flex-flash-builder-4-loses.html

Can't find compiled resource bundles

I am using Adobe Flash Builder 4.
I've run into this issue with my latest project, but I was able to re-create it with an almost empty project.
Here is what I've done.
Created a new Flex Project
Created a locale/en_US folder within this project.
Added a class that extends SparkDownloadProgressBar. All this class does is attempt to create a Label.
When I try to debug this application, I get the following error.
Error: Could not find compiled resource bundle 'components' for locale 'en_US'.
at mx.resources::ResourceManagerImpl/installCompiledResourceBundle()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\resources\ResourceManagerImpl.as:340]
at mx.resources::ResourceManagerImpl/installCompiledResourceBundles()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\resources\ResourceManagerImpl.as:269]
at mx.resources::ResourceManagerImpl/processInfo()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\resources\ResourceManagerImpl.as:387]
at mx.resources::ResourceManagerImpl()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\resources\ResourceManagerImpl.as:122]
at mx.resources::ResourceManager$/getInstance()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\resources\ResourceManager.as:111]
at mx.core::UIComponent()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\core\UIComponent.as:3728]
at spark.components.supportClasses::TextBase()[E:\dev\4.0.0\frameworks\projects\spark\src\spark\components\supportClasses\TextBase.as:154]
at spark.components::Label()[E:\dev\4.0.0\frameworks\projects\spark\src\spark\components\Label.as:384]
at Preloader()[C:\SVN\Games\Social\Test\src\Preloader.as:21]
at mx.preloaders::Preloader/initialize()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\preloaders\Preloader.as:253]
at mx.managers::SystemManager/http://www.adobe.com/2006/flex/mx/internal::initialize()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\managers\SystemManager.as:1925]
at mx.managers::SystemManager/initHandler()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\managers\SystemManager.as:2419]
The Flex Compiler/Additional Compiler Arguments section does contain "-locale en_US", but I do not want to just remove this as I am planning to have this load different property files based on the localization region at run-time and how I understand it, I will need to add each locale that I am planning to use on the compile argument line.
I am at a loss as to how to attack this problem. If you need anymore information from me to help with this, I will be more than happy to provide it. Thanks ahead of time for the help!
This might be caused by the fact, that Preloader loads the actual framework, so you can't use the Flex's classes until it loads. Use standard TextField for it and it should work fine.

IDE does not treat mx:Module descendants as Modules?

I'm playing with Modules and they work as advertised: the module swf's ares
built and deployed in the output directories automatically.
My problem is that if I use descendants of mx:Module, the IDE does NOT do all
this nice work for me. I've listed the module in the Flex Modules section of the
project properties, but still nothing.
I'm going to end up repeating a lot of code in each module (to fulfill an
interface) if I cannot figure out how to make the IDE do its thing.
Any ideas?
Right click on your project, go to properties and there's a Modules sections. You can add any classes that extends Sprite.

Resources