3 Replies Latest reply on Apr 9, 2007 5:42 AM by

    controlling one ad from another

      I found this sample code in the docs, but I don't know how to change it so that I can control the timeline in one movie from another. Basically, I want to make a nav (buttons) in one flash movie that control events in the other flash movie like loadMovie, gotoAndPlay("frame2"), etc...

      //create the LocalConnection by first
      //setting it equal to a variable
      incoming_lc = new LocalConnection();
      //define the function that will execute when a connection is made
      incoming_lc.methodToExecute = function (param) {
      //set the contents of the text field
      //equal to the parameter received from the sending movie
      sentMessage.text = param;
      }
      //make the connection
      incoming_lc.connect("lc_name");


      //assign a function to the button's event method
      buttonInstance.onRelease = function() {
      //create the LocalConnection by first
      //setting it equal to a variable
      outgoing_lc = new LocalConnection();
      //send the contents of the text field
      //using the send() method
      outgoing_lc.send("lc_name", "methodToExecute", userMessage.text);
      //delete the local connection now that the
      //message has been sent
      delete outgoing_lc;
      };


      I found these incoming and outgoing sample fla's. Can someone please help me figure out how to create a button in one movie that controls an "action" like navigating the time line in a second movie instead of just passing some text from one movie to another...I NEED TO FIGURE THIS OUT ASAP! Any help is greatly appreciated!!!

      would it just be:

      //assign a function to the button's event method
      buttonInstance.onRelease = function() {
      //create the LocalConnection by first
      //setting it equal to a variable
      outgoing_lc = new LocalConnection();
      //using the send() method
      outgoing_lc.send("lc_name", "methodToExecute");
      //delete the local connection now that the
      delete outgoing_lc;
      };

      then:

      //create the LocalConnection by first
      //setting it equal to a variable
      incoming_lc = new LocalConnection();
      //define the function that will execute when a connection is made
      incoming_lc.methodToExecute = function () {
      gotoAndPlay("frame2";
      }
      //make the connection
      incoming_lc.connect("lc_name");






        • 1. Re: controlling one ad from another
          I found this link: http://www.adobe.com/cfusion/knowledgebase/index.cfm?id=tn_16243

          It explains how to send a text message from one movie to another....but I'm wondering more how to create a button that controls something else, like the timeline in another movie.
          • 2. Re: controlling one ad from another
            Sketchsta Level 1
            all you need to know is the target path of the timeline you want to control.

            eg, if you have your Main movie, which loads 2 other movies into it called movie_mc_1, and movie_mc_2.
            and say you want to click on a button and have movie_mc_1 go to frame 5 and play from there, and movie_mc_2 to goto frame 20 and stop there.

            on the timeline of your main movie, on the first frame you would create a button and give it an instance name on btn_mc, then on another layer still on the first frame you would have something like...

            btn_mc.onRelease = function() {
            _root.holder_mc_1.movie_mc_1.gotoAndPlay(5);
            _root.holder_mc_2.movie_mc_2.gotoAndStop(20);
            }

            hope this helps.
            • 3. Re: controlling one ad from another
              This is not what i'm looking for.I'm trying to create two flash movies in the same html page that can control each other....not, one flash movie loaded into another movie.