1 Reply Latest reply on Mar 19, 2008 5:36 AM by Gregory Lafrance

    Custom component to use in mxml file?

    yevgen_78 Level 1
      Hi,

      For example i want to create a new TitleWindow component.
      I create a new mxml file like this
      quote:


      <?xml version="1.0" encoding="utf-8"?>
      <mx:TitleWindow xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute" width="400" height="300">
      </mx:TitleWindow>


      and then i can to add some controls (with design editor help, for example).

      How i can create a MYTITLEWINDOW (with some additional functionality) to use it in mxml file like this.
      quote:


      <?xml version="1.0" encoding="utf-8"?>
      <abc:MYTITLEWINDOW xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute" width="400" height="300">
      </abc:MYTITLEWINDOW >


      I know how to use my component as children in mxml file
      quote:


      <?xml version="1.0" encoding="utf-8"?>
      <mx:TitleWindow xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute" width="400" height="300">
      <abc:MyButton/>
      </mx:TitleWindow>


      but how in root - no idea. :(
        • 1. Re: Custom component to use in mxml file?
          Gregory Lafrance Level 6
          ----------------------- comp\MyTitleWindow.mxml ------------
          <?xml version="1.0" encoding="utf-8"?>
          <mx:TitleWindow xmlns:mx=" http://www.adobe.com/2006/mxml"
          width="400" height="300">
          <mx:Script>
          <![CDATA[
          import mx.managers.PopUpManager;

          private function processLogin():void {
          PopUpManager.removePopUp(this);
          }
          ]]>
          </mx:Script>
          <mx:Form>
          <mx:FormItem label="User Name">
          <mx:TextInput id="username" width="100%"/>
          </mx:FormItem>
          <mx:FormItem label="Password">
          <mx:TextInput id="password"
          displayAsPassword="true"
          width="100%"/>
          </mx:FormItem>
          </mx:Form>
          <mx:HBox>
          <mx:Button click="processLogin();" label="OK"/>
          <mx:Button
          label="Cancel"
          click="PopUpManager.removePopUp(this);"/>
          </mx:HBox>
          </mx:TitleWindow>
          ------------------------ Test.mxml ----------------------------
          <?xml version="1.0"?>
          <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml">
          <mx:Script>
          <![CDATA[
          import mx.managers.PopUpManager;
          import mx.core.IFlexDisplayObject;
          import comp.MyTitleWindow;

          private function showLogin():void {
          var helpWindow:IFlexDisplayObject =
          PopUpManager.createPopUp(this, MyTitleWindow, false);
          }
          ]]>
          </mx:Script>

          <mx:VBox width="300" height="300">
          <mx:Button click="showLogin();" label="Login"/>
          </mx:VBox>
          </mx:Application>