Add up Flash (8)

Source: Internet
Author: User

Add up Flash (8)-ActionScript 3.0 Web page acquisition parameters, JavaScript and ActionScript call each other

Introduced

Demonstrates using Flash ActionScript 3.0 to get configuration parameters, page parameters, and the interaction between JS and as

Parameter fetch-Gets the configuration parameter (flashvars) via Application.application.stage.loaderinfo.parameters[param, and gets the URL parameter via JavaScript

Interacting with JavaScript-using Externalinterface to make calls between ActionScript and JavaScript

Flash End

Main.as

/**//* * Note: * 1, if you need Flash and JavaScript interaction, then the HTML tag containing the SWF file must have ID * 2, such as Cross-domain call, you need to set the relevant plug-in parameters, such as <param name= "all
 Owscriptaccess "value =" Always "/> * 3, Flash end related security class configuration: Similar to Flash.system.Security.allowDomain (" * ");
    * * Package {import Flash.display.MovieClip;
    Import Flash.external.ExternalInterface;
            public class Main extends MovieClip {public Function main (): void {Loadvarsdemo ();
            Ascalljs ();
        Jscallas ();  

//Get the parameters for the page-side configuration//The following example is used to read the following configuration on the page side//<param name= "Flashvars" value= "name=webabcd&age=29" />//<param name= "movie" value= "demo.swf?dateofbirth=1980-02-14"/> Private Function Loadva
                Rsdemo (): void {lblvars.text = "name:" + stage.loaderinfo.parameters["name"] + "" + "Age:" + stage.loaderinfo.parameters["" "+" "+" Birthday: "+ Stage.loaderinfo. parameters ["dateOfBirth"];
        Lblswfurl.text = Stage.loaderInfo.url;  }//ActionScript invokes JavaScript private function Ascalljs (): void {//Invoke specified JavaScript
        The function of the end, and sequentially specifies the parameters passed to the JavaScript End Function Externalinterface.call ("Jsmethod", "param1", "param2");
            }//JavaScript called ActionScript, ActionScript-side functions Private Function Jscallas (): void {
        Registers a function that needs to be called by JavaScript Externalinterface.addcallback ("Asmethod", output);  Public function output (p1:string, p2:string): void {lblresult.text = "parameter 1:" + p1 + "Parameter 2:" + P2}}}

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.