How does js determine whether the Flash SWF file has been loaded? _ javascript skills

Source: Internet
Author: User
Because I have never known how to determine whether the swf file has been loaded, so I want to use js to implement this function. If I need a friend, I can refer to js to determine whether flash has been loaded?

How can we call back a set js function when flash is loaded?

This problem has been bothering me for a long time. Until today, after consulting a very good character, I suddenly felt like this!

Well, maybe this is not a problem for you, but it is indeed a problem for me, because I have never known how to determine whether the swf file has been loaded?

I used to only know img. onload and so on.

Well, let's get down to the point. How can we determine whether a flash is loaded?

Yes, it is round-robin, and then judge whether a method of flash can run normally?

Example ):

(Function () {var flash = a flash object on the webpage. Var interval = setInterval (function () {try {if (flash. isPlaying () {// polling a method of flash to call back & callBack. call (flash, args); // callBack function clearInterval (interval) ;}} catch (ex) {}, 1000); var callBack = function () {alert ('loaded ');}})();

// When flash is put into the closure of setInterval or setTimeout functions, flash may not be able to call flash player functions such as IsPlaying or call results are incorrect due to a JavaScript single thread problem, there is a temporary solution here. We can read the TotalFrames attribute of flash in the polling function and read it. Then we can think that flash has been fully loaded into the page !!!

Tested, it is feasible, but there may be a delay of 1-2 seconds.

/////////// What is wrong. You are welcome to make a mistake !!!!!!!!! //////////////

/* The following is a list of js methods that can control Flash Player */

Play () ---------------------------------------- Play an animation
StopPlay () ------------------------------------ stop an animation
IsPlaying () ----------------------------------- whether the animation is playing
GotoFrame (frame_number) -------------- jump to a frame
TotalFrames () ------------------------------- get the total number of animation Frames
CurrentFrame () ------------------------------ return the number of frames of the current animation-1
Rewind () ------------------------------------- returns the first frame of the animation.
SetZoomRect (left, top, right, buttom) ------- enlarge the specified area
Zoom (percent) ------------------------------ change the animation size
Pan (x_position, y_position, unit) ------------ move an animation in the x and y directions
PercentLoaded () ---------------------------- return the percentage of animation loaded
LoadMovie (level_number, path) ----------- load an animation
TGotoFrame (movie_clip, frame_number)-movie_clip jump to the specified number of frames
TGotoLabel (movie_clip, label_name) ------ jump to the specified tag
TCurrentFrame (movie_clip) --------------- return movie_clip current frame-1
TCurrentLabel (movie_clip) ----------------- return the current movie_clip label
TPlay (movie_clip) ------------------------- play movie_clip
TStopPlay (movie_clip) -------------------- stop playing movie_clip
GetVariable (variable_name) ----------------- get the variable
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 attribute of movie_clip
TSetProperty (movie_clip, property, number)-set the specified attribute of movie_clip

Related Article

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.