A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: How do I read Shared Object from another movie?

  1. #1
    Member
    Join Date
    Jun 2002
    Posts
    67

    How do I read Shared Object from another movie?

    I have created a Shared Object in "A.swf". I can read and write to it -no problem, but how do I read it in "B.swf"when Shared Object's data was changed in "A.swf".

    In "A.swf" I use a bottom:

    function doEnter(){
    sobj = SharedObject.getLocal("test" , "/");
    sobj.data.mydata=text_txt.text;
    sobj.flush();
    }

    In "B.swf" I use:

    sobj = SharedObject.getLocal("test" , "/");
    answer_txt.text=sobj.data.mydata;
    sobj.flush();


    If I reload the "B.swf",I can read the newest data. But I don't want to reload the "B.swf" again. How can I do this?

    Any help would be much appreciated!

    softip

  2. #2
    Softip

    As you're using a localShared Object you don't have Comm server to let the other swf know a change has been made. What you can do though is use the local connection object to 'talk' to the other movie and let it know it needs to reload the local shared object. You can find more about it in the Reference panel of Flash (communications > LocalConnection).
    This is the code though:

    // Code in the receiving movie
    receivingLC = new LocalConnection();
    receivingLC.methodToExecute = function(param1, param2)
    {
    // Code to be executed
    }
    receivingLC.connect("lc_name");

    // Code in the sending movie
    sendingLC = new LocalConnection();
    sendingLC.send("lc_name", "methodToExecute", dataItem1, dataItem2)

    It's very simple, doesn't even require Comm server and will talk to swfs in different frames, windows or even applications (browser to standalone and vice-versa).

    Hope this does the trick for you.
    Outside of a dog, a book is man's best friend. Inside of a dog, it's too dark to read. - Groucho Marx

  3. #3
    Member
    Join Date
    Jun 2002
    Posts
    67
    Hi sideshow_barry:

    Thanks for your advices! I got it that is successful in my application. Moreover,I found some references out. There're useful for me! Thanks!

    softip

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