-
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!
-
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
-
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.
-
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|