HomeAfter Sale Support Working with Flash Advanced Skipping flash header animation on certain pages

Skipping flash header animation on certain pages


Q: How can I make a flash header play full animation on certain pages only but skip it on the rest of the pages?

A: In the HTML code of our templates you'll find one of the following two blocks of code:

The 1st one (you'll find in our earlier templates):


<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="880" height="800">
   <param name="movie" value="flash/header.swf">
   <param name="quality" value="high">
   <param name="menu" value="false">
   <embed src="flash/header.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="880" height="800"></embed>
</object>

The 2nd one:


<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="745" height="328">
   
   <param name="movie" value="flash/Header.swf">

   <param name="quality" value="flash/header.swf">

   <param name="menu" value="false">

   <param name="wmode" value="transparent">

<!--[if !IE]> <-->

<object data="flash/Header.swf" width="745" height="328" type="application/x-shockwave-flash">

   <param name="quality" value="flash/header.swf">

   <param name="menu" value="false">

   <param name="wmode" value="transparent">

   <param name="pluginurl" value="http://www.macromedia.com/go/getflashplayer">

FAIL (the browser should render some flash content, not this).

</object>

<!--> <![endif]-->

</object>

You should put a parameter into Flash with the help of one of these blocks of code. In the .FLA file there should be an Action Script code that will accept this parameter and handle it. To add parameters do the following: 
In the first case update the code in this way:


<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="880" height="800">

   <param name="movie" value=" flash/header.swf?par=skip">

   <param name="quality" value="high">

   <param name="menu" value="false">

<embed src=" flash/header.swf?par=skip" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="880" height="800"></embed>

</object>


In the second case update it in this way:


<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="745" height="328">

   <param name="movie" value="flash/Header.swf">

   <param name="quality" value=" flash/header.swf?par=skip">

   <param name="menu" value="false">

   <param name="wmode" value="transparent">

<!--[if !IE]> <-->

<object data="flash/Header.swf" width="745" height="328" type="application/x-shockwave-flash">

   <param name="quality" value=" flash/header.swf?par=skip">

   <param name="menu" value="false">

   <param name="wmode" value="transparent">

   <param name="pluginurl" value="http://www.macromedia.com/go/getflashplayer">

FAIL (the browser should render some flash content, not this).

</object>

<!--> <![endif]-->

</object>

From the ActionScript code this parameter will be available as _root.par . It means that you can use conditions like this:


if(_root.par == "skip"){

//your code here

//you usually use gotoAndStop(); or gotoAndPlay(); functions to skip a certain number of frames

}


In real situations you will usually incorporate this condition into the code for the preloader. The code for the preloader can look like this one:


onClipEvent (load)
{

   total = _root.getBytesTotal();

}

onClipEvent (enterFrame)
{

   loaded = _root.getBytesLoaded();

   percent = int(loaded/total*100);

   text = percent+"%";

   gotoAndStop(percent);

   if ((loaded == total) && (_root.par == "skip"))
   {

      _root.gotoAndStop(200); // usually the frame number where animation finishes

      } else if (loaded == total) {

         _root.gotoAndPlay(2);
      }

}



See also:

How to go back to a specific place in a movie demo movie
How to skip a flash movie demo movie
How to skip a flash movie (alternative) demo movie