Accessing Embedded Content

I’ve created a MovieClip in Flash CS3 and wrote in it’s timeline:

function testFunction():void
{
rotation = 45;
}

I have then selected to export this MovieClip as ‘TestClip’ on the first frame, with a base class of flash.display.MovieClip. I compile the SWF as ‘test.swf’, and then embed it into my ActionScript project like so:

[Embed(source='test.swf', symbol='TestClip')]
private static const TestClip:Class;

I can then instantiate the embedded object I’ve created, and add it to the display list, but I’m wondering how I can call the testFunction() that I defined in Flash CS3 from my instantiated object?

var testClip:Sprite = new TestClip();
testClip.testFunction(); //? This does not work, as testFunction is not a method of Sprite.

Is there a way of doing this that I’m missing? Thanks in advance.

I assume you’re using Flex? I don’t use Flex so I don’t know the intricacies of of Embed, but try not assigning a type to your testClip variable. The type determines what properties are available to your instance and Sprite obviously isn’t defined with a testFunction natively :wink:

Yeah untyping the variable gives me a runtime error that it cannot find property testFunction in TestClip.

I’m lost. Surely there’s a simple way of talking between ActionScript-only Flex projects and Flash CS3 symbols?

there’s
http://www.adobe.com/cfusion/exchange/index.cfm?event=extensionDetail&loc=en_us&extid=1273018

Its also included in the Flex 3 SDK

I don’t know if it works with AS projects, though.

It might be possible embedding SWFs creates a wrapper as well, similar to a Loader object. I seem to be remembering something like that (dug up from the dark depths of my vacuous mind).

Ah! found this!
http://livedocs.adobe.com/flex/3/langref/mx/core/MovieClipAsset.html
Should help

Just tried using the Flex Components command thing, to no avail. The MovieClipAsset class doesn’t help much either. I decompiled a few of my swfs to see what’s going on, and it just seems that when embedding, Flex doesn’t carry over anything but the graphics of the symbol. I might have to do this another way (with Loader probably).

Sort of sucks. Ah well. Thanks senocular. Coincidentally, you’ve been the guy that’s always helped me whenever I post here lol.