Syndicate

Feed

Flash-Javascript Communication

This article tells the story of how Flash 8 movies learnt to fluently converse with Javascript using the ExternalInterface “API” in XHTML strict.

What the hell is that ?

The ExternalInterface is an ActionScript class that was introduced in Flash 8. It allows a Flash movie to communicate with the Flash Player container using ActionScript code. The Flash Player container is in 99.9% of cases a web page, hence the Flash movie is most often calling Javascript functions, either standard built-in Javascript functions or Javascript functions defined by us, usually in an external *.js file. Using the ExternalInterface class, we’re also able to let Javascript functions invoke ActionScript functions defined in the SWF movie. These Javascript and ActionScript functions can bear arguments and return values, and there can be as many of them existing on both sides of the communication bridge. Let’s keep that in mind.

When does it not work ?

The communication will fail when :

  • The Flash player used in the browser is older than version 8. There are other means of communication that work just fine in older Flash players, that we won’t cover in this article.
  • When we’re testing locally AND the Flash parameter allowscriptaccess is not set to “always”. (An exception to this is Firefox : testing locally with allowscriptaccess set to “always” won’t work, due to security reasons. In Internet Explorer, if you allow “active content” to be run locally, then you will not run into any problem.)

What’s the 6 million dollars challenge here ?

The biggest challenge is certainly to get a handle to the XHTML element in the Document Object Model (DOM) tree that stores the Flash movie. It’s through getting that handle (a handle to an element node) that we can open communication back and fro the Flash Player and our Javascript code. Most Flash books and the Macromedia documentation presents a quick and dirty way for getting such handle, under the cover of “you don't need to understand what's going on here”, a method based on the way Flash “objects" are usually embedded in HTML, using both the object and embed tags. This article provides an alternative method that will have as repercussions that 1- we won’t be shooting in the dark, not understanding what the hell we’re doing, and also that 2- our web page will validate as strict HTML or XHTML.

Last edited by Caroline Schnapp about 10 years ago.

Comments

absolutely good.

Thanks you very considerably for this great and really beneficial short report. Absolutely everyone will get very very good knowledge from this small report.great function manage it up.

The biggest challenge is

The biggest challenge is certainly to get a handle to the XHTML element in the Document Object Model (DOM) tree that stores the Flash movie. It’s through e-papierosy getting that handle (a handle to an element node) that we can open communication back and fro the Flash Player and our Javascript code. Most Flash books and the Macromedia documentation presents a quick and dirty e-papierosy way for getting such handle, under the cover of “you don't need to understand what's going on here”, a method based on the way Flash “objects" are usually embedded in HTML, using both the object and e-papierosy embed tags. This article provides an alternative method that will have as repercussions that 1- we won’t be shooting in the dark, not understanding what the hell we’re doing, and also that 2- our web page will validate as strict HTML or XHTML.

cheap essay writing services

Most university, college and high school students have benefited from having a coach at some point in their lives, either as a member of sports team, or as a cheap essay writing services participant in an individual sport. But they may not be aware that the same principles that apply to developing athletic skills apply to writing skills as well. And that's why having an Essay Writing Coach can be of great benefit to students.

Book Tour Packages

If a vacation is on your mind, you’ve come to just the right place. WeAreHolidays is where you’ll find a whole variety of predesigned vacation packages, planned with a lot of thought and care. We have packages to international destinations as well as those within India. All you have to do is choose one that suits your requirement.

I want to know more about

I want to know more about JavaScript and this kind of post is what I've been looking for.

Jewel at Buangkok will be

Jewel at Buangkok will be accessible via Buangkok MRT Station, which is just next to it. Commuting to the city area as well as the Serangoon area is therefore very convenient. http://www.braungresham.com/2013/03/tip-2-landowners-should-claim-their-rights-under-texas-laws-that-limit-liability/

Good

Great post about Flash-Javascript. Thanks for sharing.

Nice

Awesome post with useful information. Thanks for sharing.

Ur Owesome

Your expert about this Topic..Thanks For The great Article

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <css> <html> <javascript> <mysql> <php> <span> <a> <b> <i> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <sup> <sub> <dd> <del> <blockquote> <img> <q> <p> <div>
  • Lines and paragraphs break automatically.
  • You can enable syntax highlighting of source code with the following tags: <css>, <html>, <javascript>, <mysql>, <php>, <rails>, <ruby>.

More information about formatting options

CAPTCHA
I have to wonder if you're a human spammer or a machine, or less likely someone who cares to leave his or her thoughts behind.