6 Replies Latest reply on Mar 4, 2009 7:07 PM by Phildo120

    Need Help With Action Script

    Phildo120
      I am creating a flash website and am new to flash.

      I have a movie clip in the site with photos and text loaded in individual frames. I want to add action script to the movie clip so that it fades into a frame, pause for a couple of seconds, then fades out and moves to the next frame. I do not know where to start so any help would be great!
        • 1. Re: Need Help With Action Script
          Ned Murphy Adobe Community Professional & MVP
          Look into using a Tween object to animate the _alpha property as you enter and exit a frame. You can assign a listener to the Tween to have the frame advance after a fade out is complete.
          • 2. Re: Need Help With Action Script
            Level 7
            Tweener or one of the other 3rd party tweening classes is much better than
            the built in classes - which are super slow and cumbersome to use.

            You can get tweener here: http://code.google.com/p/tweener/


            --
            Dave -
            www.offroadfire.com
            Adobe Community Expert
            http://www.adobe.com/communities/experts/


            • 3. Re: Need Help With Action Script
              Phildo120 Level 1
              I have tried your suggestions, but I still need some help. The tween does not seem to work and all the MC does is cycle through the frames at the frame rate. I have placed the following script in each frame containing a new picture and text (note, TEST_SLIDES is the MC containg the images and text):

              import mx.transitions.Tween;
              import mx.transitions.easing.*;

              var fadein:Tween = new Tween(TEST_SLIDES, "_alpha", Regular.easeOut, 1, 100, 1, true);
              var hold:Tween = new Tween(TEST_SLIDES, "_alpha", None.easeOut, 100, 100, 1, true);
              var fadeout:Tween = new Tween(TEST_SLIDES, "_alpha", Regular.easeOut, 100, 1, 1, true);

              fadein.onMotionFinished = function() {
              fadein.stop();
              };

              hold.onMotionFinished = function() {
              hold.stop();
              };

              fadeout.onMotionFinished = function() {
              fadeout.stop()
              TEST_SLIDES.gotoAndPlay.nextFrame();
              };


              • 4. Re: Need Help With Action Script
                Level 7
                I don't use the built in tweening classes so can't be sure but I'd guess
                your problem is that all your tweens run at once. I think you'd want to
                start the hold in the fadeIn.onMotionFinished and then the same for fadeOut
                it'd start in the onMotionFinished for hold. In Tweener you would just use
                two tweens and a delay:

                import caurina.transitions.Tweener;

                TEST_SLIDE._alpha = 0;
                Tweener.addTween(TEST_SLIDE,{_alpha:100, time:1});
                Tweener.addTween(TEST_SLIDE,{_alpha:0, time:1, delay:2});

                --
                Dave -
                www.offroadfire.com
                Adobe Community Expert
                http://www.adobe.com/communities/experts/


                • 5. Re: Need Help With Action Script
                  Level 7
                  Er - missed your TEST_SLIDES.gotoAndPlay.nextFrame(); I don't think that
                  will work - gotoAndPlay is a function, like nextFrame(). You use it like:
                  TEST_SLIDES.nextFrame(); I'm not testing this but I think you could just use
                  that in onComplete like:

                  import caurina.transitions.Tweener;

                  TEST_SLIDE._alpha = 0;
                  Tweener.addTween(TEST_SLIDE,{_alpha:100, time:1});
                  Tweener.addTween(TEST_SLIDE,{_alpha:0, time:1, delay:2,
                  onComplete:TEST_SLIDE.nextFrame});


                  --
                  Dave -
                  www.offroadfire.com
                  Adobe Community Expert
                  http://www.adobe.com/communities/experts/


                  • 6. Re: Need Help With Action Script
                    Phildo120 Level 1
                    Thank you so much for your help , this is working great. I placed the following script on each frame:

                    import caurina.transitions.Tweener;
                    stop();
                    this._alpha = 0;
                    Tweener.addTween(this,{_alpha:100, time:1, transition:"easeInOutSine"});
                    Tweener.addTween(this,{_alpha:0, time:1, delay:8, transition:"easeInOutSine", onComplete:this.nextFrame});

                    The only thins left is when it finishes the last frame, the slide show goes blank. How can I get the slideshow to return to frame 1?