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):
02 |
var flash = 网页上某个flash对象。 |
04 |
var interval = setInterval( function () { |
06 |
if (flash.IsPlaying()) { //轮询flash的某个方法即可 |
07 |
callBack && callBack.call(flash, args); //回调函数 |
08 |
clearInterval(interval); |
15 |
var callBack = function () { |
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 specified properties for Movie_clip