Interaction code between flash and js: IE window highlighted when FLASH has messages

Source: Internet
Author: User
Tags setinterval

AS call JS method (example)

The code is as follows: Copy code

Code in Flash:
// Import the package
Import flash. external .*;
Get_btn.onRelease = function (){
// Call JS functions on the page
Var temp_str = String (ExternalInterface. call ("say", "Hello, World "));
Result_txt.text = temp_str;
}

Code in Html:

Function say (txt ){
Return txt;
}

JS calls the AS method

The code is as follows: Copy code
Code in FLASH: // Import package
Import flash. external .*;
// Provide the function name for JS access
Var _ method: String = "say ";
// Specify the scope of this variable in the local function. It can be set to null and left empty.
Var e_area: Object = null;
// AS internal function name
Var method: Function = say;
// Register the function to the container list
Var wasSuccessful: Boolean = ExternalInterface. addCallback (_ method, e_area, method );
// Check whether the registration is successful
If (wasSuccessful ){
Result_txt.text = "function registration successful ";
}
// Local function
Function say (txt: String ){
Result_txt.text = txt;
}
Code in Html: <div>
<Form>
<Input type = "button" onclick = "callExternalInterface ()" value = "JS call AS method"/>
</Form>
<Script>
Function callExternalInterface (){
ThisMovie ("demo"). say ("Hello, World ");
}
// The browser is compatible with DOM
Function thisMovie (movieName ){
If (navigator. appName. indexOf ("Microsoft ")! =-1 ){
Return window [movieName]
}
Else {
Return document [movieName]
}
}
</Script>
</Div>

All of the above functions are described. The following describes how to highlight the IE window when FLASH has a message.

Add code in HTML

The code is as follows: Copy code

<Script language = "JavaScript">
Function windowstiao (){
Window. focus ();
}
</Script>

Add the call function in FLASH. Pay attention to the bold section.

The code is as follows: Copy code

Import flash. external. ExternalInterface;
Function textadd (): Void {
My_text.text + = "Add a first! ";
ExternalInterface. call ("windowstiao ");
}
My_id = setInterval (textadd, 3000 );
Function clearit (): Void {
ClearInterval (my_id );
}
My_id2 = setInterval (clearit, 30000 );

Is it easy.

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.