2 Replies Latest reply on Mar 3, 2009 7:14 AM by Newsgroup_User

    mxml vs as3

    SiHoop Level 1
      I'm trying to understand containers. The following code shows two ways to use a UIComponent. If I remove the mxml UIComponent and uncomment the as3 UIComponent, the class fails to load properly. Is this because I'm using creationComplete?

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="init()">
      <mx:Script>
      <![CDATA[
      import MyImport
      import mx.core.UIComponent
      //private var mapContainer:UIComponent
      private var myImp:MyImport=new MyImport()
      private function init():void{
      //mapContainer=new UIComponent()
      mapContainer.addChild(myImp)
      }
      ]]>
      </mx:Script>
      <mx:UIComponent id="mapContainer" />
      </mx:Application>
        • 1. Re: mxml vs as3
          VarioPegged Level 2
          quote:

          If I remove the mxml UIComponent and uncomment the as3 UIComponent, the class fails to load properly. Is this because I'm using creationComplete?

          No. It's because you don't add mapContainer as a child of the application in your AS code. With your MXML version, mapContainer is added as a child automatically.

          So, in your AS3 version add the line:
          addChild(mapContainer);

          TS
          • 2. Re: mxml vs as3
            Level 7

            "VarioPegged" <webforumsuser@macromedia.com> wrote in message
            news:goiems$ji2$1@forums.macromedia.com...
            >
            quote:

            If I remove the mxml UIComponent and uncomment the as3 UIComponent, the
            > class fails to load properly. Is this because I'm using
            > creationComplete?

            > No. It's because you don't add mapContainer as a child of the application
            > in
            > your AS code. With your MXML version, mapContainer is added as a child
            > automatically.
            >
            > So, in your AS3 version add the line:
            > addChild(mapContainer);

            Additionally, set a break point at the end of your init function and look at
            the width and height properties of mapContainer.

            HTH;

            Amy