Issue 1: It looks like you want to create a Flex button. If so, you want 
mx.controls.Button, not mx.core.ButtonAsset. But you can't take a Flex Button 
and have it work inside a plain old Sprite, which is what a pure 
ActionScript-based app is. Flex is an application framework, and Flex controls 
expect to be inside of Flex containers. So you have to start by creating, in 
MXML, an <mx:Application> or an <s:Application>. Once you have that, you can do 
everything else in AS rather than MXML if you really don't like MXML. But it's 
a lot easier to just write <mx:Button>.

Issue 2: Again, it looks like your problem is that you're expecting Flex 
controls to work inside of pure ActionScript apps.

Gordon Smith
Adobe Flex SDK Team

From: [email protected] [mailto:[email protected]] On Behalf 
Of dennis
Sent: Friday, October 09, 2009 12:09 PM
To: [email protected]
Subject: [flexcoders] 2 strange issues for begginer in action script ref


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