views:

2235

answers:

4

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
         }
        }
    }
+3  A: 

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.

Branden Hall
A: 

Branden is correct the fl package is a part of the Flash IDE..I am not sure either but you may be able to add the package to your class path if you know where the package resides on your file system..i am guessing somewhere in C:/program files/adobe/flash

if you want to use components in flex builder I think you need make a flex project not an actionscript project

and change your imports to:

import mx.controls.Button;
import mx.controls.Label;
import mx.events.FlexEvent;

Also if you do not need to use components either you can use a Sprite for a button like branden said and you could just use a TextField for a label.

another option if you have the flash IDE is to make a SimpleButton, press F8 select button, click enter. then give it a linkage name by right clickin it in the library panel and selecting linkage name. then export the .swf and put the swf in the src folder for your project and embed it like this:

[Embed(source="flashfile.swf")]
public var myButton:Class;

You may even be able to export the Flash IDE components this way but not sure...actually I am not 100% positive if the [Embed] meta data works in an actionscript project or just flex projects so you will have to check and see.

John Isaacks
A: 

Not sure why you would want to, but if you need to import the flash libs into flex,try dragging what you want to the stage in flash and exporting as a .swc file to import into your flex project.

philip
A: 

It depends what version of the IDE you have, for CS4 and Mac the location would be /Applications/Adobe Flash CS4/Common/First Run/Classes

Add that folder or the relevant folder for your installation/OS to your classpath in flashbuilder/eclipse and it will interpret the class calls fine.

It makes sense if you're coding pure actionscript and dont want to use flex components, or employing a mixed coding and designing in IDE approach.

@philip the embed tag cannot be used in pure actionscript

Franz