2 Replies Latest reply on Jul 28, 2010 12:24 AM by Karthikeyan Ramasamy

    SharedObject class

    988hfas9fhaf8 Level 1

      Hi there,

      I don't have quite a good enough grasp on AS3 just yet, but I'm getting there.
      I have a movie that has an intro to it. It also has buttons that take  them to subsequent pages. Once they go back, I'd like the intro portion  of the movie to not play. In other words, I'd like it to start at a  particular frame after the initial visit to it.

      I think this can be done with Local Shared Objects, but I haven't quite figured out how exactly. Any solutions?

        • 1. Re: SharedObject class
          kglad Adobe Community Professional & MVP

          you can use the sharedobject to store a variable/value that indicates you have a repeat visitor and then use a goto to skip your intro.

          • 2. Re: SharedObject class
            Karthikeyan Ramasamy

            Here is a simple example of what you are expecting.

             

            1. Create Frame with frame label 'home'. Add a button (instance name 'a_btn') to skip introduction.

            2. Copy the following code to actions panel

                 --------------------------------------------------

                 stop();

                 import flash.net.SharedObject;

                 import flash.events.MouseEvent;

                 var so:SharedObject = SharedObject.getLocal("mysharedobject");

                 if(so.data.frame && so.data.frame!="home")

                      gotoAndStop(so.data.frame);

                 else {

                      so.data.frame = "home";

                      so.flush();

             

                      a_btn.addEventListener(MouseEvent.CLICK, skipIntro);

                 }

             

                 function skipIntro(e:MouseEvent):void {

                      gotoAndStop("menu");

                 }

             

            3. Create new frame with frame label "menu"

            4. Copy the following code to actions panel

                 ------------------------------------------

                 stop();

                 so.data.frame = "menu";

                 so.flush();

             

            Run the swf. Click 'Skip Intro' button and close the application. Run the swf again. It should go to Menu frame directly.

             

             

            Hope this helps.

             

            Thanks,

            Karthikeyan R.