8 Replies Latest reply on Sep 21, 2006 5:10 AM by Newsgroup_User

    Target main.swf and load frame30

    Entenie
      Hello everybody,

      I recently constructed a new website and it uses two different swf files. The main swf file main.swf is aligned to the toprightcorner of the webpage, and the other swf buttons.swf is at the bottom of the webpage. What I need now is the buttons.swf to whenever a button is hit, the main.swf should play a particular frame. So when I press button 1, frame 30 of main.swf should start playing.

      Is this possible? Or is it possible instead of using buttons.swf, I just add different gif images and somehow have those images target the frame within main.swf?

      I've been searching for a whole day and I can't seem to find anything. I'm quite new to flash when it comes to adding functions or script.

      I hope anyone can help me!

      Regards,
      Entenie
        • 1. Re: Target main.swf and load frame30
          pall zoltan Level 1
          hi

          look for the ExternalInterface class and read through few times till you understand it and then try to copy-paste the code to make yours work
          coz afterall it _does_ work :)
          • 2. Re: Target main.swf and load frame30
            Level 7
            pall zoltan,

            > look for the ExternalInterface class and read through few
            > times till you understand it and then try to copy-paste the
            > code to make yours work coz afterall it _does_ work :)

            Well, sure. Of course it works. ;) But based on what the original
            poster wrote, ExternalInterface isn't the answer.

            >> The main swf file main.swf is aligned to the toprightcorner
            >> of the webpage, and the other swf buttons.swf is at the
            >> bottom of the webpage.

            Are these separate SWFs, then?

            >> What I need now is the buttons.swf to whenever a button
            >> is hit, the main.swf should play a particular frame. So when
            >> I press button 1, frame 30 of main.swf should start playing.

            If these are separate SWFs, use the LocalConnection class. This allows
            more than one SWF on the same client computer to send messages to each
            other.


            David Stiller
            Adobe Community Expert
            Dev blog, http://www.quip.net/blog/
            "Luck is the residue of good design."


            • 3. Target main.swf and load frame30
              Entenie Level 1
              I don't know anything about the LocalConnection class. Would this help me target the frame of another swf file?

              And yes, there are two different swf files.
              • 4. Re: Target main.swf and load frame30
                Level 7
                Entenie,

                > I don't know anything about the LocalConnection class. Would
                > this help me target the frame of another swf files?

                From the "LocalConnection class" entry of the ActionScript 2.0 Language
                Reference, which is part of the built-in Help documentation:

                <quote>
                The LocalConnection class lets you develop SWF files that can send
                instructions to each other without the use of fscommand() or JavaScript.
                LocalConnection objects can communicate only among SWF files that are
                running on the same client computer, but they can be running in different
                applications--for example, a SWF file running in a browser and a SWF file
                running in a projector. You can use LocalConnection objects to send and
                receive data within a single SWF file, but this is not a standard
                implementation; all the examples in this section illustrate communication
                between different SWF files.
                </quote>

                > And yes, there are two different swf files.

                Then it sounds like the LocalConnectin class is what you want. :)


                David Stiller
                Adobe Community Expert
                Dev blog, http://www.quip.net/blog/
                "Luck is the residue of good design."


                • 5. Re: Target main.swf and load frame30
                  Entenie Level 1
                  Thanks for the tip!

                  I downloaded a sample file from the Adobe support site which demonstrates how to send text from one swf file to another.

                  Only thing different is that I want one swf file to tell the other to go to frame 10.

                  I've been experimenting but to be honest I have no clue as what each word means in the code. I hope it's not rude if I ask for a working sample. I'm not planning on going any further with programming with flash, this is all I need so if anyone won't find it too much trouble helping me out with this one thing, I'd really appreciate it.

                  And thanks for the help so far!
                  • 6. Re: Target main.swf and load frame30
                    Level 7
                    Entenie,

                    > Thanks for the tip!

                    Sure thing. :)

                    > I downloaded a sample file from the Adobe support site which
                    > demonstrates how to send text from one swf file to another.

                    Okay.

                    > Only thing different is that I want one swf file to tell the other to
                    > go to frame 10.
                    >
                    > I've been experimenting but to be honest I have no clue as what
                    > each word means in the code.

                    Fair enough. It is tough, I admit, when you're just getting started.

                    > I hope it's not rude if I ask for a working sample.

                    Not rude at all. :)

                    > I'm not planning on going any further with programming with flash,
                    > this is all I need

                    Heh, you sure about that? You're never going to use the MovieClip class
                    to instruct various movie clips how to behave? You're never going to use
                    the Button class to assign functions to button events? ;)

                    > so if anyone won't find it too much trouble helping me out with this
                    > one thing, I'd really appreciate it.

                    What file did you download? I'm looking at the LocalConnection class
                    entry right now, and there's a source code example that passes text, like
                    you describe. The thing is, you can write that
                    "receiving_mc.methodToExecute()" function to do anything you like. In the
                    example I'm looking at, it does only one thing:

                    result_txt.text = param1+param2;

                    ... namely, to set the TextField.text property of a particular text field
                    (here, result_txt) to a combination of two passed-in parameters.

                    In your case, you could use the same code, only drop the part the
                    creates a TextField instance ...

                    // cut this
                    this.createTextField("result_txt", 1, 10, 10, 100, 22);
                    result_txt.border = true;

                    ... and change the methodToExecute() from what it is to this ...

                    receiving_lc.methodToExecute = function(param1:Number) {
                    gotoAndPlay(param1);
                    };

                    ... then change the last line in the other SWFs code from what it is to this
                    ...

                    sending_lc.send("lc_name", "methodToExecute", 10);

                    ... which means you're still sending a message over the "lc_name" line, so
                    to speak; you're still calling the "methodToExecute" function; but now,
                    you're only sending one parameter, and this time it's 10. Again, on the
                    receiving end, the methodToExecute() function (which could be named
                    anything, but in this example they used a self-describing name) is simply
                    invoking the native gotoAndPlay() function instead of setting a text field's
                    text. And it's passing in that 10 value via the param1 parameter. Does
                    that clear it up a bit?


                    David Stiller
                    Adobe Community Expert
                    Dev blog, http://www.quip.net/blog/
                    "Luck is the residue of good design."


                    • 7. Re: Target main.swf and load frame30
                      Entenie Level 1
                      It's a miracle it's working! :D

                      Thanks a lot!
                      • 8. Re: Target main.swf and load frame30
                        Level 7
                        Entenie,

                        > It's a miracle it's working! :D

                        Elementary! Honestly, you just have to give it a go. I know you said
                        this was all you'd ever need in regard to ActionScript, but I encourage you
                        to keep at it.

                        You might get something out of these three articles here.

                        http://www.quip.net/blog/first-time-here/

                        > Thanks a lot!

                        Glad to help. :)


                        David Stiller
                        Adobe Community Expert
                        Dev blog, http://www.quip.net/blog/
                        "Luck is the residue of good design."