Actionscript – Adding button in Actionscript code : Using Flex Builder

actionscriptapache-flexflexbuilder

I created a new actionscript project using Flex Builder 3 and tried

to run the following file. I get this error :

Definitions: fl.controls:Button could not be found.
All I want to do is, to add a button to the application.
How could I do it?

package  {
        import PaperBase;
        import org.papervision3d.objects.primitives.Cone;
        import fl.controls.Button;
        import fl.controls.Label;
        import fl.events.ComponentEvent;

        public class cone1 extends PaperBase {
            public var cone:Cone = new Cone();
            protected var sceneWidth:Number;
            protected var sceneHeight:Number;
            public function cone1() {
                sceneWidth = stage.stageWidth
                sceneHeight = stage.stageHeight;
                init(sceneWidth*0.5,sceneHeight*0.5);//position of the cone
            }
            override protected function init3d():void {
                cone.scale = 5;
                cone.pitch(-40)
                default_scene.addChild(cone);
            }
            override protected function processFrame():void {
                cone.yaw(1);//rotation speed
            }
        }
    }

Best Answer

The fl.* package is part of Flash Professional, not Flex. For Flex you should be using the components that are part of the mx.* package.

Now, that being said, I'm fairly sure it is possible to use Flash components in Flex. I'm just not sure how it's done off the top of my head.

Also, you don't need an actual button component to get a "button like" ui element - any class that extends InteractiveObject will do. This incldes Sprite and MovieClip.

Related Topic