Ok, MXML is pretty sweet. We can make the panel tag in our HelloWorld application into a custom tag by simply creating a new file in the same directory as “HelloWorld.mxml” named “CustomPanel.mxml”:
<mx:Panel xmlns:mx=”http://www.adobe.com/2006/mxml” title=”Hello world!” width=”100%” height=”100%”/>
And let’s update “HelloWorld.mxml” to be: (Note the addition of the “xmlns=” attribute in the first line)
<mx:Application xmlns:mx=”http://www.adobe.com/2006/mxml” xmlns=”*”>
<CustomPanel/>
</mx:Application>
Compile it same as before, and it’ll spit out a “HelloWorld.swf” that works exactly like before.
So, a couple interesting things are happening here:
- You can create custom MXML tags with ease: just create a .MXML file with the name of the tag, and you’re done.
- The <?xml?> tag on the first line is optional. I’m sure people will scream at me, but in my book that means leave it out.
- The Adobe-supplied tags all start with “mx:”, whereas your custom tags don’t.
Pretty slick! Next up are namespaces, which I’ll talk about once I figure them out.