A Flash Developer Resource Site

Results 1 to 13 of 13

Thread: [F8] Shared Object between 2 mc's

  1. #1
    Junior Member
    Join Date
    Aug 2005
    Posts
    24

    [F8] Shared Object between 2 mc's

    Hi Guys,

    I am pretty new to shared objects and need some help.

    I have two mc's, one is the login (php/flash) and the other is secured area. Basically when a customer accesses the secure area I want it to create a Shared Object for the login page to read.

    Example:When the customer logs into the secure area and then goes back to the login page it will read the SharedObject telling it they already visited the secure area and go to frame 3 on the login page... bacially bypassing the login process again.

    Below is the code I current have but it is not working... any help would be appreciated.

    Secure area fram 1 fla:
    Code:
    var sos:SharedObject = new SharedObject();
    sos.data.Play = "AA";
    sos.flush();
    Log in page:
    Code:
    var sos:SharedObject = new SharedObject();
    if (sos.data.Play != "undefined") {
    	this.authmain.gotoAndStop(3);
    	sos.flush();
    }

  2. #2
    Musical chair sumwungye's Avatar
    Join Date
    Jan 2008
    Location
    Planet Earth, third planet from the Sun
    Posts
    287

    Yup.

    Put this code somewhere where it will only be passed by ONCE (at the beginning):
    Code:
    _root.sos=SharedObject.getLocal("secure");
    Secure area
    Code:
    _root.sos.data.Play = "AA";
    _root.sos.flush();
    Login page:
    Code:
    if (_root.sos.data.Play !== "undefined") {
    	this.authmain.gotoAndStop(3);
    	_root.sos.flush();
    }
    If this doesn't work or doesn't do what you want, let me know.
    --SumWunGye

  3. #3
    Musical chair sumwungye's Avatar
    Join Date
    Jan 2008
    Location
    Planet Earth, third planet from the Sun
    Posts
    287
    Sorry, that last block of code should say this:
    Code:
    if (_root.sos.data.Play) {
    	this.authmain.gotoAndStop(3);
    	_root.sos.flush();
    }
    --SumWunGye

  4. #4
    Junior Member
    Join Date
    Aug 2005
    Posts
    24
    Hi Sumwungye,

    Thank you. However it is not working.

  5. #5
    Junior Member
    Join Date
    Aug 2005
    Posts
    24

    shared obejct

    I do see that it is creating the shared object but the login mc is not reading it?

  6. #6
    Musical chair sumwungye's Avatar
    Join Date
    Jan 2008
    Location
    Planet Earth, third planet from the Sun
    Posts
    287
    Maybe you could try posting your Flash...you know, I'd rather ask that than ask you to post all of its details.
    --SumWunGye

  7. #7
    Junior Member
    Join Date
    Aug 2005
    Posts
    24

    filexs

    Here are the fla's (zipped) to fit. Please note that there are many more mc's and php files that come into play but these are the two files that use the shared objects. I appreciate all your help.
    Attached Files Attached Files

  8. #8
    Musical chair sumwungye's Avatar
    Join Date
    Jan 2008
    Location
    Planet Earth, third planet from the Sun
    Posts
    287
    You DO know that SharedObjects can't be transferred between different flash files without PHP, right?
    --SumWunGye

  9. #9
    Musical chair sumwungye's Avatar
    Join Date
    Jan 2008
    Location
    Planet Earth, third planet from the Sun
    Posts
    287
    I was expecting it all to be one file, for one thing... For another, if there are two files, you're going to need to use some php to transfer the different SharedObjects.

    Plus, you put the "this.authmain" part on the frame, so you should change that to "_root" for it to work.

    I also noticed most of the code I posted......wasn't in there...?

    Yeah, so only the file that created the SharedObject can access it and vice versa.

    Plus, you told the SharedObject to goto frame 3.....................which didn't exist.

    That's about it... You can get back to me on that...
    --SumWunGye

  10. #10
    Junior Member
    Join Date
    Aug 2005
    Posts
    24
    Thanks for all your help, very much appreciated. I will have to look around on how to transfer a shared object between two fla's with php. Would you know of any resources or tutorials?

    On your comments
    this.authmain is the file that needs to go to the frame 3, authmain has a frame 3, it's a mc is inside FFprod.fla.

    I did change the you posted code around to try to get it to work... sorry about that for not changing it back before posting the files.

  11. #11
    Musical chair sumwungye's Avatar
    Join Date
    Jan 2008
    Location
    Planet Earth, third planet from the Sun
    Posts
    287
    Yeah, so "this.authmain" should be "_root.authmain" or just "authmain".
    --SumWunGye

  12. #12
    Musical chair sumwungye's Avatar
    Join Date
    Jan 2008
    Location
    Planet Earth, third planet from the Sun
    Posts
    287

    Okay.............................................. .........................

    Anyway, put this on the part of your flash where you want it to go to the other flash (the receiving one), where the code "this.unloadMovie();" goes:

    Code:
    getURL("mainpage.php?page=a", "_self", "POST");
    Put this code on the part of the receiving flash, at the very beginning:

    Code:
    _root.holder = new LoadVars();
    _root.holder.load("mainpage.php");
    Finally, create a .php file with this code (named "mainpage.php"):

    PHP Code:
    <?php
    echo "<html><head><title>Fabric Page</title></head><body>";
    if (
    $_GET["page"]=="a"){
    echo 
    "<embed src='FFprod.swf'></embed>;
    } else {
    echo "
    <embed src='FFwelcome'></embed>;
    }
    $Play $_POST["Play"];
    echo 
    "</body></html>";
    ?>
    If I did this right, your variable (holding "AA") should be, in the receiving flash, "_root.holder.Play" If not, let me know, because I probably did it wrong.

    Bye!
    --SumWunGye

  13. #13
    Junior Member
    Join Date
    Aug 2005
    Posts
    24
    Sorry for the delayed response, thank you! I will give it a try

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