0 Replies Latest reply on Oct 9, 2009 11:26 AM by LarrySpace

    2 strange issues for begginer in action script

    LarrySpace

      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?

       

      Regards