(reposting this from the AS3 page, sorry if you’re seeing twice, but this topic is in limbo:) )
I develop my AS3 projects in Flex Builder, which has been magic so far… but now I have a need for components.
There are two obvious paths here:
a) Use the Flash 9 component set (sounds like it works, but takes a bunch of hackwork, and its a small set really)
b) Use the Flex framework components. (I’d like to be able to use these, but am having trouble.)
Does anyone have suggestions regarding this choice?
I am currently trying to use the Flex framework, and have gone through a lot of work (and the entire internet) trying to figure it out. From what I’ve gathered, this is the way to do it:
Create a new FLEX project, with 1 mxml file:
<!-- @mxmlc -default-size 400 300 -incremental=false -->
<Main xmlns="*"/>
This file runs my Main.as file (which extends Application):
package {
import flash.display.*
import flash.text.*
import flash.events.*
import mx.core.*;
import mx.controls.*;
import mx.events.*
import mx.skins.halo.*;
public class Main extends Application
{
public function Main()
{
//initialize flex
super();
this.layout = "vertical";
this.setStyle("borderSkin",mx.skins.halo.HaloBorder);
this.addEventListener(FlexEvent.APPLICATION_COMPLETE, init);
}
private function init(eventObj:FlexEvent):void
{
trace("init()");
var clip:Sprite = new Sprite();
clip.x = 100;
clip.y = 50;
clip.graphics.beginFill(0x00aa00, .7);
clip.graphics.drawRect(0, 0, 300, 200);
addChild(clip);
}
}
}
Now I am under the impression that all of the above would work, except I get one error. addChild(clip) is not able to run because it is trying to add a sprite to the stage, and Flex will only accept Flex display objects.
Can anyone advise?