JS and Flash Interactive Flash Lianbo controller _flash as

Source: Internet
Author: User
The example of the main implementation of JS and flash interaction, operating on the premise that the browser installed Flash plugin!

Some time ago the leadership asked a question: can achieve multiple flash continuous playback?
Check the relevant information and through their own efforts, and finally realized the following a simple flash playback of the JS script.
The realization of this function is actually quite simple, mainly to understand the JS to Flash control interface function, know these, the difficulty of the problem immediately fell to the 1+1=? 's level.
Copy Code code as follows:

var flashs=[
"Http://60.210.98.23/theater/flash/2007-07/1436151_1183823655.swf",
"Http://www.flashempire.com/theater/flash/2007-08/1300680_1186654843.swf",
"Http://60.210.98.23/theater/flash/2007-05/1178503513_chinese.swf",
"Http://60.210.98.23/theater/flash/2007-07/1192848_1183734914.swf"
];

function Makeflashstr (URL) {
Return ' <object classid= ' clsid:d27cdb6e-ae6d-11cf-96b8-444553540000 "codebase=" http://download.macromedia.com/ pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0 "width=" "height=" id= "swf" >\
<param name= "bgcolor" value= "#ffffff" >\
<param name= "movie" value= "+url+" >\
<param name= "Quality" value= "High" >\
<embed src= "' +url+ '" "quality=" High "pluginspage=" Http://www.macromedia.com/go/getflashplayer "type=" Application " /x-shockwave-flash "width=" "height=" "></embed></object>";
}

var curflash=0;
var flashlen=flashs.length;
var $=function (obj) {return document.getElementById (obj)}
Determine if you need to play the next flash
function Updatemovie () {
var swf=$ ("SwF");
var swf_container=$ ("Swfcontain");
if (SWF. percentloaded () ==100) {
var totalframes;
The difference between IE and Standard browser
try{//for OPERA/FF
totalframes=swf. Totalframes ();
}catch (e) {//for IE
totalframes=swf. Totalframes;
}
var curframe=swf. Currentframe () +1;

var isplay=swf. IsPlaying ();
if (totalframes==curframe) {
Swfcontain.innerhtml=makeflashstr (Flashs[++curflash%flashlen]);
$ ("Flashlist"). Selectedindex=curflash;
}
Debugging information
$ ("Curflash"). Value=flashs[curflash%flashlen];
$ ("Totalframes"). Value=totalframes;
$ ("Curframe"). Value=curframe;
$ ("Playstatu"). Value= (isplay?) Play "+[". "," ... "," ... "][parseint (CURFRAME/10)%3]:" Stop ");
}else{
Debugging information
$ ("Curflash"). Value=flashs[curflash%flashlen];
$ ("Totalframes"). Value= "Loading Flash";
$ ("Curframe"). Value= "Loading Flash";
$ ("Playstatu"). Value= "Loading Flash";
}
SetTimeout ("Updatemovie ()", 100);
}
Manually specify the Flash to play
function Setmovie (index) {
Curflash=index;
$ ("Swfcontain"). Innerhtml=makeflashstr (Flashs[index]);
}
Window.onload=function () {
var sel=$ ("Flashlist");
Initialize and generate a list of flash
for (Var i=0;i<flashlen;i++) {
$ ("Flashlist"). Add (New Option (flashs[i],i));
}
Setmovie (0); Play the first flash
Cycle Detect and update flash
SetTimeout ("Updatemovie ()", 10);
}

In addition to the operation of JS and Flash interface functions, on the one hand, on the other hand, I hope the program is interested in friends can help.

--------------------------------------------------------------------------------

List of JavaScript 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.