As I understand, ActionScript is used mostly to control graphical output on Flash websites: such as Flash based games.
However, I would like ActionScript to perform tasks not related to graphical output. Tasks, which for browser compatibility reasons, are more suitable for ActionScript: such as file upload.
Is it therefore possible to use ActionScript instead of JavaScript or to accomplish tasks that are not possible with JavaScript, such as file upload?
Are the following possible?
- Run ActionScript on HTML Button Press?
- Send information to ActionScript from HTML/JavaScript?
- Process information without any graphical output in ActionScript?
- Ouptut information from ActionScript to HTML/JavasScript?
I wish to know, if ActionScript can do what I wish.
I will have a picture of the right functions to call.
ExternalInterface is your friend:
http://help.adobe.com/nl_NL/Flash/CS5/AS3LR/flash/external/ExternalInterface.html
Some tips when using ExternalInterface:
allowScriptAccessto “always” in the html embed codeSome simple examples:
1. Grab a value from javascript to flash
2. Call a function with parameters from flash
3. Call from javascript a function with parameters to Flash:
.. and
You can do lots of stuff between flash and javascript, as you can see the intergration is almost painless! The only note is that within flash ExternalInterface is not available, so you have to test in browser. You can make a transparent Flash object using
wmode="transparent". You cannot usedisplay:noneorvisibility(css) because then the flash isnt executed or acts slower. To make sure it keeps running, place itposition:fixed(css) on the page in a corner or something. Browsers make flash object run in a sort of sleep mode (slower) when out of screen or when inactive (ie in an inactive tab)