This is a message.

Creating a Flash and JavaScript Plugin Created Nov 30, 2009

This thread is solved

Views: 1839     Replies: 5     Last reply Nov 30, 2009  
You must login first before you can use this feature

lemonbeti

Posts: 3

Registered:
Nov 30, 2009

Creating a Flash and JavaScript Plugin

Posted: Nov 30, 2009

I've the idea of developing a plugin that uses flash and javascript in combination. Like flash is displaying the content and handling the interaction with the user, javascript is generating the content to display.
I din't do a lot plugin developement yet, only one simple flash plugin, so i want to ask the more experienced developers, if there is any point against creating such a mix-plugin and if there is something i should think about, or pay attention to.... ???

Thanks for your help.
Cheers lemonbeti

Anssi
Flowplayer Flash & video streaming developer

Posts: 1197

Registered:
Jul 24, 2007

» Creating a Flash and JavaScript Plugin

Posted: Nov 30, 2009

Reply to: Creating a Flash and JavaScript Plugin, from lemonbeti
Sounds like a reasonable approach. It's always a good idea to have a JavaScript API in the Flash plugin so that people can control, configure and script the Flash behavior via JavaScript.

You can use the [External] annotation to expose Flash methods for JavaScript access. Nothe that you will need to compile the plugin using the Flex compiler so that this annotation gets processed by the compiler - The Flash CS IDE does not do it.

lemonbeti

Posts: 3

Registered:
Nov 30, 2009

» » Creating a Flash and JavaScript Plugin

Posted: Nov 30, 2009

Reply to: » Creating a Flash and JavaScript Plugin, from Anssi
Thanks for the quick response.

Don't know if ist makes a difference but i what to do is the following:
Click a button in Flash calls a JavaScript-function, the function changes the appearance uf the Flash-Plugin an delivers some variables....

So that users can change and configure the plugin with javascript, is not exactly what i'm thinking about. But i can imagine, that that it will work the same way and you don't see general problems.

But when I'm doining this, the user will have to add the .swf of the plugin and as well a .js, right?

cheers lemonbeti

Anssi
Flowplayer Flash & video streaming developer

Posts: 1197

Registered:
Jul 24, 2007

» » » Creating a Flash and JavaScript Plugin

Posted: Nov 30, 2009

Reply to: » » Creating a Flash and JavaScript Plugin, from lemonbeti
Yes what you describe is certainly doable. I'd make the Flash plugin to generate an event when the button is clicked. Here's ActionScript code how it would do it:


_model.dispatch(PluginEventType.PLUGIN_EVENT, "onButtonClick");

This can be handled in JavaScript like this:


plugins: {
 myPlugin: {
    url: 'flowplayer.specialplugin.swf',
    onButtonClick: function() {
       // invoke a method in my plugin passing it some random parameters
       this.doStuff('foo', 'bar', true);
    }
)
}

lemonbeti

Posts: 3

Registered:
Nov 30, 2009

» » » » Creating a Flash and JavaScript Plugin

Posted: Nov 30, 2009

Reply to: » » » Creating a Flash and JavaScript Plugin, from Anssi
Thanks for your help. sounds easy so far.
so i think i ll have to try it :)

surely i'll come back here if i get struck at some point.

Anssi
Flowplayer Flash & video streaming developer

Posts: 1197

Registered:
Jul 24, 2007

» » » » » Creating a Flash and JavaScript Plugin

Posted: Nov 30, 2009

Reply to: » » » » Creating a Flash and JavaScript Plugin, from lemonbeti
Give it a shot! I'll monitor this thread and will help you when you have more questions.