2 Replies Latest reply on Aug 4, 2008 6:23 PM by Gregory Lafrance

    Refer application window

    from-kriftel
      Hi Everybody

      I would like to know how can I access main application window from my custom classes to <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute" width="1000" height="1000" creationComplete="loadComponents()" > to be precise

      I have a class called TplElement in which I have a function called createPhysicalElement which adds up canvas to the main application window after parsing an XML file

      public class TplElement
      {
      private var _id:int = 0;
      private var _name:String = "";
      private var _type:String = "";
      private var _properties:TplElementProperty;



      public function TplElement(id:int, name:String, propertyType:String, properties:Array)
      {
      _id = id;
      _name = name;
      _type = propertyType;
      _properties = new TplElementProperty(properties);


      }

      public function getElementProperties():TplElementProperty
      {
      return _properties;
      }

      public function createPhysicalElement():Canvas{
      var xmlCanvas:Canvas = new Canvas();
      xmlCanvas.x = int(_properties.get("left",0));
      xmlCanvas.y = int(_properties.get("top",0));
      xmlCanvas.width = int(_properties.get("width",0));
      xmlCanvas.height = int(_properties.get("height",0));
      xmlCanvas.setStyle("backgroundColor", String(_properties.get("background-color",0)));
      xmlCanvas.visible = true;
      xmlCanvas.id = String(_id);
      xmlCanvas.name = String(_name);

      addChild(xmlCanvas);
      return xmlCanvas;
      }



      }

      This somehow does not works can anyone help please
        • 1. Re: Refer application window
          Level 7

          "from-kriftel" <webforumsuser@macromedia.com> wrote in message
          news:g6n03g$jc5$1@forums.macromedia.com...
          > Hi Everybody
          >
          > I would like to know how can I access main application window from my
          > custom
          > classes to <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml"
          > layout="absolute" width="1000" height="1000"
          > creationComplete="loadComponents()" > to be precise
          >
          > I have a class called TplElement in which I have a function called
          > createPhysicalElement which adds up canvas to the main application window
          > after
          > parsing an XML file
          >
          > public class TplElement
          > {
          > private var _id:int = 0;
          > private var _name:String = "";
          > private var _type:String = "";
          > private var _properties:TplElementProperty;
          >
          >
          >
          > public function TplElement(id:int, name:String, propertyType:String,
          > properties:Array)
          > {
          > _id = id;
          > _name = name;
          > _type = propertyType;
          > _properties = new TplElementProperty(properties);
          >
          >
          > }
          >
          > public function getElementProperties():TplElementProperty
          > {
          > return _properties;
          > }
          >
          > public function createPhysicalElement():Canvas{
          > var xmlCanvas:Canvas = new Canvas();
          > xmlCanvas.x = int(_properties.get("left",0));
          > xmlCanvas.y = int(_properties.get("top",0));
          > xmlCanvas.width = int(_properties.get("width",0));
          > xmlCanvas.height = int(_properties.get("height",0));
          > xmlCanvas.setStyle("backgroundColor",
          > String(_properties.get("background-color",0)));
          > xmlCanvas.visible = true;
          > xmlCanvas.id = String(_id);
          > xmlCanvas.name = String(_name);
          >
          > addChild(xmlCanvas);
          > return xmlCanvas;
          > }
          >
          >
          >
          > }

          Sounds like you'd be better off using a repeater. But to answer your
          question, look at outerDocument.

          HTH;

          Amy


          • 2. Re: Refer application window
            Gregory Lafrance Level 6
            Or you might try

            parent.ParentVarOrMethod

            or

            Application.application.ParentVarOrMethod

            in this case don't forget to

            import mx.core.Application;