PDA

View Full Version : CSS Commands From Flash?



mrwizzer
March 26th, 2008, 04:38 PM
I'm working with a developer who has set up a simple scheme where the video on a page moves itself to the center of the page upon a click of a button. The button needs to be in Flash.

Question is: how do you call a CSS command (which I know nothing about) from inside Flash?

We need two flash buttons to call the following commands:

onclick="document.getElementById('contentBox').style.displa y='block'"
onclick="document.getElementById('contentBox').style.displa y='none'"

Suggestions would be very much appreciated!

Ordinathorreur
March 26th, 2008, 05:09 PM
To call JavaScript from Flash you will need to take a look at the ExternalInterface class ( http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/external/ExternalInterface.html )

There's also a nice guide here: http://www.adobe.com/devnet/flash/articles/external_interface_02.html

Important note: There are some flash player security changes in April which may impact your JavaScript calls so you may want to keep this in mind when choosing the best solution for you: http://www.adobe.com/devnet/flashplayer/articles/flash_player9_security_update.html

mrwizzer
March 27th, 2008, 02:44 PM
Thanks, and that does look like it might be a simple way to approach it, but alas, I don't know the first thing about Javascript.

Do I need to put the

Show Text -- onclick="document.getElementById('contentBox').style.displa y='block'"

code in the html document, or in the Flash actionscript?

If anyone who's familiar with this could help me with an example code, I'd be very grateful.