Communication between javascript and Flash _ Javascript tutorial

Source: Internet
Author: User
Javascript: Communication Between javascript and Flash, Javascript tutorial Description: slightly modified, mainly for some very preliminary operations; and many similar articles, but this is very authoritative

Below are some examples of direct communication between Flash and HTML files using javascript. Each example has a simple step.

This article discusses three basic Flash/javascript communication methods:
> Javascript-to-Flash Communication-use the javascript method of Flash Player
> Communication between Flash and javascript-use the Flash fscommand
> Flash-to-Flash Communication --------- use local connection objects or a combination of the two technologies

Not all browsers attach great importance to scripts. To communicate with Flash players, the browser must have built-in hooks so that flash players can 'snoop '. The browser must be of the following types:
> Netscape Navigator 3.0-4.7x, and Netscape 6.2 or higher
(Windows 95/98/NT/2000/XP or MacOS; Java and LiveConnect are allowed)
> Internet Explorer 3.0 or higher
(Windows 95/98/NT/2000/XP only; ActiveX allowed)

Note: Internet Explorer on Macintosh and Netscape6 of earlier versions do not support this method. Please refer to the additional information in this article.


Communication between javascript and Flash
This example demonstrates how to use the Flash method to send the variable from the HTML input text to the Flash file on the page. The HTML input data is transmitted to the Flash file through the Flash SetVariable method.

Steps:
> Flash in progress
1. Create a new file and save it as javascript_to_flash.fla
2. Use a text tool to create a text field on the stage
3. Select this Text field. On the property panel, select Dynamic Text from the drop-down list and fill in "myVar" in the variable column"
Note: The best practice is to use Instance and use myVar. text to change the value of myVar. For simplicity and compatibility with Flash4 and Flash5, we use the form of variable names.
4. Save the file
5. Publish HTML and SWF files


 

Steps:
> Flash in progress
1. Create a new file and save it as javascript_to_flash.fla
2. Use a text tool to create a text field on the stage
3. Select this Text field. On the property panel, select Dynamic Text from the drop-down list and fill in "myVar" in the variable column"
Note: The best practice is to use Instance and use myVar. text to change the value of myVar. For simplicity and compatibility with Flash4 and Flash5, we use the form of variable names.
4. Save the file
5. Publish HTML and SWF files


> Dreamweaver
The next step is to move to Dreamweaver. Of course, it can also be another HTML editor.
1. Open the HTML file released in the previous step.
2. Insert the generated SWF file and OBJECT/EMBED tag
(1) Insert> Media> Flash and select the Flash
(2) to switch to the Code view, we need to modify the selectedAndTag
(3) Insert id = "myFlash" in the object tag"
  Width = 366 height = 142 id = "myFlash">

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.