JS how to determine whether the Flash SWF file loaded _javascript tips

Source: Internet
Author: User
Tags setinterval

JS how to determine if Flash is finished loading it?

How do we recall a JS function we set when the Flash is loaded?

This question, has been bothering me for a long time, until today, consulted a very cow B character, suddenly came to feel!

Oh, maybe, this problem is not a problem to you, but for me, it is a problem, because I always do not know how to determine whether the SWF file is finished loading?

It used to be all about img.onload and so on.

Well, in the end, how can we tell if a flash is finished loading?

Yes, polling, and then determine if a Flash method is working correctly?

Examples are as follows (pseudo code):

(function () { 
var flash = A Flash object on a Web page. 

var interval = setinterval (function () { 
try { 
if (Flash). IsPlaying ()) {//a method to poll flash 
callBack && callback.call (Flash, args);//callback function 
Clearinterval ( interval); 
} 
catch (ex) { 

} 
}, 1000); 

var callBack = function () { 
alert (' Loaded '); 
} 
}) ();

In particular, when Flash is put into a setinterval or settimeout function closure, flash can be caused by JavaScript single-threaded problems that could not be invoked on flash, such as isplaying Player function or the result of the call is not the case, there is a temporary solution, we can read in the polling function to read the Totalframes properties of the flash, read to get, we can think that the flash has been fully loaded into the page!!!

Tested, it works, but there may be a 1-2-second delay.

There's something wrong, welcome to Errata!!!!!!!!! //////////////

/* The following is a list of JS methods to control Flash Player * *

Play ()----------------------------------------animation
Stopplay ()------------------------------------stop animation
IsPlaying ()-----------------------------------whether the animation is playing
Gotoframe (frame_number)----------------jump to a frame
Totalframes ()-------------------------------get the total number of frames for the animation
Currentframe ()------------------------------return the number of frames in the current animation-1
Rewind ()-------------------------------------causes the animation to return to the first frame
Setzoomrect (Left,top,right,buttom)-------enlarge the specified range
Zoom (percent)------------------------------change animation size
Pan (x_position,y_position,unit)------------to translate the animation in the x,y direction
percentloaded ()----------------------------returns the percentage of animation being loaded
Loadmovie (Level_number,path)-----------load animation
Tgotoframe (movie_clip,frame_number)-Movie_clip jumps to the specified number of frames
Tgotolabel (movie_clip,label_name)------Movie_clip jumps to the specified label
Tcurrentframe (movie_clip)---------------postback Movie_clip Current frame-1
Tcurrentlabel (movie_clip)-----------------postback movie_clip current label
Tplay (Movie_clip)---------------------------play Movie_clip
Tstopplay (movie_clip)----------------------stop movie_clip Playback
GetVariable (variable_name)-----------------Get variables
SetVariable (variable_name,value)-----------variable assignment
Tcallframe (movie_clip,frame_number)---Call specifies the action on the frame
Tcalllabel (Movie_clip,label)----------------call specifies the action on the label
Tgetproperty (Movie_clip,property)--------get the specified properties of Movie_clip
Tsetproperty (Movie_clip,property,number)-Set the specified properties of Movie_clip

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.