3 Replies Latest reply on Nov 30, 2008 7:28 AM by clbeech

    2nd Post: What is the best Way to Do This?

    Level 7
      Dear All,

      What is the best way to attach a secondary swf to movie in the main swf and
      pass back values to main swf? Is it to use setvariable or another method?

      Thanks again.

      Alastair MacFarlane

        • 1. Re: 2nd Post: What is the best Way to Do This?
          clbeech Level 3
          a good way to load an external file using AS2 is to use the MovieClipLoader class. if the values are constants in the loaded file, then you could also use the onLoadInit handler to trasfer the values. if the loaded file generates values at a different time or by calling a method, then you can either target the corresponding variables on the main timeline by using _root or _parent, or you can call to a method in the loaded file that uses a 'return'.

          if the values are constant in the loaded file a basic code block would look something like this:
          • 2. Re: 2nd Post: What is the best Way to Do This?
            Level 7
            clbeech,

            Thanks for the reply. I am not that familiar with classes in Flash. I will
            read up on it. Thanks for the pointer and sample code.

            Alastair


            "clbeech" <webforumsuser@macromedia.com> wrote in message
            news:ggsl2d$2lh$1@forums.macromedia.com...
            >a good way to load an external file using AS2 is to use the MovieClipLoader
            > class. if the values are constants in the loaded file, then you could
            > also use
            > the onLoadInit handler to trasfer the values. if the loaded file
            > generates
            > values at a different time or by calling a method, then you can either
            > target
            > the corresponding variables on the main timeline by using _root or
            > _parent, or
            > you can call to a method in the loaded file that uses a 'return'.
            >
            > if the values are constant in the loaded file a basic code block would
            > look
            > something like this:
            >
            >
            > var valueA:Number;
            > var valueB:String;
            > ... etc
            >
            > var mcl = new MovieClipLoader();
            > var lstn = new Object();
            > mcl.addListener(lstn);
            >
            > mcl.onLoadInit = function(clip) {
            > valueA = clip.valueA;
            > valueB = clip.valueB;
            > ... etc
            > }
            >
            > mcl.loadClip('thefile.swf', mc); //mc is the 'target' instance
            >

            • 3. Re: 2nd Post: What is the best Way to Do This?
              clbeech Level 3
              you're welcome - on reviewing this post i also just noticed an error in my code above, the line:

              mcl.onLoadInit ...

              should be:

              lstn.onLoadInit ...