SWFAdapter – Proxy to Communicating to Flash 8 SWFs from Flash 9

Filed under: Articles — Robert Taylor at 11:01 am on Monday, December 11, 2006

A new member to the FlashInterface family is in the works. This little guy will be called SWFAdapter. It uses ExternalInterface and the AS 3.0 Proxy class. SWFAdapter is not an upgrade or replacement to FlashInterface, rather a different means to talk to Flash 8 SWFs. By using the Proxy class, you can address the object, properties and functions as if it resided natively inside the Flash 9 player. This solution will not offer all the bells and whistles of FlashInterface, so if you are looking for a more robust solution you might consider it. For more information on the FlashInterface solution click here.

So what does the API currently look like for SWFAdapter?

var movie = new SWFAdapter(”flash/sample.swf”, new SWFLoader());
addChild(movie.content);

Scenario 1 - Inline Assignment from different objects

movie.dot.label.abc = 123;
trace(movie.dot.label.abc); // (Optional)
movie.dot.label.text = movie.dot.label.abc;

var pos:Number = movie.dot._x;
movie.dot._x = pos + 20;

Scenario 2 - Inline Assignment from same object

movie.dot.label.text = movie.dot.label.text;

Scenario 3 - Direct calls to root functions

movie.gotoAndStop(++count);
movie.hide();

Scenario 4 - Property Assignments

movie.dot._visible = false;
movie.box._x = 20;
movie.dot.label.text = “2″;
movie.dot.label._x = 100;

Scenario 5 - Complex Inline Property Assignments

movie.dot.label.text += “X”;
movie.dot.label.text = movie.dot.label.text + ” goodbye”;

Scenario 6 - Property Getters

trace(movie.dot.label.text);
trace(movie.myObject.name);

Scenario 7 - Complex Numeric Assignments

movie.dot._x += movie.dot._x;
movie.dot.label._x += 20;
movie.dot._x++;

trace(movie.dot._x)
movie.dot._x+=20;
trace(movie.dot._x);

Scenario 8 - Property Assignments from Another Movie

movie.dot._x = movie2.dot._x;

Currntly Testing
movie.x = 123;
movie2.x = movie.x;
trace(movie._x, movie2._x, movie.x, movie2.x);

If you want to play around with the files, that I am currently working on, download them here. Got input or feedback, ideas, anything, email me!

Download SWFAdapter workspace here.

No Comments »

No comments yet.

RSS feed for comments on this post.

Leave a comment

You must be logged in to post a comment.