Using Flex Components in ActionScript Projects
A lot of people have had questions about whether you can use the Flex 2 Framework classes / controls (everything in mx.*) within an ActionScript 3 project without using any MXML.
You can definitely do this, and we have posted some info on the labs wiki that shows how (written by Gordon Smith).
You can view the info here.
You can download Flex Builder 2 and ActionScript from labs.macromedia.com.






This is great mike… was just aksing round about this yesterday. Thanks a lot.
JimmyH
29 Nov 05 at 1:19 pm
i can`t get it to work ;-(
Are you sure you`re talking about an AS3 only project? Does anyone can provide a full class.
Everytime i try it it compiles fine but nothing shows up.
Thanx
Benz
benjamin
29 Nov 05 at 1:33 pm
Hello,
Will the Flex 2 compiler eventually target versions 7 and/or 8 of the Flash Player?
Mike
Mike
29 Nov 05 at 2:30 pm
Thanks for the tip Mike but according to that info it seems we need a Container to be able to attach the Button on stage, like in MXML projets. Is there a way to create one then instantiate it on runtime ?
Thanks
Francis Gabon
29 Nov 05 at 2:45 pm
You could use the method explained here to see the generated actionscript file and have a bit of a look around what mxml files produce. Might help understand whats going on:
http://www.powersdk.com/ted/2005/11/flex-wizard-behind-curtain.php
Campbell
30 Nov 05 at 4:43 am
Take that back seems you cant do it in flexbuilder 2 :o(
Campbell
30 Nov 05 at 4:53 am
Aparently “-keep-generated-actionscript=true” is a compiler argument in Flex 2 but:
“Normally, you would put an argument like that in the box provided on the
Flex Compiler page of the project properties in Flex Builder. However, in
the current alpha build, Flex Builder is not passing that through properly
to the compiler. This will be fixed in a subsequent build.
For now, you can use the mxmlc command-line compiler to view the generated
ActionScript.
–
Phil Costa
Sr. Product Manager
Macromedia”
Campbell
30 Nov 05 at 5:06 am
This is my as3.0 sample.
http://blog.naver.com/ecj2000
This sample is show combinations of Marix, bitmap, realtime MP3 Spectrum.
Just Look and feel AS3.0′ powers.
cheol jin eom
2 Dec 05 at 8:22 pm
Hello,
Almost a year later what do you know, well, I cannot find any info on how to do this “Using Flex Components in ActionScript Projects” can someone please send me an email with a clear example of how I can do this because I tried a lot of things including the explanation found here which almost worked
http://www.moock.org/blog/archives/000197.html
I was able to access the mx.controls but when I tried to create a control dynamically it was not shown on the stage ? pls send me an email
Kind Regards,
thanks.
Flexer
30 Nov 06 at 9:45 pm
Hello,
Almost 2 years later what do you know ;)
I want to use a combobox and a button in a simple as3 project, possible? not possible?
thanks,
Sakri
sakri
29 Jun 07 at 3:48 am
Anyone ever figure this out?
Dave
14 Sep 07 at 5:40 am
Do anyone know, how to add MXML components like “panel, vbox etc” in pure ActionScript Flex Project?
amitpal
21 Jan 08 at 5:56 am
Hi,
I’m trying to make an AS Project in flex builder 2.01.
All is fine i can use Tween of Flex but I can’t use Datagrid.
Can you help me about that?
In my source path I’ve
${FRAMEWORKS}\source
${FRAMEWORKS}\locale\en_US // To avoid
And
${FRAMEWORKS}/libs/playerglobal.swc
${FRAMEWORKS}/libs/utilities.swc
${FRAMEWORKS}/libs/flex.swc
${FRAMEWORKS}/libs/framework.swc
THe project compile weel but When i run the project i got this error:
Error #1006: getInstance is not a function
at mx.core::Singleton$/getInstance()[C:\Program Files\Adobe\Flex Builder 2\Flex SDK 2\frameworks\source\mx\core\Singleton.as:49]
at mx.styles::CSSStyleDeclaration$cinit()
at global$init()[C:\Program Files\Adobe\Flex Builder 2\Flex SDK 2\frameworks\source\mx\styles\CSSStyleDeclaration.as:75]
at global$init()[C:\Program Files\Adobe\Flex Builder 2\Flex SDK 2\frameworks\source\mx\controls\dataGridClasses\DataGridColumn.as:151]
at content.winners::Winners$iinit()[M:\flex workspaces\lunapark\Lunapark\src\content\winners\Winners.as:32]
at Lunapark/setContent()[M:\flex workspaces\lunapark\Lunapark\src\Lunapark.as:118]
at content.header::Header/content.header:Header::navigate()[M:\flex workspaces\lunapark\Lunapark\src\content\header\Header.as:111]
Can you help me?
Best regards
Hadrien
wouitmil
27 Jan 08 at 5:13 pm
And yet another year later… I searched entire google trying to find an answer to the same question: how to use mx.controls components in Flex AS project.
It just doesn’t work for me, I keep getting a runtime error that styleManager is a bad descriptor (null aparently).. Here is the code example that breaks:
package {
import mx.controls.Button;
import mx.core.Application;
public class test2 extends Application
{
public var btn:Button;
public function test2() {
btn = new Button();
btn.label=”OK”;
addChild(btn);
}
}
}
It beaks with this runtime error:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at mx.core::UIComponent/getStyle()[E:\dev\3.0.x\frameworks\projects\framework\src\mx\core\UIComponent.as:7597]
please help :)
Thanks
Henry
Henry G
3 Jan 09 at 11:14 pm
I have not tried this, but I would say the problem is you need to create the correct hierarchy to attach the button too which I believe goes nativeWindow->application->panel->button
none
13 Jan 09 at 9:26 am
A solution can be found here:
http://ersatz.tv/2009/off-topic-flex-components-without-mxml
This code snippet gives you the basic set of Flex components for use with ActionScript only.
Herr Moose
28 Jun 09 at 2:44 pm