Explanation: Slightly modified, mainly some primary operations; there are many similar articles, but this is very authoritative
Here are some examples of direct communication directly in Flash and HTML files using JavaScript, each example has a brief step.
This article discusses three basic Flash / JavaScript communication methods:> JavaScript to flash communication ---- JavaScript method using Flash Player> Flash to JavaScript communication ---- using Flash FSCommand> Flash to Flash communication ----------- 2 techniques using local connection objects or synthesis
Not all browsers pay great attention to scripts. In order to communicate with the flash player, the browser must have built-in hooks so that the Flash player can 'listen ". The browser must be the following:> Netscape Navigator 3.0-4.7x And Netscape 6.2 or higher (Windows 95/98 / NT / 2000 / XP or MacOS; allowed Java and LiveConnect)> Internet Explorer 3.0 or higher (only Windows 95/98 / NT / 2000 / XP; allowed ActiveX)
Note: This approach is not supported by Internet Explorer and earlier versions on Macintosh. Please check the additional information from this article.
JavaScript to Flash communication This example demonstrates how to use Flash Method to send variables from HTML's INPUT text to the flash file in this page. HTML INPUT data is transferred to the flash file via Flash's setvariable method.
View example: sample Download Source File (17K)
Steps:> Flash 1. Create a file to be saved as JavaScript_to_flash.fla 2. Create a text domain on the stage 3. Select this text field, select Dynamic Text from the Distribution List (Dynamic Text ), Fill in the variable bar "Note: The best habit is to use instance, change myvar's value with myvar.text. For simple start and compatible with Flash4 and Flash5, we use the form of variable names. 4. Save File 5. Publish HTML Files and SWF Files> Dreamweaver's next work Transfer to Dreamweaver, of course, other HTML editors 1. Open the HTML file published in the previous step 2. Insert the generated SWF file And Object / Embed tab (1) Insert> Media> Flash, and select this flash (2) to switch to code view, we need to modify the selected
Whenever the text domain changes, the onchange is triggered, and the DOPASSVAR () function is called.
4. Create a JavaScript function that delivers the variable value Copy the following JavaScript to
head> tab