A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: Linking between 2 different .swf files

  1. #1
    Junior Member
    Join Date
    Nov 2009
    Posts
    3

    Linking between 2 different .swf files

    So I have main .swf file(I'll call it movie1) that leads to webpages that are not in the movie. The webpage has a navbar which is a seperate .swf file (I'll call this movie2). I need the buttons on the navbar to link to a certain place in the main movie. Is there a way to use gotoAndplay in movie2 to go to a scene in movie1? How could I make this work? Thanks.

  2. #2
    Member
    Join Date
    Nov 2009
    Location
    Philadelphia
    Posts
    40
    Here you go 'dmore'. This is in AS2.0, I hope this helps... it's really easy to pass info between two flash movies.
    Put this code in the first flash file... assuming that a button click will start the process


    var mySender:LocalConnection = new LocalConnection();
    //
    var myText:String;
    btnStart.onRelease = function() {
    myText = "some variable/text to pass";
    mySender.connect("myConnections");
    mySender.send("myConnections", "myAction", txtVar);
    };


    ---------------------------------
    put this code in the receiving flash file
    ----------------------------------

    var myReceiver:LocalConnection = new LocalConnection();
    myReceiver.connect("myConnections");
    myReceiver.myAction = function(myText:String) {

    //do something with the passed variable in this function

    };

  3. #3
    Junior Member
    Join Date
    Nov 2009
    Posts
    3

    no luck

    I had to modify the code a little bit because I'm using CS4. So I'm getting this error. I was hoping there wasn't much difference between versions.

    Error #2044: Unhandled AsyncErrorEvent:. text=Error #2095: flash.net.LocalConnection was unable to invoke callback myAction. error=ReferenceError: Error #1069: Property myAction not found on flash.net.LocalConnection and there is no default value.

    mybutton.addEventListener(MouseEvent.CLICK, buttonClicked);
    var mySender:LocalConnection = new LocalConnection();



    function buttonClicked(event:MouseEvent):void {

    var myText:String;
    myText = "some variable/text to pass";
    mySender.connect("myConnections");
    mySender.send("myConnections", "myAction", "s2");
    }

    Any chance you know how to make this work in 3.0?

  4. #4
    Member
    Join Date
    Nov 2009
    Location
    Philadelphia
    Posts
    40
    sorry... I haven't had time to study AS3 yet... I know it works in AS2 because I use it quite often.
    Last edited by nstanziani; 11-19-2009 at 10:49 AM. Reason: typo
    - Nick Stanziani

    pls support: www.whowantsacookie.com

    My site: pebcak

  5. #5
    Junior Member
    Join Date
    Nov 2009
    Posts
    3
    Ok. Im trying this is AS 2.0. I am completely new to actionscript so I'm probably doing something ignorant here. What do I need to plug into this code just so the 2nd file will play go to a certain scene?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center