I'm fairly new to actionscript but I've created a flash presentation and it works great however I need to modify it slightly.
As default if you press the right arrow it goes to the next slide and if you press the left arrow it goes to the previous slide.
I need to change this function to work on pageup and pagedown key press.
I've had a go at doing this myself but the function just repeats over and over and therefore when I press page up it goes rapidly flicks though all the slides until it gets to the end.
Please can someone help. Heres my code:
Code:
onClipEvent(enterFrame){
if (Key.getCode() == Key.PGDN) {
// GoTo Next Screen behavior
var screen = null;
var target = this;
while((screen == null) && (target != undefined) && (target != null))
{
if(target instanceof mx.screens.Screen)
{
screen = target;
}
else
{
target = target._parent;
}
}
if(screen instanceof mx.screens.Slide)
{
screen.rootSlide.currentSlide.gotoNextSlide();
}
// End GoTo Next Screen behavior
}
else if (Key.getCode() == Key.PGUP) {
// GoTo Last Screen behavior
var screen = null;
var target = this;
while((screen == null) && (target != undefined) && (target != null))
{
if(target instanceof mx.screens.Screen)
{
screen = target;
}
else
{
target = target._parent;
}
}
if(screen instanceof mx.screens.Slide)
{
screen.rootSlide.gotoLastSlide();
}
// End GoTo Last Screen behavior
}
}
Hi thanks for the reply I have place the code on the Presentation frame as below, it works with the left and right arrows but not with pageup page down any ideas any help much appreciated:
onClipEvent (enterFrame) {
var keyListener:Object = new Object();
keyListener.onKeyUp = function() {
if (Key.isDown ( Key.PGDN)) {
trace("down");
// GoTo Next Screen behavior
var screen = null;
var target = this;
while((screen == null) && (target != undefined) && (target != null))
{
if(target instanceof mx.screens.Screen)
{
screen = target;
}
else
{
target = target._parent;
}
}
if(screen instanceof mx.screens.Slide)
{
screen.rootSlide.currentSlide.gotoNextSlide();
}
// End GoTo Next Screen behavior
}
if (Key.isDown ( Key.PGUP)) {
trace("up");
// GoTo Last Screen behavior
var screen = null;
var target = this;
while((screen == null) && (target != undefined) && (target != null))
{
if(target instanceof mx.screens.Screen)
{
screen = target;
}
else
{
target = target._parent;
}
}
if(screen instanceof mx.screens.Slide)
{
screen.rootSlide.gotoLastSlide();
}
// End GoTo Last Screen behavior
Sorry, i forgot to tell you, when you Test the movie, go to Control and click on Disable Keyboard shorcuts. If you use the script I gave to you, it should work now.
Ok yes that works, in the sense that in the output window is shows Down or Up when the keys are pressed which is great its further than I have got before, but it dosent move the slides on when I export the swf file any more help is appreciated thanks again
May you post .fla to help you further? The script i gave you works on my side. Instead of going to a slide, i used a trace and it works. The important thing here is that the page up and page down buttons now works. If you can not go to any slide, is not the pageup/pagedown buttons fault. Please post the fla to see how your slide engine works.
screen.rootSlide.gotoLastSlide(); } // End GoTo Last Screen behavior
} }; Key.addListener(keyListener);a
I created 2 frames, put a stop(); on each one, and created a text on stage that reads Slide 1, Slide 2, then in the script i added if (Key.isDown ( Key.PGDN)) { gotoAndStop(2); } and if (Key.isDown ( Key.PGUP)) { gotoAndStop(1); }
And it works. If you press the page down, it goes to frame 2. If you press page up, it goes back to frame 1. That is in the case of using the frames as slides. I don't know how you are creating the slides.
It was done in CS4 on a mac and created: File new > Flash Slide Presentation, I should have done it all on a timeline instead of a presentation but if I can fix it its better than doing the whole thing again as there are about 100 slides
No problem! ^_^ Anything else you want to do with that presentation thing, don't hesistate, inbox me, or just post it here. I never have used the presentation prototype before, i'm just experimenting with it.