A Flash Developer Resource Site

Results 1 to 14 of 14

Thread: [RESOLVED] SharedObject..can it refresh faster?

  1. #1
    Senior Member
    Join Date
    Dec 2005
    Posts
    142

    [Kinda...RESOLVED] [Kinda] SharedObject..can it refresh faster?

    Ok i have a site im working on, and everything works fine, in fact, this script kinda works fine, if you refresh the page that the site is on, when it gets back to that frame, it knows you have checked your e-mail, but the fact is, i dont want you to have to refresh, heres my code

    on the main site i have this
    Code:
    onClipEvent(enterFrame) {
    	var info:SharedObject = SharedObject.getLocal("mainsite", "/");
    	if (info.data.email == undefined) {
    		gotoAndStop(1);
    	} else {
    		gotoAndStop(2);
    	}
    }
    it then has a button that loads another page in a window with the e-mail inpute and flash file on it with this script

    Code:
    onClipEvent(enterFrame) {
    	var info:SharedObject = SharedObject.getLocal("mainsite", "/");
      info.data.email = 1;
      info.flush();
    }
    now the fact is, if i refresh the main page, it knows that e-mail = 1, but why cant it refresh the SharedObject without Refreshing the page!?
    Last edited by molster; 11-27-2006 at 02:39 AM.

  2. #2
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,448
    Once the shared object is created you do not need to change any frame. You can directly call the shared object. BTW, I strongly recommend you to go away from associating scripts with buttons or movieclips. It makes life difficult for anybody debugging scripts. Put all scripts in a frame on the main timeline.
    - The right of the People to create Flash movies shall not be infringed. -

  3. #3
    Senior Member
    Join Date
    Dec 2005
    Posts
    142
    i know what you have said, but thats not my problem exactly, my one file is checking the var "mail" in my sharedobject, once it see that it is no longer undefined, it needs to go to its 2nd frame, however, it dosnt relazie that it is no longer undefined until i refresh the page. mail is being set to 1 in a whole nother .swf file on another page.

    if you would like to see what im talking about

    ~Link Removed~ (just dl the zip file)

    go there and do as it says (the php isnt working so it wont send your e-mail, in fact you can just put all T's if you want) when you see the pop-up come up with the e-mail text field, you will see after 6 seconds a red dot appear on that page, when that red dot appears it sets the Shardobject varible "mail" to 1. on the main site, in the red text, you will see it say "e-mail not entered" that is the mc that will go to frame 2. if you refresh your browser after you do the e-mail, when you get back to this spot, it will now be green (aka it knows the var now = 1)
    Last edited by molster; 11-29-2006 at 02:13 AM.

  4. #4
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,448
    You are giving too few informations. I don't know your movie and from the description and what I see i have no idea how it works. May be you can post sample files.
    - The right of the People to create Flash movies shall not be infringed. -

  5. #5
    Senior Member
    Join Date
    Dec 2005
    Posts
    142
    ok give me...10 mins..if that, and ill make up a quick ver of this with both .fla files. I wont double post so ill just edit this with the files so check back, and thanks for your time ^^

    ok here it is in action
    ~Link Removed~ (just dl the .fla)


    notice, once you have the other page pop-up, if you refresh the main one, it finaly knows that it = 1, why dosnt it know it without a refresh?


    PS: if you clear the sharedobject, it knows it goes back to undefined right away... err maby it has somthing to do with my info.flush(); not flushing or somthing.. or.. i duno..
    Attached Files Attached Files
    Last edited by molster; 11-29-2006 at 02:17 AM.

  6. #6
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,448
    I think the problem was that you have all those scripts associated with buttons and movieclips. I changed that and now it works. Once the new page opens, the movie goes to the next frame.
    Attached Files Attached Files
    - The right of the People to create Flash movies shall not be infringed. -

  7. #7
    Senior Member
    Join Date
    Dec 2005
    Posts
    142
    Why will it only change the main time line right away?? Cuase chaning the main timeline wont help me on my main project, the little movieclip called "clip" needs to go to frame 2, i tryed changing your script (keeping it all in the main timeline) to _root.clip.gotoAndStop(2); that dosnt work, i tryed making it set a varibale on the main timeline and then my mc check it, that dosnt work, why is it that only the main timeline will change without a refresh and nothing else??

    ive tryed like 20 things just now, nothing but changing the maintime line works right away.... there has to be a way, if it can change right away,anything should be able to..
    Last edited by molster; 11-26-2006 at 01:31 PM.

  8. #8
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,448
    I did not know that clip has two frames .
    Just change to this.

    clip.onEnterFrame = function ()
    {
    var info:SharedObject = SharedObject.getLocal ("test", "/");
    trace (info.data.mail);
    if (info.data.mail == undefined)
    {
    this.gotoAndStop (1);
    }
    else
    {
    this.gotoAndStop (2);
    this.onEnterFrame = null;
    }
    };
    - The right of the People to create Flash movies shall not be infringed. -

  9. #9
    Senior Member
    Join Date
    Dec 2005
    Posts
    142
    and it works perfectly! thank you very very much for your time, i guess i am gana have to start learning to use the main timeline more for scripts, the only reason i dont is beacause the book i learned AS in used a MC off to the side of the scene for all the scripts, so i learned to do all my scripts in mc lol.

    anyway, do you know why this only works when you use the main timeline to hold the scripts? if not, it dosnt matter, im just happy it works.

  10. #10
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,448
    It should work also when you use "this" in your former script. Just when you have all the scripts on the main timeline, you have a nice overview and everything in one frame. Many problems with variables or pathes are easy to control and will disappear.
    - The right of the People to create Flash movies shall not be infringed. -

  11. #11
    Senior Member
    Join Date
    Dec 2005
    Posts
    142
    and to think you where done helping me with this.. hehehehe... ok anyway
    before i explain whats wrong, i will say i changed my movie around to fix the problem im about to say, HOWEVER, i would like to understand how i could fix this new problem without doing that, for future knowlege.


    ok I understand now how to make it work when you put the script on the timeline, and the MC is on the main timeline, but what happens if the movie clip you want to change...........is in side a mc, and in frame 4 of that MC.


    __________________________________________________ ______________
    just to make it more clear.

    On Layer 7 of Main Time Line - MC called "info". Info has 5 Frames. On frame 4 of "info" there is a MC called mm. "mm" is the MC that we want to go to Frame 2 when our SharedObject "mail" is 1.
    __________________________________________________ ______________






    Code:
    if (info._currentframe == 4) {
    info.mm.onEnterFrame = function() {
    	var info:SharedObject = SharedObject.getLocal("mainsite", "/");
    	if (info.data.email == undefined) {
    		this.gotoAndStop(1);
    	} else {
    		this.gotoAndStop(2);
    	}
    };
    }
    this code cant even find the clip to give it its function... so i go insde the MC "info" go to frame 4 of it, and on its timeline, i do this code

    Code:
    mm.onEnterFrame = function() {
    	var info:SharedObject = SharedObject.getLocal("mainsite", "/");
    	if (info.data.email == undefined) {
    		this.gotoAndStop(1);
    	} else {
    		this.gotoAndStop(2);
    	}
    };
    now it can find it, but it once again has the error of needed to refresh to show it .... how in the world can i fix this without having to move the "mm" MC to the main timeline.
    Last edited by molster; 11-27-2006 at 01:51 AM.

  12. #12
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,448
    This works:
    PHP Code:
    import mx.utils.Delegate;
    //
    var myLoadedVar:Object = new Object ();
    var 
    myListener:Object = new Object ();
    myListener.traceVar setInterval (Delegate.create (thislistener), 1000);
    function 
    listener ()
    {
        if (
    info._currentframe == 4)
        {
            
    notifyMM ();
            
    clearInterval (myListener.traceVar);
        }
    }
    AsBroadcaster.initialize (myLoadedVar);
    myLoadedVar.addListener (myListener);
    myLoadedVar.broadcastMessage ("traceVar");
    //
    function notifyMM ()
    {
        
    info.mm.onEnterFrame = function ()
        {
            var 
    info:SharedObject SharedObject.getLocal ("test""/");
            if (
    info.data.mail == undefined)
            {
                
    this.gotoAndStop (1);
            }
            else
            {
                
    this.gotoAndStop (2);
                
    this.onEnterFrame null;
            }
        };
    }
    //
    myBut.onPress = function ()
    {
        
    getURL ("mail.html""_blank");
        
    info.gotoAndStop (4);
    }; 
    My guess is that somewhere you say to go to frame 4 of info. I put that in the button here as example. You have a Asbroadcaster, which will detetct, when the frame is 4 of info. Then the function notifyMM is triggered and from here you know.
    - The right of the People to create Flash movies shall not be infringed. -

  13. #13
    Senior Member
    Join Date
    Dec 2005
    Posts
    142
    This works Perfectly, thank you so much for your time. Luckly this will be the only thing i have a problem with on my site, beacuse im re-doing it useing sharedObjects now. but now that i know what SharedObjects like and dont like, as i add them in my site, i wont make them needed in such weird areas lol. once again, thank you so much for your time.

  14. #14
    Senior Member
    Join Date
    Dec 2005
    Posts
    142

    Talking

    omg........... im kinda pisst, really pisst acctully, i said it worked correct, will it dosnt, i forgot that i had made a backup of my .fla where the MC "mm" was on the main timeline so that it would work like the first one we did, however when i put your code in the one that actully has it like i said, it does not work. it finds and gives 'mm' the function, however it still needs a refresh before it relized mail = 1 now and it needs to freaken go to the dang next frame...why in the heck is this such a pain. Im about ready to send you my main .fla, but the way its done..your gana have a heck of a time finding it. but i have no choice i guess.

    I have made lines showing you where the MC's are. on the bottom layer i labled it, "this is where info is" and then i drew lines to the mc. inside info, on frame 4 is "mm" i circled mm so you know where that is, i also included
    clear.swf in the zip. just a quick way for you to remove that sharedobject so we can keep testing to make sure its actully working.

    the only reason this is getting me so mad now is theres no reason why it shouldnt work, when we do the trace, the swf knows mail = 1,... why dosnt the script know it until you refresh it..and somthing so simple is ending up being the hardest thing ive learned in flash...*sigh* lol..



    PS: on the main project, my sharedObject is "mainsite" and not "test" and the varible is not "mail" its "email" just so you know.
    Attached Files Attached Files
    Last edited by molster; 11-29-2006 at 02:19 AM.

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