5 Replies Latest reply on Jan 18, 2007 12:10 PM by kglad

    Variables newbie question

    Level 7
      Newbie Question:
      Is a function considered a variable?
      I have the following identical functions "function firstImage()" in two
      swfs. The 2nd swf is loaded from the 1st swf.
      How can all the variables within the 2nd function = the variable values
      within the 1st function?
      Can I replace the function in the 2nd swf something like this or am I
      totally off on this?
      function firstImage() = _parent.function firstImage();

      }
      function firstImage() {
      if (loaded == filesize) {
      picture._alpha = 0;
      picture.loadMovie(image[0], 1);
      desc_txt.htmlText = description[0];
      notes_txt.htmlText = notes[p];
      Pic1Desc_txt.htmlText = Pic1Desc[p];
      detailimage1.loadMovie(picture1[p], 1);
      picture_num();
      }
      }


      Thank you

        • 1. Re: Variables newbie question
          Level 7

          "Joe T" <mail@tese.com> wrote in message
          news:eom3se$oc8$1@forums.macromedia.com...
          > Newbie Question:
          > Is a function considered a variable?
          > I have the following identical functions "function firstImage()" in two
          > swfs. The 2nd swf is loaded from the 1st swf.
          > How can all the variables within the 2nd function = the variable values
          > within the 1st function?
          > Can I replace the function in the 2nd swf something like this or am I
          > totally off on this?
          > function firstImage() = _parent.function firstImage();
          >
          > }
          > function firstImage() {
          > if (loaded == filesize) {
          > picture._alpha = 0;
          > picture.loadMovie(image[0], 1);
          > desc_txt.htmlText = description[0];
          > notes_txt.htmlText = notes[p];
          > Pic1Desc_txt.htmlText = Pic1Desc[p];
          > detailimage1.loadMovie(picture1[p], 1);
          > picture_num();
          > }
          > }
          >
          >
          > Thank you

          There are a few things you can do here. It kind of depends on what scope
          you want the function to run under.

          For example:
          this.firstImage = mx.utils.Delegate.create(this._parent, firstImage);
          Will work, running the parent's firstImage function in the scope of this
          (meaning the child or imported swf).

          Or you can do this:
          this.firstImage = this._parent.firstImage;
          This will work too, however the scope of the function is now based on the
          _parent clip, not the loaded clip.

          HTH



          • 2. Re: Variables newbie question
            kglad Adobe Community Professional & MVP
            make the variables global by prefixing them with _global. each time they are assigned a value.
            • 3. Re: Variables newbie question
              kglad Adobe Community Professional & MVP
              and yes, you can reference a function in one movieclip from any other movieclip by using the correct path to that function.

              but the code you showed wouldn't work.
              • 4. Re: Variables newbie question
                Level 7
                Thank you for your responses.
                I made the variables global and is working fine now.



                "kglad" <webforumsuser@macromedia.com> wrote in message
                news:eom62i$qk3$1@forums.macromedia.com...
                > and yes, you can reference a function in one movieclip from any other
                > movieclip by using the correct path to that function.
                >
                > but the code you showed wouldn't work.

                • 5. Re: Variables newbie question
                  kglad Adobe Community Professional & MVP
                  you're welcome.