Calling Flex from Authorware

english mobile

So I finally had my datagrid calling my ASP page, which squirted out XML. I embedded my Flex swf and could not for the life of me figure out how to call the functionality from Authorware. I did a lot of Googling and banging my head up against a wall, and here is what I came up with:

CallSprite(@"Flash", #CallString, "CallFunction('<invoke
name=\"myFlexFunction\" returntype=\"void\"><arguments><string>hello
world</string></arguments></invoke>')")


If you're not familiar with Authorware, it has two methods for embedding swf files. One is a sort of proprietary method called the Flash Asset Xtra. It actually contains the Flash player so the user does not need to have the player installed. Problem is, it only goes up to Flash 6. So this Flash Sprite is the other type, the Flash 9 ActiveX control embedded in Authorware. #CallString is a method of the CallSprite function that allows you to get access to all methods of a given sprite, even ones that aren't exposed in the way Authorware recognizes. All of this is a long hand way of saying if you're not using Authorware, you'd probably use the CallFunction function some other way.

However, the important part is the XML string, which the Flex documentation doesn't, well, document. I haven't found anything but examples, but I'll give it a stab from my surmises which have borne out through trial and error so far.

<invoke>-root level tag. It has a name property that tells Flex what to invoke (i.e. the name of your function). Those backslashes you see there in my code are to tell Authorware those are literal quotes that should be passed on through to the function. Also has a returntype property, which, presumably, is the return type you expect. Probably this can be any valid return type a function could have from Flex.
<arguments>-nested within invoke, this is a container for all the arguments your function is expecting. Each argument should, again presumably, be wrapped in a tag that tells Flex what type of argument it is. IMO a cleaner implementation would be <argument type="string>foo</argument> but then I'm just a random spong so I don't control these things.

If there's anything else that you could put in here I haven't found it.

Note that I am really curious as to whether a function that returned a value would return it back to Authorware and what form that would take, but not quite curious enough to try it until I need to.

0 comments: