Wie zu verwenden AS3-Klasse, die in MXML?

Wie würde ich das folgende AS3-Klasse in MXML?

AS3-Klasse:

package mtm 
{
  import flash.display.MovieClip;
  import flash.display.Shape;

  public class TestClass extends MovieClip
  {

      public function TestClass() 
      {
          var s:Shape = new Shape();
          s.graphics.beginFill(0x000000, 1);
          s.graphics.drawRect(0, 0, 60, 60);
          s.graphics.endFill();
          addChild(s);
      } 
  }
}

MXML-Dokument:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
        <mx:Panel width="75%" height="75%" paddingTop="10" paddingLeft="10">

    </mx:Panel>
</mx:Application>

Muss ich erklären, meine eigenen Namensraum? Ich gehe davon aus, dass es möglich ist, etwas zu tun:

//Where 'mtm' is my own namespace
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:mtm="com.mtm.*"></mx:Application>

Tun, und dann etwas wie das?

<mtm:TestClass></mtm:TestClass>

Ich bin neu in Flex und MXML, aber nicht neu in AS3.
Danke!

InformationsquelleAutor Mike Moore | 2010-06-10
Schreibe einen Kommentar