Problems with developing rich media advertisements today use JS to control flash and find compatible solutions only at full cost on the IE Platform
The method is as follows:
The focus is on the id attribute of the object and the name attribute swliveconnect = "true" attribute of the EMBED.
Copy to ClipboardReference: [www.bkjia.com] <object classid = "clsid: d27CDB6E-AE6D-11cf-96B8-444553540000 "codebase =" "id =" myFlashMovie "width = 481 height = 86> <param name = movie value =" flips2.swf "> <embed play = false swliveconnect =" true "name = "myFlashMovie" src = "flips2.swf" quality = high bgcolor = # FFFFFF width = 481 height = 86 type = "application/x-shockwave-flash"...> </embed> </object> The following table lists the methods for obtaining flash objects using js.
Obtain the flash Object using JavaScript. It is compatible with multiple browsers.
Copy to ClipboardReference: [www.bkjia.com] function getFlashMovieObject (movieName)
{
If (window.doc ument [movieName])
{
Return response parameters Doc ument [movieName];
}
If (navigator. appName. indexOf ("Microsoft Internet") =-1)
{
If (document. embeds & document. embeds [movieName])
Return document. embeds [movieName];
}
Else // if (navigator. appName. indexOf ("Microsoft Internet ")! =-1)
{
Return document. getElementById (movieName );
}
}
You can use relevant methods to obtain flash objects.
Play: Play ()
Stop: StopPlay ()
Stop and return to the first frame: Rewind ()
Next frame: TGetProperty (nameOfTargetMovieClip, propertyIndex) and GotoFrame (frameNum)
Zoom (relative percentage)
Send data: SetVariable (variableName, variableValue)
Read data: GetVariable (variableName)
Final Demonstration:
<Style type = "text/css"> body {margin: 0px; padding: 0px; font-size: 12px;} img {border: none;} # warp {width: 960px; margin: 0px auto;} # header {height: 100px; background: #333} # content h1 {height: 22px; line-height: 22px; font-size: 12px; background: # ccc; margin: 0px; padding: 0px; padding-left: 15px; color: #333 ;}# content. demo {text-align: center; padding: 20px ;}# content. text {text-align: left; padding: 20px; backgroun D: # CCC ;}# footer {height: 30px; text-align: center ;}</style> <script type = "text/javascript"> function getFlashMovieObject (movieName) {if (window.doc ument [movieName]) {return window.doc ument [movieName];} if (navigator. appName. indexOf ("Microsoft Internet") =-1) {if (document. embeds & document. embeds [movieName]) return document. embeds [movieName];} else // if (navigator. appName. indexOf ("Microsoft Internet ")! =-1) {return document. getElementById (movieName) ;}} function StopFlashMovie () {var flashMovie = getFlashMovieObject ("Myflash"); flashMovie. stopPlay ();} function PlayFlashMovie () {var flashMovie = getFlashMovieObject ("Myflash"); flashMovie. play (); // embed. nativeProperty. anotherNativeMethod ();} function RewindFlashMovie () {var flashMovie = getFlashMovieObject ("Myflash"); flashMovie. rewind ();} function NextFrameFlashMovie () {var flashMovie = getFlashMovieObject ("Myflash"); // 4 is the index of the property for _ currentFramevar currentFrame = flashMovie. TGetProperty ("/", 4); var nextFrame = parseInt (currentFrame); if (nextFrame> = 9) nextFrame = 0; flashMovie. gotoFrame (nextFrame);} function ZoominFlashMovie () {var flashMovie = getFlashMovieObject ("Myflash"); flashMovie. zoom (90);} function ZoomoutFlashMovie () {var flashMovie = getFlashMovieObject ("Myflash"); flashMovie. zoom (110);} function SendDataToFlashMovie () {var flashMovie = getFlashMovieObject ("Myflash"); flashMovie. setVariable ("/: mytext", document. getElementById ("data "). value);} function ReceiveDataFromFlashMovie () {var flashMovie = getFlashMovieObject ("Myflash"); document. getElementById ("data "). value = flashMovie. getVariable ("/: mytext"); // document. controller. data. value = message;} </script>
Tip: the code can be modified before running!