5 Replies Latest reply on Jan 6, 2010 8:17 AM by Sprogleg

    Flash popup banner - Help needed

    Sprogleg

      I'm sure this is really simple but I'm having some problems with it.

       

      Here is an example of where I am so far. http://www.justsandymedia.com/test/test3.html

       

      What I need now is for it to instead of staying on screen forever for it to stay on for 20-30secs then move back down off screen.

       

      The code I'm using is this:

       

      // Create a movie clip instance.
      this.createEmptyMovieClip("img1_mc", 10);
      var mcl_obj:Object = new Object();
      mcl_obj.onLoadInit = function (target_mc:MovieClip):Void {
          target_mc._y = 110;
          target_mc.onEnterFrame = function() {
              target_mc._y -= 10; // decrease current _y position by 10 pixels
              if (target_mc._y <= 0) {
                  target_mc._y = 0;
                  delete target_mc.onEnterFrame;
              }
          };
      };
      var img_mcl:MovieClipLoader = new MovieClipLoader();
      img_mcl.addListener(mcl_obj);
      // Load an image into the movie clip
      img_mcl.loadClip("flashadd_test_1.png", img1_mc);
      
      close_btn.onRelease = function(){
           img1_mc._y = 110;
           close_btn._y = 110;
      }
      

       

      Any help, ideas or information would be greatly appreciated.

       

      Many thanks

        • 1. Re: Flash popup banner - Help needed
          Ned Murphy Adobe Community Professional & MVP

          Use the setTimeout() function after the object's y value is fixed at zero.  The function it calls could work similarly to what you have for moving it in, just the opposite direction.

          1 person found this helpful
          • 2. Re: Flash popup banner - Help needed
            Sprogleg Level 1

            I can't seem to get that working. I'm using it as follows

             

            // Create a movie clip instance.
            
            function closebanner(){
                  target_mc._y += 10;
            }
            
            this.createEmptyMovieClip("img1_mc", 10);
            var mcl_obj:Object = new Object();
            mcl_obj.onLoadInit = function (target_mc:MovieClip):Void {
                target_mc._y = 110;
                target_mc.onEnterFrame = function() {
                    target_mc._y -= 10; // decrease current _y position by 10 pixels
                    if (target_mc._y <= 0) {
                        target_mc._y = 0;
                        delete target_mc.onEnterFrame;
                        setTimeout(closebanner,3000);
                    }
                };
            };
            var img_mcl:MovieClipLoader = new MovieClipLoader();
            img_mcl.addListener(mcl_obj);
            // Load an image into the movie clip
            img_mcl.loadClip("flashadd_test_1.png", img1_mc);
            
            close_btn.onRelease = function(){
                img1_mc._y = 110;
                close_btn._y = 110;
            }
            

            Not sure if this is correct. Tbh I'm not even sure what I should be targeting?

            • 3. Re: Flash popup banner - Help needed
              Ned Murphy Adobe Community Professional & MVP

              If you look at the onEnterFrame function that is created in your onLoadInit function, you should be able to work out a similar solution that steps in the opposite direction.  The only problem being that target_mc is not globally available, so within that onLoadInit function you'll need to assign the target_mc to a variable outside of the function so that it is available to be used by the closing function.

              1 person found this helpful
              • 4. Re: Flash popup banner - Help needed
                Sprogleg Level 1

                Maybe I should have mentioned how limited my use of actionscript was and that I've got this far from basically using code found on the internet.

                 

                To assign target_mc a var outside of the onLoadInit function would I use something like

                 

                var outsideloadtarget_mc = target_mc
                

                 

                would I assign this within the onLoadInit function or outside it?

                 

                I feel more confused but also slightly less confused...

                 

                Thanks for the help soo far

                • 5. Re: Flash popup banner - Help needed
                  Sprogleg Level 1

                  I've managed to get it to work.

                   

                  I called the function within the onLoadInit function like so

                   

                  // Create a movie clip instance.
                  
                  
                  this.createEmptyMovieClip("img1_mc", 10);
                  var mcl_obj:Object = new Object();
                  mcl_obj.onLoadInit = function (target_mc:MovieClip):Void {
                      function closebanner(){
                        target_mc.onEnterFrame = function() {
                          target_mc._y += 10;
                          closebut_mc._y = 150;
                        };
                  }
                      target_mc._y = 110;
                      target_mc.onEnterFrame = function() {
                          target_mc._y -= 10; // decrease current _y position by 10 pixels
                          if (target_mc._y <= 0) {
                              target_mc._y = 0;
                              delete target_mc.onEnterFrame;
                              setTimeout(closebanner,1000);
                          }
                      };
                  };
                  var img_mcl:MovieClipLoader = new MovieClipLoader();
                  img_mcl.addListener(mcl_obj);
                  // Load an image into the movie clip
                  img_mcl.loadClip("flashadd_test_1.png", img1_mc);
                  
                  _root.closebut_mc.close_btn.onRelease = function(){
                      img1_mc._y = 110;
                      closebut_mc._y = 150;
                  }
                  
                  _root.closebut_mc.swapDepths(getNextHighestDepth());
                  

                   

                  You can see it working here set at a 5 second delay for testing purposes.