Wednesday, February 13th, 2008

MooTools Swiff: Communicate with Flash

Category: Flash, MooTools

MooTools core team member Michelle Steigerwalt has a writeup about the MooTools 1.2 Swiff object which allows communication between Flash movie (.swf) files and a page’s JavaScript. The Swiff object makes it substantially easier to interact with ActionScript allowing you to pass values or manipulate the Flash movie using JavaScript and MooTools:

Unless you’re a diehard fan of the embedded Quicktime movie, you might see the benefit in a Flash video player to provide smooth playback of videos to your users, while still yearning for full control over the action using JavaScript and MooTools.

It’s not even necessary for the Swiff object to be visible in order to benefit from its use. Using Swiff, you can utilize all of Flash’s functionality, including its video, sound, file streaming, and clipboard accessing features, and lots more.

You get all the flashiness of Flash, while still being able to manipulate and display your content using the DOM and MooTools.

Instantiating a Swiff object instantly provides access to the referenced Flash movie and any exposed methods:

[language]
//(JavaScript)
var obj = new Swiff(‘mySwf.swf’, {
width: 1,
height: 1,
container: $(‘swiffContainer’),
events: {
onLoad: function() {
alert(“Flash is loaded!”)
}
}
});
[/language]

In addition to this, the Swiff object’s remote() method provides the hook to make calls to actual ActionScript functions:

[language]
//(JavaScript)
var obj = new Swiff(‘mySwf.swf’, {
//[…]
events: {
onLoad: function() {
Swiff.remote(obj, ‘echoText’, ‘Hello Flash, meet Swiff.’);
}
}
});
[/language]

The Swiff object is currently available in MooTools 1.2 beta

Posted by Rey Bango at 9:18 am
7 Comments

++---
2 rating from 147 votes

7 Comments »

Comments feed TrackBack URI

Another great release from the Mootools team. Thanks for the heads up, Rey.

I’ve been using the Mootools framework on all my projects for the past 6 months, and I’m loving it.

Comment by renderblender — February 13, 2008

Same here renderblender, switched our project from Protaculous to JQuery, to Mootools and have been really happy ever since. I really appreciate how most of the cross-browser and complex action headaches are alleviated under this framework! Can’t wait to drop in some subtle user activated sound effects for some of the actions on our site!

Comment by csuwldcat — February 13, 2008

csuwldcat: Maybe you’d like to have a look at http://widgets.rabidlabs.net/sounds/v0.8/ (also done by Michelle)

Comment by zilenCe — February 13, 2008

@renderblender: my pleasure man. :)

Comment by Rey Bango — February 13, 2008

@zilenCe – Wow, that will be perfect for a section of an app me and some other guys are working on! Killer link man thanks!

@Rey Bango – Don’t know if you’ll see this Rey, but I wanted to say sorry for venting my project frustrations about this jQuery/Interface conflict thing in the Adobe AIR post the other day, it was dumb and sparked a huge argument in the rest of the posts. I have a developer that is a real pompous prick and he was the main coder on an app recently that ended up kind of crappy and I was really frustrated. It was probably more him being a know it all, and really knowing none, not an issue with jQuery. Some times I think people are scared to use anything they have to take a chance on, especially with a lot riding on it!

Have a good one!

Comment by csuwldcat — February 15, 2008

@csuwldcat — so you’re saying sorry that you said something wrong and then you go blaming someone else that it was their remarks to you that was the problem? no comment.

Comment by ibolmo — February 15, 2008

@csuwldcat: No problem man. Its water under the bridge. Enjoy MooTools Swiff :)

Comment by Rey Bango — February 15, 2008

Leave a comment

You must be logged in to post a comment.