How about using a FLEX 3 component inside a Flash file?

Can Flex 3 component / code be used inside a Flash SWF file (cs4)?

I know this is possible in the opposite direction.

+1


source to share


4 answers


With my minimal testing, it seems that you cannot use Flex components when creating a "pure AS3" project. (Can I call it PAS3 or something like "passé". Or "pastry" ". :)

I did this admittedly limited testing by creating a test project with one AS class as a "document class" that would instantiate and add one instance of mx.controls.Button. I copied the entire mx package from the path given by hasseg to the original project path.



Here's what I learned:

  • By removing the use of mx_internal from a specific Version.as file, I got the Flash IDE to compile my test project without warning. However, nothing appeared on the stage.
  • With Flex Builder (and the Flex compiler), obviously I also managed to compile the project without errors. I put breakpoints in the code and watched as it is built into the debugger. The components were created flawlessly, but nothing appeared on the scene. This swf also damaged the browser several times.
+1


source


I myself have not used Flex code in the "pure AS3" project, but I do not understand why you could not do this.



You can download the Flex SDK and get Flex components from it, both in file swc

(c /frameworks/libs

) and as AS3 source code (under /frameworks/projects/framework/src

).

+1


source


+1


source


In general, you need to use MXML to initialize a Flex frame and use Flex components.

Mike Chambers of Adobe says:

There is no support for using Flex Framework in an AS only project. While this is theoretically possible, you will have to manually load a lot of application initialization code that Flex handles (something that would be quite complicated). - Source

To find out how complex, you can tell the compiler to save the AS3 intermediate files it generates from MXML. Open the properties of the AS3 project and set -keep-generated-actionscript

as an argument to the compiler. Compile your project, then look in the shared folder. Using Flex 4 I end up with 13 small files, the main one extending spark.components.Application

and overriding several methods.

So it's possible, but you probably don't want to. Flex is designed to make your life easier, not harder.

0


source







All Articles