12 Replies Latest reply on May 27, 2009 8:02 AM by kglad

    Interesting Preloader Qestion...

    esco1313

      Hey All!

       

      Anyone would have a clue on how to achieve this result using actionscript (not the percent animation, i pretty much figured it out..)? What i mean is the "shaky/blury" effect...

       

      An example of script would be apreciated, since i'm not an expert...

       

      Thanks!!

       

      http://flashden.net/item/nervous-preloader/43007

        • 1. Re: Interesting Preloader Qestion...
          kglad Adobe Community Professional & MVP

          you can do that using the blur filter and momentary changes in the _x or x property of your movieclip textfield.

          • 2. Re: Interesting Preloader Qestion...
            esco1313 Level 1

            ok and i that achievable by actionscript? or do i have to key frames?

            • 3. Re: Interesting Preloader Qestion...
              esco1313 Level 1

              ok so i'm doing a test... so far, i have a sqare called "carre". on the 1st frame, my code:

               

              import flash.filters.BlurFilter;
              import mx.transitions.Tween;
              import mx.transitions.easing.*;

               

              var myTween:Tween = new Tween(carre, "blur", Strong.easeInOut, 0, 20, 1/5, true);

              myTween.onMotionChanged = function() {
                      carre._parent.filters = [new BlurFilter(carre.blur, carre.blur, 1)];
                  };

               

              i want to add a randomness on the blur and position..?

               

              EDIT

               

              ok i've added this code ON my movieCLip. But i dont want it to be on the mc...

               

              onClipEvent (load) {
              cx = this._x;
              cy = this._y;
              }
              onClipEvent (enterFrame) {
              this._x = cx+(1+Math.random()*5);
              this._y = cy+(1+Math.random()*5);
              }

               

              PLUS, it shakes randomly, but with no pause... like i would like it to...

               

              what should i do?

              • 4. Re: Interesting Preloader Qestion...
                esco1313 Level 1

                anyone? ...:(

                • 5. Re: Interesting Preloader Qestion...
                  SvingXD

                  To make it stop all you have to do is add a timer code, something like this onto the script:

                   

                  startTime = getTimer();
                  this.onEnterFrame = function () {
                  currentTime = getTimer();
                  if(currentTime-startTime > 1000) {
                  }
                  }
                  You can change the '1000' value to experiment with different lengths of time, hope that helps.
                  • 6. Re: Interesting Preloader Qestion...
                    kglad Adobe Community Professional & MVP

                    don't attach code to objects.  you can then use:

                     

                    import flash.filters.BlurFilter;
                    import mx.transitions.Tween;
                    import mx.transitions.easing.*;
                    
                    var myTween:Tween = new Tween(carre, "blur", Strong.easeInOut, 0, 20, 1/5, true);
                    
                    myTween.onMotionChanged = function() {
                         carre._parent.filters = [new BlurFilter(carre.blur, carre.blur, 1)];
                    };
                    
                    
                    cx = carre._x;
                    cy = carre._y;
                    
                    carre.onEnterFrame = function() {
                         this._x = cx+(1+Math.random()*5);
                         this._y = cy+(1+Math.random()*5);
                    };
                    
                    // then when you want to stop the shaking use:
                    
                    carre.onEnterFrame = null;
                    
                    1 person found this helpful
                    • 7. Re: Interesting Preloader Qestion...
                      esco1313 Level 1

                      thanks! it works. However, what i meant by stopping the shake was stopping it momentarily. Like in the example. its a random shake in time too...

                      any ideas?

                      • 8. Re: Interesting Preloader Qestion...
                        kglad Adobe Community Professional & MVP

                        when you want the shaking to start call:  startShakeF()

                         

                        when you want the shaking to stop call: stopShakeF()


                         

                        import flash.filters.BlurFilter;
                        import mx.transitions.Tween;
                        import mx.transitions.easing.*;
                        
                        var myTween:Tween = new Tween(carre, "blur", Strong.easeInOut, 0, 20, 1/5, true);
                        
                        myTween.onMotionChanged = function() {
                             carre._parent.filters = [new BlurFilter(carre.blur, carre.blur, 1)];
                        };
                        
                        
                        cx = carre._x;
                        cy = carre._y;
                        
                        function startShakeF(){
                        carre.onEnterFrame = shakeF;
                        }

                        function shakeF() {      this._x = cx+(1+Math.random()*5);      this._y = cy+(1+Math.random()*5); }; // then when you want to stop the shaking use: function stopShakeF(){
                        carre.onEnterFrame = null;
                        }
                        • 9. Re: Interesting Preloader Qestion...
                          esco1313 Level 1

                          ok i think that my description ist clear. What i'm trying to achieve in actionscript: if i had a movieclip, and i animated it so that it would shake for lets say...10 frames, then stop shaking for 20 frames, then shake for hmm..15 frames? then stop for 30 frames... i mean randomly. so whenever it would shake, it would blur (to create motionblur effect) but would shake randomly in time...

                           

                          i want to achieve that with a script. is it possible?

                          • 10. Re: Interesting Preloader Qestion...
                            kglad Adobe Community Professional & MVP

                            yes.  you can use timers to call those two functions when you want.  for example:

                             

                            var startTimer:Timer=new Timer(5000,0);
                            var stopTimer:Timer=new Timer(2500,1);

                            startTimer.addEventListener(TimerEvent.TIMER,startShakeF);

                            startTimer.start();

                            stopTimer.addEventListener(TimerEvent.TIMER.stopShakeF);

                             

                            function startShakeF(e:Event){

                            stopTimer.reset();

                            stopTimer.start();

                            //rest of code

                            .

                            .

                            .

                            }

                            • 11. Re: Interesting Preloader Qestion...
                              esco1313 Level 1

                              AAAAAHHhhhhhhhhhhhhhhh...... i get it.. i'll try that!

                               

                              thanks, ill give you news