5 Replies Latest reply on Mar 1, 2007 7:46 AM by tonyhigham

    delay and cancel delay


      I'm having some trouble delaying single keyframes keyframe in flash.

      I'm making a 5 slide slideshow over 5 frames. Each frame needs to last about 4000ms, although this is flexible.
      BUT the 4000ms delay must be able to be reset when a button is pressed.

      There are 5 buttons on the slideshow allowing a user to return to a previous slide or skip ahead without having to wait.

      However the button when clicked switches frame but does not reset the delay set on the previous keyframe. So the whole slideshow goes out of sync until it just flashs different slides repeatedly. I've tried what I consider to be everything but as I am a novice I could do with the help of a pro.

      The other problem I have which goes hand in hand with the one above is that I need the movie to pause and then resume when the mouse rolls over and rolls out from a particular area i.e. a button. But I have tried setting on rollover stop and on rollout play wtc (I know the syntax is wrong but I used the correct in the fla file) needless to say it doesn't work.

      I have uploaded the fla file to here in case it helps: http://manage.merrions.com/slideshow.zip

      I have attached the function i am using to delay each frame.

      Thanks in advance


        • 1. Re: delay and cancel delay
          tonyhigham Level 1
          OK, this is a little complicated...
          FWIW, I would move your button actions off the buttons since it's not considered best practice, but it's not strictly necessary to make things work.

          First, go to your overButton layer, select frames 2-5, right click, and select 'Clear Keyframes'
          Then, go to your AS layer and in frames 2-5, remove everything in line 2
          Then, on your 5 buttons, change the 'gotoAndPlay' to 'gotoAndStop'
          Also on these buttons, add the following line directly below the 'gotoAndStop'

          On your OverButton, place the following code:


          Lastly, replace all the code on your AS layer, frame 1 with the attached code.

          As I have it, that should make things work the way you want. Like I said before, some parts of the setup are less than ideal, but it will still work the way you intended. Let me know if you have any more questions...
          • 2. Re: delay and cancel delay
            chrissp26 Level 1
            Cool thanks ever so much for your help.

            I shall have a fiddle with it and let you know how I get on.

            Kindest regards

            • 3. Re: delay and cancel delay
              tonyhigham Level 1
              Glad to help. Nothing is more frustrating than knowing exactly what you want, and not being able to get it. ;)
              • 4. delay and cancel delay
                chrissp26 Level 1

                That worked a real treat.

                Would it be possible to transition the frames? (I know I didn't ask this originally so I apologise) but is it possible to use action script to apply an alpha transparency to the imageHolder movie so that at the beginning of the delay it sets the alpha from 0 to 100 and the end it sets it from 100 to 0 over say 200ms? Just so its a little easier on the eyes when then image changes?

                I have set the canvas colour to black so that when the the imageHolder fades, it shows through giving the impression of the transition.

                Could i do something like the example I've written below (I know this doesn't work...but it might help show what I am trying to acheive...?

                Thanks for all your help

                • 5. Re: delay and cancel delay
                  tonyhigham Level 1
                  Got your reply and your message. Looks like I forgot one important line; your resetInterval() function needs an extra line like so:

                  function resetInterval():Void{
                  //this sets up our initial interval,
                  //and also resets it after a rollout on the over button
                  myInterval = setInterval(checkWait,6000)

                  This ensures that the old interval is cleared when one of the numbered buttons is clicked. Seems to work fine now.

                  As for the alpha transition, it's a piece of cake with the Tween class: http://www.actionscript.org/resources/articles/170/1/Flash-MX-2004-Undocumented-TweenEasin g-Classes-Documented/Page1.html

                  I made a new movieclip called Loading that is just a copy of your ImageHolder clip with some static text that says Loading. Put it on the stage and name the instance Loading.

                  Then just change your conditional on frame 1 to:
                  var alphaState:Boolean = false
                  Loading._alpha = 0
                  //create an intervalID var, and call a function to assign it
                  var myInterval:Number

                  and right below that you need this:
                  function doTween():Void{
                  aTween = new mx.transitions.Tween(Loading, "_alpha", mx.transitions.easing.Strong.easeOut, Loading._alpha, 100, 0.25, true)
                  aTween.onMotionFinished = function(){
                  alphaState = !alphaState

                  Then, on frames 2-5, paste this line:

                  And there you have a basic transition that you can dress up however you want.

                  After looking at this file, which allows me to forestall work on my own portfolio ;) , I edited it down to a more sensible arrangement. If you send me another private message with your email address, I can forward it along....

                  Hope this helps! :)