So my team is struggling with something. We have a collection of SWFs that we want to load into a Flex app built on the Swiz framework. We can load them in and get them to display, but when it comes to accessing their methods... nada. Zilch. Zip.
Now, if this was just straight-up Flash, I would simply cast the loaded SWF to the associated interface:
var swf:IMyClass = (event.target.content as IMyClass);
// test it
swf.output("Hello world!");
But here that doesn't produce anything. A bit of research turned up this:
if (swf.hasOwnProperty("output")) {
var output:Function = (swf["output"] as Function);
output("Hello world!");
}
Really? Really? A conditional and four lines of code just to call a single method? Not to mention that this defeats the whole purpose of using interfaces.
Le sigh.
Even worse, it doesn't work. Granted, that might be due to Swiz, but still...
Super frustrated. Any advice/suggestions/condemnations are welcome.
:(
// edit: also, how the hell does one format a code block now?
No idea about your question, but code blocks are 4 spaces at the start of each line (or 1 tab)
if (swf.hasOwnProperty("output")) {
var output:Function = (swf["output"] as Function);
output("Hello world!");
}
No idea about the main question, but four spaces at the start of the line gives you:
var swf:IMyClass = (event.target.content as IMyClass);
// test it
swf.output("Hello world!");
//EDIT -- pah! too slow. And double post! I really suck.