11 Replies Latest reply on Jul 29, 2010 6:54 AM by kglad

    swf picture disappears from the screen

    alexee77

      We have a problem with a code as below made in AS2. By some reason 3-4 minutes after appearance the image disappears from the screen. Please, advise, where is the error? How to keep the picture on the screen and make it possible that it would be dynamic only at the first loading, and at second and next clicks on the html links it becomes static?

       

      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";
      lightSpeed = -lightSpeed;
      showNext(white);
      }
      function showNext(clip:MovieClip):Void {
      clip.onEnterFrame = function():Void {
      this._alpha += lightSpeed;
      };
      }
      init();

        • 1. Re: swf picture disappears from the screen
          kglad Adobe Community Professional & MVP

          you're never terminating your onEnterFrame loop.  after a while that _alpha exceeds its limit and wraps to negative numbers.

           

          use:

           


           

          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";
          lightSpeed = -lightSpeed;
          showNext(white);
          }
          function showNext(clip:MovieClip):Void {
          clip.onEnterFrame = function():Void {
          this._alpha += lightSpeed;

          if(this._alpha>=100){

          delete this.onEnterFrame;

          }

          };
          }
          init();

          • 2. Re: swf picture disappears from the screen
            alexee77 Level 1

            Thank you very much for your reply.

            However, the picture still disappears with your code too, after abt. 3 minutes the screen is empty again.

            • 3. Re: swf picture disappears from the screen
              kglad Adobe Community Professional & MVP

              there's something else going on besides that code.

               

              lightSpeed is -5 when that loop starts so your object should fade out quickly.  it will re-appear again latter because that _alpha loops to a positive number.

              • 4. Re: swf picture disappears from the screen
                alexee77 Level 1

                Is there any possibility to change this code in such a way that the picture will not disappear?

                • 5. Re: swf picture disappears from the screen
                  kglad Adobe Community Professional & MVP

                  if you're trying to fade in "white", use:

                   

                  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(0xFFFF00);
                          lineTo(Stage.width,0);
                          lineTo(Stage.width,Stage.height);
                          lineTo(0,Stage.height);
                          lineTo(0,0);
                          endFill();
                      }
                      white.blendMode = "add";
                      white._alpha = 0;
                      showNext(white);
                  }
                  function showNext(clip:MovieClip):Void {
                      clip.onEnterFrame = function():Void  {
                          this._alpha += lightSpeed;
                  trace(this._alpha);
                          if (this._alpha>=100) {

                   

                              delete this.onEnterFrame;

                   

                          }

                   

                      };
                  }
                  init();

                  • 6. Re: swf picture disappears from the screen
                    alexee77 Level 1

                    Thank you for info. However, the picture becomes yellow.

                    We need to get in a result something similar to http://www.creative-portal.ru/Uroki-Flash-10/106964-b-Smena-slaydov-cherez-quot-zasvet-quo t-b-urok.html

                    but with one picture only, that after appearance it remains displayed.

                    • 7. Re: swf picture disappears from the screen
                      kglad Adobe Community Professional & MVP

                      for white, use:

                       

                      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";
                          white._alpha = 0;
                          showNext(white);
                      }
                      function showNext(clip:MovieClip):Void {
                          clip.onEnterFrame = function():Void  {
                              this._alpha += lightSpeed;
                      trace(this._alpha);
                              if (this._alpha>=100) {

                       

                                  delete this.onEnterFrame;

                       

                              }

                       

                          };
                      }
                      init();

                      • 8. Re: swf picture disappears from the screen
                        alexee77 Level 1

                        Thank you.

                        However, the last one code makes a motion from picture to white background.

                        But wee need vice versa, like in the first code, as quoted below. This is working fine, and the result is as we need, but by some reason after the picture appears, it disappear in about 3-4 min. again, and it is required that it will not disappear. If possible, I can send you flv file to your e-mail address to see the problem.

                         

                        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";
                        lightSpeed = -lightSpeed;
                        showNext(white);
                        }
                        function showNext(clip:MovieClip):Void {
                        clip.onEnterFrame = function():Void {
                        this._alpha += lightSpeed;

                         

                        if(this._alpha>=100){

                         

                        delete this.onEnterFrame;

                         

                        }

                         

                        };
                        }
                        init();

                        • 9. Re: swf picture disappears from the screen
                          kglad Adobe Community Professional & MVP

                          if you want to fade out the white cover, use:

                           


                          var lightSpeed:Number = 5;


                          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();

                          • 10. Re: swf picture disappears from the screen
                            alexee77 Level 1

                            All is working fine. This is the work of a genius! Thank you very much.

                             

                            I would like to ask you of the following:

                            - is it possible to make so that .swf file with this code will loaded for the 2nd and following times without fade-out effect, but simply as static picture. For instance, at the front page of a website this is loading with fade-out effect as dynamic, and in the 2nd and following web-pages the same already loaded file works already as static, without motion (i.e. effects)? Or it is required anyway to load other static .swf file for 2nd and the following web-pages?

                             

                            -  Another one question: by some reason after setting of hotlink protection for .swf file in .htaccess on the server, .swf file is not displayed in Safari browser for Windows.
                            RewriteRule .*\.(jpg|jpeg|gif|png|bmp|swf)$ - [F,NC]
                            Options -Indexes
                            In all other browsers swf is displayed with hotlink protection, and in Safari it is displayed only if hotlink protection is not set, other files, like .png work with hotlink protection in Safari too, but .swf not.
                            Maybe do you know what is the cause? Have you ever faced such an issue?
                            Thank you in advance.

                            • 11. Re: swf picture disappears from the screen
                              kglad Adobe Community Professional & MVP

                              you're welcome.

                               

                              i don't know what you've done in your .htaccess file and i don't understand your question about a 2nd load.

                               

                              please mark this thread as answered, if you can.  start a new thread if you have other problems.