R – using alchethe generated swc in Flash CS4

actionscript-3alchemyflash

I've gone over the Alchemy quick start guide and exported my stringecho.swc successfully, but I don't want to compile in Flex. I just don't know Flex and I'm not very keen on learning it all of a sudden. I tried to do my business in Flash, instead, considering that they both run on AS3. The Flex code they give as an example is

package
{
    import flash.display.Sprite;
    import cmodule.stringecho.CLibInit;

    public class EchoTest extends Sprite
    {
        public function EchoTest()
        {
            var loader:CLibInit = new CLibInit;
            var lib:Object = loader.init();
            trace(lib.echo("foo"));
        }
    }
}

I've added my swc in the Flash CS4 options and thought I could convert the Flex code into the following AS3 Flash code, written in the timeline:

import cmodule.stringecho.CLibInit;

var loader:CLibInit = new CLibInit;
var lib:Object = loader.init();
trace(lib.echo("foo"));

But, alas, I get the following error at runtime: ReferenceError: Error #1065: Variable MainTimeline is not defined.

I've not enough experience with Flex, but quite a lot with Flash, but that error tells me nothing at all. I haven't heard of any properties of the stage object or whatever called MainTimeline. Could someone tell me why I get the error or why what I'm doing is just plain stupid?

Best Answer

Never mind, I made it work. Under Profile->Edit->SWF Settings, I checked "Export SWC". Not sure why it works, maybe someone could still give me a logical explanation...

Related Topic