-
1136 error with a KeyboardEvent
I'm trying to add a KeyBoard event in addition to the MouseEvent I already have for my function. So I set up the following code to handle that but it's giving me 1136 errors looking for an argument inside the parenthesis when in reality, it doesn't need one. What to do?
stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyPressed);
function onKeyPressed(evt:KeyboardEvent):void {
switch (evt.keyCode) {
case Keyboard.RIGHT:
slideRight();
break;
case Keyboard.LEFT:
slideLeft();
break;
}
}
Adam Bell
dzign@datatv.com
--
Over 90% of all websites
suck......
Join the minority.
-
Total Universe Mod
You'd have to post the slideRight() and slideLeft() and mouse handler functions and complete error message that are mentioned in your post in order to troubleshoot it. The code you posted is correct.
-
import gs.TweenLite;
import flash.net.navigateToURL;
import flash.net.URLRequest;
import flash.utils.getDefinitionByName;
import flash.events.Event;
import flash.events.KeyboardEvent;
import flash.ui.Keyboard;
var curSlide:MovieClip;
var showingIndex:int=1;
var indexIncrement:int;
var maxSlides:int=33;
rightArrow_btn.addEventListener(MouseEvent.CLICK, slideRight);
leftArrow_btn.addEventListener(MouseEvent.CLICK, slideLeft);
function slideRight(e:Event) {
indexIncrement=1;
if (showingIndex<maxSlides) {
removeCurrent();
}
if (showingIndex==33) {
linkNext();
}
copy_mc.nextFrame();
}
function slideLeft(e:Event) {
indexIncrement=-1;
if (showingIndex>1) {
removeCurrent();
} else if (showingIndex - 1 == 0) {
linkPrev();
}
copy_mc.prevFrame();
}
function removeCurrent() {
showingIndex+=indexIncrement;
TweenLite.to(curSlide, 0.5, {alpha:0, onComplete:showNext});
}
function linkNext() {
navigateToURL(new URLRequest("promotion.html"), '_self');
}
function linkPrev() {
navigateToURL(new URLRequest("identity.html"), '_self');
}
function showNext() {
removeChild(curSlide);
showNextSlide();
}
function showNextSlide():void {
var which="slide"+showingIndex+"_mc";
var classRef:Class=getDefinitionByName(which) as Class;
curSlide = new classRef();
addChild(curSlide);
curSlide.x=250;
curSlide.y=0;
curSlide.alpha=0;
TweenLite.to(curSlide, 0.5, {alpha:1});
}
showNextSlide();//show first slide
stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyPressed);
function onKeyPressed(evt:KeyboardEvent):void {
switch (evt.keyCode) {
case Keyboard.RIGHT:
slideRight();
break;
case Keyboard.LEFT:
slideLeft();
break;
}
}
stop();
Adam Bell
dzign@datatv.com
--
Over 90% of all websites
suck......
Join the minority.
-
Total Universe Mod
in onKeyPressed() your calling slideRight() and slideLeft but not passing the required event param. Just change their signatures to set 'e' param to null by default.
function slideRight(e:Event = null) {
and
function slideLeft(e:Event = null) {
-
Adam Bell
dzign@datatv.com
--
Over 90% of all websites
suck......
Join the minority.
-
Time Out. Found an error. The keyboard event does work. However, not right away. One the first slide in my slideshow if you click either arrow with the keyboard, nothing happens. Now click the right arrow and yes, you get to slide two. Then click on the keyboard left or right arrow. NOW it works! But only after slide one. So how can I make the arrows work on slide one?
Adam Bell
dzign@datatv.com
--
Over 90% of all websites
suck......
Join the minority.
Tags for this Thread
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
|