4 Replies Latest reply on Nov 21, 2012 8:03 AM by djx18

    First Actionscript Mobile project for IOS failed with TypeError: Error #1009

    jxyiliu@yahoo.ca Level 1

      Hi All,

       

      I am very very new to the actionscript mobile project for iOS. I tried to start with and build a very simple HelloWorld project. However it did not work for me. Please give any advice/hint what I was doing wrong.

       

       

      Steps I did:

       

      (1) Open Adobe Flash Builder 4.6 version

       

      (2) Click File -> New -> Actionscript Mobile Project -> Project name: Hello World and Use default SDK -> Mobile Settings:Apple iOS only -> next -> finish

       

      (3) In the HelloWorld.as, First I add a spark components Group into Sprite as my main container, and Second I create a textInput and add it to the container.

       

      The code is as following:

       

      package

      {

                import flash.display.Sprite;

                import flash.display.StageAlign;

                import flash.display.StageScaleMode;

                import flash.text.TextField;

       

                import spark.components.Group;

                import spark.components.TextInput;

       

                public class HelloWorld extends Sprite

                {

                          public function HelloWorld()

                          {

                                    super();

                                    // support autoOrients

                                    stage.align = StageAlign.TOP_LEFT;

                                    stage.scaleMode = StageScaleMode.NO_SCALE;

       

                                    // My main container

                                    var myMain:Group = new Group();

                                    this.addChild(myMain);

       

                                    // first child

                                    var textbox:TextInput = new TextInput();

                                    textbox.text = "Hello World";

                                    textbox.x = 10;

                                    textbox.y = 10;

                                    myMain.addElement(textbox);

                          }

                }

      }

       

       

      Testing Results:

       

      The script always failed at myMain.addElement(textbox); with following error mesages:

       

      TypeError: Error #1009: Cannot access a property or method of a null object reference.

                at mx.styles::StyleManager$/getStyleManager()[E:\dev\4.y\frameworks\projects\framework\src\m x\styles\StyleManager.as:139]

                at mx.styles::StyleProtoChain$/getStyleManager()[E:\dev\4.y\frameworks\projects\framework\sr c\mx\styles\StyleProtoChain.as:1016]

                at mx.styles::StyleProtoChain$/initProtoChain()[E:\dev\4.y\frameworks\projects\framework\src \mx\styles\StyleProtoChain.as:149]

                at mx.core::UIComponent/http://www.adobe.com/2006/flex/mx/internal::initProtoChain()[E:\dev\4.y\frameworks\projects\framework\src\mx\core\UIComponent.as:10926]

                at mx.core::UIComponent/regenerateStyleCache()[E:\dev\4.y\frameworks\projects\framework\src\ mx\core\UIComponent.as:10989]

                at mx.core::UIComponent/http://www.adobe.com/2006/flex/mx/internal::addingChild()[E:\dev\4.y\frameworks\projects\framework\src\mx\core\UIComponent.as:7465]

                at mx.core::UIComponent/addChildAt()[E:\dev\4.y\frameworks\projects\framework\src\mx\core\UI Component.as:7195]

                at spark.components::Group/addDisplayObjectToDisplayList()[E:\dev\4.y\frameworks\projects\sp ark\src\spark\components\Group.as:2037]

                at spark.components::Group/http://www.adobe.com/2006/flex/mx/internal::elementAdded()[E:\dev\4.y\frameworks\projects\spark\src\spark\components\Group.as:1628]

                at spark.components::Group/addElementAt()[E:\dev\4.y\frameworks\projects\spark\src\spark\com ponents\Group.as:1387]

                at spark.components::Group/addElement()[E:\dev\4.y\frameworks\projects\spark\src\spark\compo nents\Group.as:1345]

       

       

      I searched on the internet, and did not find any useful information.

       

      Please help!