1 Reply Latest reply on Jul 20, 2008 8:33 AM by robdillon

    Inserting Background Random Pictures

    Level 7
      > This message is in MIME format. Since your mail reader does not understand
      this format, some or all of this message may not be legible.

      --B_3299405535_543822
      Content-type: text/plain;
      charset="ISO-8859-1"
      Content-transfer-encoding: 8bit

      Hi

      Can someone please please help me. I have a very simple Flash movie where I
      want to insert a random background image every time the movie plays or the
      web page is refreshed.

      I found the following script online but need a step by step idiot¹s guide
      how to add it to the original Flash file.

      randomClips = new Array ("background0.jpg", "background1.jpg",
      "background2.jpg", "background3.jpg");
      function randomBackground() {
      randomNumber = random (randomClips.length);
      _root.mtClip.loadMovie (randomClips[randomNumber]);
      }
      randomBackground();

      Cheers

      Sally

      --B_3299405535_543822
      Content-type: text/html;
      charset="ISO-8859-1"
      Content-transfer-encoding: quoted-printable

      <HTML>
      <HEAD>
      <TITLE>Inserting Background Random Pictures </TITLE>
      </HEAD>
      <BODY>
      <FONT FACE=3D"Verdana, Helvetica, Arial"><SPAN STYLE=3D'font-size:12.0px'>Hi<BR=
      >
      <BR>
      Can someone please please help me.  I have a very simple Flash movie w=
      here I want to insert a random background image every time the movie plays o=
      r the web page is refreshed.<BR>
      <BR>
      I found the following script online but need a step by step idiot&#8217;s g=
      uide how to add it to the original Flash file.<BR>
      <BR>
      </SPAN><SPAN STYLE=3D'font-size:11.0px'>randomClips =3D new Array (&quot;backgr=
      ound0.jpg&quot;, &quot;background1.jpg&quot;, &quot;background2.jpg&quot;, &=
      quot;background3.jpg&quot;);<BR>
      function randomBackground() {<BR>
      randomNumber =3D random (randomClips.length);<BR>
      _root.mtClip.loadMovie (randomClips[randomNumber]);<BR>
      }<BR>
      randomBackground();<BR>
      </SPAN><SPAN STYLE=3D'font-size:12.0px'><BR>
      Cheers<BR>
      <BR>
      Sally</SPAN></FONT>
      </BODY>
      </HTML>


      --B_3299405535_543822--

        • 1. Re: Inserting Background Random Pictures
          robdillon Most Valuable Participant
          You need two .jpg files in the same folder as the .swf file. Place the code that you quoted in the frame script space in the first frame of your movie, preferably in its own layer. Add a new layer at the bottom of the timeline. Create an empty movieClip. Place an intance of this clip in the first frame of that bottom layer and name the instance "mtClip".

          The code in the first frame will run when the movie starts, it will choose one of the two .jpgs to load. It will then load that file into the empty movieclip that you've placed in the bottom layer. This new image will then display as the background for your movie.

          You may need to adjust the location of the empty movieclip on the stage so that the .jpg shows up in the correct position.