How to determine whether flash has been loaded in js?
How do we call back a js function we set when flash is loaded?
This question has troubled me for a long time. Until today, after asking a very awesome character, I suddenly felt it!
Haha, maybe, this question is not a problem in your opinion, but for me, it is indeed a problem, because I have never known how to determine whether the swf file has been loaded?
In the past, I only knew img.onload and so on.
Okay, let's get back to the point, how should we judge whether a flash has been loaded?
That's right, it's just polling and then determining whether a certain method of flash can run normally?
The example is as follows (pseudocode):
(function () { var flash = a flash object on the web page. var interval = setInterval(function () { try { if(flash.IsPlaying()) { //Populate a certain method of flash to callBack && callBack.call(flash, args); //Callback function clearInterval(interval); } } catch (ex) { } }, 1000); var callBack = function () { alert('loaded'); } })();// When using it specifically, when flash is put into the function closure of setInterval or setTimeout, it may cause flash to not call flash player functions such as IsPlaying or call result is ambiguous. Here is a temporary solution. We can read the TotalFrames property of flash in the polling function. After reading it, we can think that flash has been completely loaded into the page! ! !
After testing, it is indeed feasible, but there may be a time delay of 1-2 seconds.
///////////////////// If there is anything wrong, welcome to errata! ! ! ! ! ! ! ! ! /////////////////////////////////
/*After attached a list of js methods that can control Flash Player*/
Play() ------------------------------------------------------------------------------------------------------------------------------
StopPlay()--------------------------------------------------------------------------------------------------------------------------
IsPlaying()-------------------------------------------------------------------------------------------------------------------------
GotoFrame(frame_number)--------------------------------------------------------------------------------------------------------------------
TotalFrames() ---------------------------------------------- Get the total number of animation frames
CurrentFrame()--------------------------------------------------------------------------------------------------------------------------
Rewind() ----------------------------------------------------------------------------------------------------------------------------
SetZoomRect(left,top,right,buttom)--------------------------------------------------------------------------------------------------------------
Zoom(percent)------------------------------------------------------------------------------------------------------------------------
Pan(x_position,y_position,unit)------------------------------------------------------------------------------------------------------------------
PercentLoaded()-------------------------------------------------------------------------------------------------------------------------
LoadMovie(level_number,path)------------------------------------------------------------------------------------------------------------------
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 tag
TCurrentFrame(movie_clip)----------------------------------------------------------------------------------------------------------------
TCurrentLabel(movie_clip)-----------------------------------------------------------------------------------------------------------------
TPlay(movie_clip)---------------------------------------------------------------------------------------------------------------------
TStopPlay(movie_clip)-------------------------------------------------------------------------------------------------------------------
GetVariable(variable_name)---------------------------------------------------------------------------------------------------------------------
SetVariable(variable_name,value)-------------------------------------------------------------------------------------------------------------------
TCallFrame(movie_clip,frame_number)---call action on the specified frame
TCallLabel(movie_clip,label)----------------------------------------------------------------------------------------------------------------
TGetProperty(movie_clip,property)---------Get the specified attribute of movie_clip
TSetProperty(movie_clip,property,number)-Sets the specified attribute of movie_clip