PDA

View Full Version : mxmlc question



Rezmason
October 10th, 2007, 03:40 AM
Hi there.

The free as in beer Flex 2 SDK contains a compiler called mxmlc. That's big news- or was, rather, back when it came out. Think about it. You can make SWFs without pulling out your wallet, if you're willing to sacrifice the content development tools in the Flash/Flex authoring environment. I like that.

But I expect that I can't just drag and drop my ActionScript class files onto mxmlc. Sure, there're those meta tags to worry about, but I'm not talking about them. At some point, mxmlc has to latch onto an mxml file, right? And I don't want to bother with too much mxml; if I wanted to design interface forms, I'd program in VB for crying out loud.

Here's what I'd like– and if it's not out there, I'll make it myself: a simple system that I can hook my classes onto, like the document class in Flash, that lets me use the flash and flex frameworks. The fl library would be nice too, but that's not of primary interest. What's important is, a tiny mxml file with just enough data to say, "Hi, I'm app XYZ, I was made by ABC, now here's the ActionScript". That'd take a load off my back. :)

Has anyone else looked into this?

Krilnon
October 10th, 2007, 12:14 PM
If your main class isn't one that Flex will accept (as in, it doesn't implement IUIComponent and is a regular DisplayObject of some sort), then you could use something like this:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="addFlashContent();">
<mx:Script>
<![CDATA[
import path.path.path.RandomFlashClass;
private function addFlashContent():void {
rawChildren.addChild(new RandomFlashClass());
}
]]>
</mx:Script>
</mx:Application>

Otherwise, with an application built with a main class that extends some Flex class, the MXML file could look like this:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" xmlns:app="my.app.path.*">
<app:MyApp />
</mx:Application>

Also, there may be some way to do this without having to use an MXML file; I'm not sure. Flex Builder allows you to build AS-only projects without forcing you to supply it with an MXML file, so either mxmlc doesn't receive an MXML file, Flex Builder generates one, or mxmlc isn't used. The last option is pretty unlikely, though.

Rezmason
October 10th, 2007, 01:53 PM
Also, there may be some way to do this without having to use an MXML file; I'm not sure. Flex Builder allows you to build AS-only projects without forcing you to supply it with an MXML file, so either mxmlc doesn't receive an MXML file, Flex Builder generates one, or mxmlc isn't used. The last option is pretty unlikely, though.

Interesting! If Flex is structured the same way as Flash, maybe I can also find an mxml file in the Flex directory that is used during this sort of compilation. In the meantime, I'll try using your examples. Thanks very much. :)

Rezmason
October 10th, 2007, 02:21 PM
Oh, hey. Guess who has a nice article about using mxmlc, without any mxml? Senocular! You can read it here. (http://www.senocular.com/flash/tutorials/as3withmxmlc/)

So it looks like all I'll need to do to get my programs to work is to use meta tags and such.