You need to import the Button so

import mx.controls.Button

But I think your main issue is that you can't create a Sprite component and put 
mx components inside of it.  You need to use UIComponent as your base instead 
of Sprite. I believe you can go lower down the inheritance chain to FlexSprite 
(don't quote me on the name I don't have my Flex posters in front of me). But 
even if you use FlexSprite you have to implement a lot of Classes and write a 
lot of functions (override possibly) to make FlexSprite work so its just best 
to go with UIComponent.

J

--- In [email protected], "dennis" <den...@...> wrote:
>
> Hello. I am new to action script and I am (pretty) confused. so any help is
> valuable!!!
> 
>  
> 
> --- issue 1
> ----------------------------------------------------------------------------
> -
> 
> I have the follow code. and I get blank page. nothing is appeared on the
> stage at all!!! For god's sake, what is wrong?
> 
>  
> 
> package
> 
> {
> 
>   import flash.display.Sprite;
> 
>   import mx.core.ButtonAsset;
> 
>   public class ASProject2 extends Sprite
> 
>   {
> 
>     public function ASProject2()
> 
>     {
> 
>       var mb: ButtonAsset = new ButtonAsset();
> 
>         mb.x=100; mb.y=100; mb.width=200;
> 
>         addChild(mb);
> 
>     }
> 
>   }
> 
> }
> 
>  
> 
> --- issue 2
> ----------------------------------------------------------------------------
> -
> 
> Which button is the more simple button to use?
> 
> I found the spark components button is the component that Flash Builder uses
> if you write in mxml language. So I add the folder to my project's libraries
> paths, in precise I added as SWC folder the follow folder:
> 
>     c:\Program Files\Adobe\Flash Builder
> Beta\sdks\4.0.0\frameworks\projects\flex4\src\spark\components\
> 
>  
> 
> Here is the (very simple) code (with compiler's errors):
> 
>  
> 
> package
> 
> {
> 
>   import flash.display.Sprite;
> 
>   import spark.components.Button;  // <- compile time error: 1172:
> Definition spark.components:Button could not be found.
> 
>   public class ASProjectInFB4 extends Sprite
> 
>   {
> 
>     public function ASProjectInFB4()
> 
>     {
> 
>       var ab : Button = new Button();  // <- compile time error: 1046: Type
> was not found or was not a compile-time constant: Button.
> 
>         ab.x=10;
> 
>         ab.y=10;
> 
>         ab.width=200;
> 
>         ab.height=100;
> 
>         ab.enabled=true;
> 
>       addChild(ab);
> 
>     }
> 
>   }
> 
> }
> 
>  
> 
> The problem (as you see) are the two compiler errors. Now. if get the cursor
> on "Button" text in my code and I press the F3 the Flash Builder transfers
> me to the declaration of Button class in the proper Button.as file! So I
> suppose that my definition in my preceding code is correct. If I remove the
> the SWC folder from the libraries of my project, the F3 buttons doesn't
> transfer me anywhere, so the SWC folder definition is working too.
> 
>  
> 
> What is wrong?
> 
>  
> 
> Best regards
> 
> Dennis
>


Reply via email to