dcsimg
A Flash Developer Resource Site

Results 1 to 9 of 9

Thread: LocalConnection Object

  1. #1
    Member
    Join Date
    Apr 2009
    Posts
    51

    LocalConnection Object

    Hello,

    I'm currently trying to call up one swf to another using this method, kindly suggested by Northcode, without any success. I have looked at documentation on it and I've been trying out a tutorial but it's not working for me. I have seen some third party apps that do what I want, but I'd like to understand what's behind it, once the theory is understood I'll probably purchase an swf2exe app.

    I've attached the two files created from the tutorial, any help on this would be appreciated.

    Thanks
    Attached Files Attached Files

  2. #2
    Tim (Super Moderator) Northcode's Avatar
    Join Date
    Dec 2000
    Location
    Whitehorse YT
    Posts
    3,766
    Looks like that tutorial was designed to make your life too complicated

    Try this...
    Attached Files Attached Files

  3. #3
    Member
    Join Date
    Apr 2009
    Posts
    51
    This is great, once again you switch the light on.

    I think I understand what's going on here:

    lc = new LocalConnection();
    lc.send("simple_lc", "methodName", send_txt.text);
    It's like MSN,

    but what if I wanted it to bring up an entire swf, would I use something other than "send_txt.text"?
    I've tried a couple of things but they don't seem to work.

    Also I see that in order for this to function it has to have both the sending swf and receiving swf in the same movie, otherwise it won't work.
    Is that right?

    I've managed to call it up in a mc_holder in the same movie.
    But cant seem to get the second movie to load into it, only the speech.

    I've attached my add ons

    Thanks again

    This is following the previous post you helped me with:
    http://board.flashkit.com/board/showthread.php?t=804846
    Attached Files Attached Files

  4. #4
    Tim (Super Moderator) Northcode's Avatar
    Join Date
    Dec 2000
    Location
    Whitehorse YT
    Posts
    3,766
    Keep the SWF you want to load external to the sender and receiver but in a place where they can both access it. Then just send the name of the SWF via the local connection and have the receiver load the SWF that the sender tells it to. Will that work for what you're trying to do?

  5. #5
    Member
    Join Date
    Apr 2009
    Posts
    51
    I don't think I understand what you mean,

    by "external" do you mean not loaded in the sender?
    If you look at the attached zip in my last post, I have not loaded the
    picture swf into the senders mc_holder, only the receiver loads in.

    Parent Movie ------ mc_holder------receiver loads into parent movie, into holder

    Picture movie ---- should only load when called through the picture button

    in this instance it is external or not with-in the Parent Movie

    or do you mean
    in a another folder external from the loaded receiver?


    appreciate your help,

  6. #6
    Tim (Super Moderator) Northcode's Avatar
    Join Date
    Dec 2000
    Location
    Whitehorse YT
    Posts
    3,766
    By external I mean outside Flash, yes.

    If the receiver SWF contains all the movie clips you want to load and the sender just sends a trigger (the name of the asset to load) then that will work but you can't send a movie clip or a SWF to another SWF via LocalConnection (as far as I know).

  7. #7
    Member
    Join Date
    Apr 2009
    Posts
    51
    Ok let me see if I have this.

    Effectively what I want to do can't be done through LC.
    Calling swfs up through a button.

    But

    If I some-how include all the movie clips into the receiver
    and then use buttons from the receiver to call up those movies it should work.

    How would I include multiple movies in the one receiver swf with-out having them on the stage? Would I put them at intervals along a timeline?
    If so the triggers would need a path to link to?

    Something like:

    open_pic.setLabel("picture");
    open_pic.onRelease = function()
    {
    lc2 = new LocalConnection();
    lc2.send("folder/picture.swf", "methodName");
    }


    I'm sorry but Im totally lost.

    I've not used flash in this way before, only use absolute paths from a trigger.

  8. #8
    Tim (Super Moderator) Northcode's Avatar
    Join Date
    Dec 2000
    Location
    Whitehorse YT
    Posts
    3,766
    It can be done, you just need to wrap your head around the possible solutions instead of the "perfect" solution you'd like to use Flash doesn't give you a way to transfer a movie clip from one running SWF to another so need to find a solution that Flash will let you get away with. There are two that I can think of... (1) you can import the SWFs to your library as movie clips OR (2) you can leave them on disk and load them by name. Either way the receiver is doing all the heavy lifting and the sender is just telling it which asset you'd like it to load and where it should find it. With the first solution the receiver has to have all the SWFs inside it (can make for a heavy SWF). With the second solution you don't need to modify your receiver every time you want/have to change one of the SWFs that needs to be loaded.

  9. #9
    Member
    Join Date
    Apr 2009
    Posts
    51
    I'll continue to try it out and see what I can achieve.
    I'll post back when and if I crack it

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