TwelvestoneFlash

Loading typed SWFs into a Flex app (aka "Really, Flex? Really?)


Sign in

  • Waiting for Godot ( 730 k posts )
    Just conversation.
  • Thunder Dome ( 23 k posts )
    Photoshop Tennis and Collabs.
  • Photography ( 5.1 k posts )
    For all you shutterbugs, sh...
  • Flash ( 18 k posts )
    ActionScripting to tweens, ...
  • Front End ( 5.9 k posts )
    general front end design an...
  • Back End ( 9.7 k posts )
    serverside scripting, progr...
  • Projects and Theory ( 12 k posts )
    This forum is for discussio...
  • FAQ ( 269 posts )
    All those nagging questions...
  • Design ( 17 k posts )
    graphics & all aspects of g...
  • Purgatory ( 3.6 k posts )
    12stone Jail, feel free to ...
baron ruhstoff
 
2011-10-10

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?

jamiec
 
2011-10-10

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!");
 }
Stickman
 
2011-10-10

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.

Sorry, you must be a member to post to a conversation. Either log in or sign up to get involved.
TwelvestoneFlash

Loading typed SWFs into a Flex app (aka "Really, Flex? Really?)