12 Replies Latest reply on Sep 20, 2010 5:05 AM by alexee77

    Play Movie Only One Time

    alexee77

      I need the movie to play just once (the top header) per user session and then other pages not to restart the same movie from the beginning...
      At the same time protection against hotlinking should remain.
      Can anybody help me? Is it possible to make this without storing the swf file on the user's machine? Will be glad to solutions of this issue.

       

      The code is asf.:

       

      var picTotal:Number = 1;
      var lightSpeed:Number = 5;
      var delay:Number = 5000;
      var count:Number = 0;
      function init():Void {
      var white:MovieClip = this.createEmptyMovieClip("wh", 10);
      with (white) {
      beginFill(0xFFFFFF);
      lineTo(Stage.width, 0);
      lineTo(Stage.width, Stage.height);
      lineTo(0, Stage.height);
      lineTo(0, 0);
      endFill();
      }
      white.blendMode = "add";
      showNext(white);
      }
      function showNext(clip:MovieClip):Void {
      clip.onEnterFrame = function():Void {
      this._alpha -= lightSpeed;
      if(this._alpha<=0){
      delete this.onEnterFrame;
      }
      };
      }
      init();

        • 1. Re: Play Movie Only One Time
          kglad Adobe Community Professional & MVP

          you can use the sharedobject to track each client.


          • 2. Re: Play Movie Only One Time
            alexee77 Level 1

            Thanks.

            Could you please inform, how to modify code to implement this.

            • 3. Re: Play Movie Only One Time
              kglad Adobe Community Professional & MVP

              because it's not clear what you mean by, "I need the movie to play just once (the top header) per user session and  then other pages not to restart the same movie from the beginning", you'll need to encode that yourself.

              • 4. Re: Play Movie Only One Time
                alexee77 Level 1

                The situation is asf.:

                There is only one swf object on the web-site, this is top on the web-site.

                It has to appear on each page, but it's playing with flash effects has to be only on the home page, on other pages there should be no restart to play from the beginnig, only static picture. So I asked, if there is any solution for this. You proposed the sharedobject, but I would like to ask you which modifications are required in the html code to embed this sharedobject, and if hotlink protection will remain.

                I've never used shareobjects before, so I ask.

                Thank you in advance.

                • 5. Re: Play Movie Only One Time
                  kglad Adobe Community Professional & MVP

                  no html code modification is needed.  you

                   

                  1.  check if a sharedobject exists and you probably want to check for a recent date/time

                  2.  if there's none, play your swf

                  3.  if there is one, display the static pic in your swf

                  4.  create the sharedobject and you probably want to store the date/time

                  • 6. Re: Play Movie Only One Time
                    alexee77 Level 1

                    Thank you, but I still cannot understand it completely.

                    I have found a solution to the same problem on one of internet forums about flash as below.

                    However, this does not work. Maybe any additional scripts for sharedobject required?

                     

                    myLocal_so = sharedobject.getLocal("flashcookie", "/images/top.swf"); // create the SO

                     

                    // see if the SO exists

                     

                    if (!myLocal_so.data.visited) { // if it doesn't

                     

                    gotoAndStop(_totalframes); // send the playhead to the last frame

                     

                    myLocal_so.data.visited = true; // set the value to true

                     

                    myLocal_so.flush(); // write

                     

                    } else { // first visit

                     

                    // play to movie

                     

                    }

                    • 7. Re: Play Movie Only One Time
                      kglad Adobe Community Professional & MVP

                      use:

                       


                       

                      myLocal_so = sharedobject.getLocal("flashcookie", "/"); // create the SO

                       

                      // see if the SO exists

                       

                      if (myLocal_so.data.visited) { // if it doesn't

                      // skip intro

                      gotoAndStop(_totalframes); // send the playhead to the last frame

                      } else {

                      // play intro

                      }

                       

                      myLocal_so.data.visited = true; // set the value to true

                      myLocal_so.flush(); // write

                       


                      • 8. Re: Play Movie Only One Time
                        alexee77 Level 1

                        I have added the code you have recommended, but there is no result, the top.swf file restarts to load on each page. I've tried to remove hotlink protection on the server, but there is no effect. Maybe any additional files/libraries for sharedobject required?

                         

                        var picTotal:Number = 1;
                        var lightSpeed:Number = 5;
                        var delay:Number = 5000;
                        var count:Number = 0;
                        function init():Void {
                        var white:MovieClip = this.createEmptyMovieClip("wh", 10);
                        with (white) {
                        beginFill(0xFFFFFF);
                        lineTo(Stage.width, 0);
                        lineTo(Stage.width, Stage.height);
                        lineTo(0, Stage.height);
                        lineTo(0, 0);
                        endFill();
                        }
                        white.blendMode = "normal";
                        showNext(white);
                        }
                        function showNext(clip:MovieClip):Void {
                        clip.onEnterFrame = function():Void {
                        this._alpha -= lightSpeed;
                        if(this._alpha<=0){
                        delete this.onEnterFrame;
                        }
                        };
                        }
                        init();

                         

                        myLocal_so = sharedobject.getLocal("flashcookie", "/images/top.swf"); // create the SO

                         

                        // see if the SO exists

                         

                        if (myLocal_so.data.visited) { // if it doesn't

                         

                        // skip intro

                         

                        gotoAndStop(_totalframes); // send the playhead to the last frame

                         

                        } else {

                         

                        // play intro

                         

                        }

                         

                        myLocal_so.data.visited = true; // set the value to true

                         

                        myLocal_so.flush(); // write

                        • 9. Re: Play Movie Only One Time
                          kglad Adobe Community Professional & MVP

                          that's not the code i suggested.

                          • 10. Re: Play Movie Only One Time
                            alexee77 Level 1

                            Yes, you have suggested to use

                             

                            myLocal_so = sharedobject.getLocal("flashcookie", "/"); // create the SO

                             

                             

                            // see if the SO exists

                             

                             

                            if (myLocal_so.data.visited) { // if it doesn't

                             

                            // skip intro

                             

                            gotoAndStop(_totalframes); // send the playhead to the last frame

                             

                            } else {

                             

                            // play intro

                             

                            }

                             

                             

                            myLocal_so.data.visited = true; // set the value to true

                             

                            myLocal_so.flush(); // write

                             

                            Do I correct understand that it has to be added to the code of the movie clip or not?

                            • 11. Re: Play Movie Only One Time
                              kglad Adobe Community Professional & MVP

                              the code i suggested should execute in frame 1 of your swfs.


                              1 person found this helpful
                              • 12. Re: Play Movie Only One Time
                                alexee77 Level 1

                                Hello,

                                 

                                After placing your sharedobject code into the 1st frame of the movie clip, there is still no change.

                                The only change, placing it into the 1st frame makes loop effect in the movie clip.