PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197
start, stop motion tweens with keyboard event (powerpoint style)
A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: start, stop motion tweens with keyboard event (powerpoint style)

  1. #1
    Junior Member
    Join Date
    Jul 2011
    Posts
    2

    start, stop motion tweens with keyboard event (powerpoint style)

    Hi everyone,
    i've been looking around for answers to my problem to no avail.
    What I want to do is create a powerpoint style presentation.
    But rather than change slides, I have one large "graphic" that I am moving around and zooming into by "motion tweening"
    Now all I need to do is:
    (with a keyboard event)
    start the motion tween and then let it play out
    then start the next motion tween and let it play out
    and so on...

    all i have is this, which allows me to start and stop it when it is tweening, but isn't as effective as it stopping at then end of a motion tween, then allowing me to push a key and for it to go to the next "slide"

    Code:
    stop();
    var isPlaying:Boolean = false;
     
    stage.addEventListener(KeyboardEvent.KEY_UP, keyUsed);
     
    function keyUsed(event:KeyboardEvent)
    {
    if (isPlaying){
              stop();
         } else {
              play();
         }
      
      isPlaying = !isPlaying;
    }
    thanks everyone!

  2. #2
    Senior Member
    Join Date
    May 2010
    Location
    Russia: Western Siberia
    Posts
    268
    Ok, let's say you know exactly the width of your slides, and they all the same.
    I suppose they're all added in a row, like so:
    Actionscript Code:
    var w:int            = 500; // width of the slide
    var numSlides:int = 20;   // number of slides
    var slideContainer:Sprite = new Sprite();
    stage.addChild(slideContainer);

    for (var i:int =0; i < numSlides; i++) {
            var slide:Slide = new Slide();
            slide.x           = i * w;                // adding all slides in a row
            slideContainer.addChild(slide);
    }
    stage.addEventListener(KeyboardEvent.KEY_UP, onKeyUp);
    function onKeyUp(e:KeyboardEvent):void {
           if (slideContainer % w != 0) return;             // check if container has finished movement, before letting in move again
           if (e.keyCode == Keyboard.LEFT) {        
                   Tweener.addTween(slideContainer, { x: x - w, time: 2, transition: "easeInExpo"} );
           } else  if (e.keyCode == Keyboard.RIGHT) {
                   Tweener.addTween(slideContainer, { x: x + w, time: 2, transition: "easeInExpo"} );
           }
    }

    This example uses caurina tweener engine. You can use greensock or something else, idk.
    Cheers

  3. #3
    Junior Member
    Join Date
    Jul 2011
    Posts
    2
    hi caseyryan,

    instead of lots of separate slides, i have one large graphic, that will look like I am panning and zooming into as I press each key to change "slide"!

    the option you gave isn't quite what i was looking for, thanks anyway.

  4. #4
    Senior Member
    Join Date
    May 2010
    Location
    Russia: Western Siberia
    Posts
    268
    It doesn't really matter. You can move one big slide around just as easily. Using the same approach. I just gave you an idea of what you can do.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center