4 Replies Latest reply on Apr 9, 2009 7:03 AM by MikiNack

    Question on Variable Syntax


      I am trying to get a variable to load into my flash movie from the html page in which it is located.

      In the Object tag I am placing:
      <param name="movie" value="images/navigation.swf?Section=about" />
      In the Embed tag I am placing:

      In the first frame of the Actions layer of my movie I have:
      baseRate = 12;
      thisPage = Section;

      In the movie clip from which I am calling the variable I have:
      onClipEvent(load) {
      if (thisPage = about){
      this._alpha = 100;
      this._alpha = 0;

      The movie is recognizing that there is an conditional statement but is not passing the variable. I am assuming my syntax at least is incorrect someplace.
      Thank you.
        • 1. Re: Question on Variable Syntax
          Level 7

          At this point ...

          > <param name="movie" value="images/navigation.swf?Section=about" />

          ... you're passing in a string. The string instructs Flash to define a
          variable named Section and set its value to the (string) value "about". So
          far, so good.

          > In the movie clip from which I am calling the variable I have:
          > onClipEvent(load) {
          > if (thisPage = about){

          There are two issues here. First, you're checking to see if thisPage
          equals about -- but that word, "about", isn't in quotes, which means it
          isn't a string. But the variable you passed in is a string, so you'll need
          to wrap the word "about" in quotes. In addition to that, you'll need to use
          the equality operator (==), instead of the equals sign. In ActionScript,
          the equals sign *sets* a value to something, while the double equals sign
          *checks* if one value matches another.

          onClipEvent(load) {
          if (thisPage == "about") { ...

          See the difference?

          While you're at it, honestly ... you may as well just check for the
          original variable name you passed in, Section. It doesn't hurt anything to
          set thisPage = Section in previous code, but it doesn't help anything,
          either. You can skip the "thisPage = Section" line and simply change your
          on() code to look like this:

          onClipEvent(load) {
          if (Section == "about") { ...

          David Stiller
          Co-author, Foundation Flash CS4 for Designers
          "Luck is the residue of good design."

          • 2. Re: Question on Variable Syntax
            Level 1

            Thank you - I will give this a try.



            • 3. Re: Question on Variable Syntax
              Level 1

              Still not working.


              Here is what I have in the flash:


              onClipEvent(load) {
                  if (section == "about"){
                      this._alpha = 100;
                  this._alpha = 0;


              On the page I have:


              <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="550" height="400" id="test" align="middle">
              <param name="allowScriptAccess" value="sameDomain" />
              <param name="movie" value="test.swf?section=about" />

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

              <param name="bgcolor" value="#ffffff" />

              <embed src="test.swf?section=about" quality="high" bgcolor="#ffffff" width="550" height="400" name="test" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />


              When I publish the test - the _alpha is 0 so Flash is reading the conditional statement. But the variable "about" is not being passed at all.



              • 4. Re: Question on Variable Syntax
                Level 1

                I think I have it working now - I changed it to this:


                onClipEvent(load) {
                    if (_level0.section=="about"){
                        this._alpha = 100;
                    this._alpha = 0;


                adding the '_level0' did the trick - now I will try it in my real application!