PDA

View Full Version : pressing ENTER key instead of clicking a button in Flash 8..


sirolivern
02-27-2008, 10:47 PM
hello everyone.. good day!

I have i problem with my page flip animation and i have this actionscript for the animation:

prevBtn.onRelease = function() {
var prevPage = _parent.offsetPages(_parent.page-1,_parent.removedPages);
if(prevPage>=-1) _parent.gotoPage(prevPage);
}

nextBtn.onRelease = function() {
var nextPage = _parent.offsetPages(_parent.page+2,_parent.removed Pages);
if(nextPage<=_parent.offsetPages(_parent.maxpage,_parent.remov edPages)) _parent.gotoPage(nextPage);
}

gotoBtn.onRelease = function() {
_parent.gotoPage(Number(pageNum.text)+1);
}


I am using Flash 8. The actionscript runs and do well. What my problem is I want to add the keypress function like when I pressed the ENTER key it will automatically flip the pages and go to the typed page number. ESCAPE for close. RIGHT arrow for next page. LEFT for previous page. I tried this code for ENTER :

pageNum.on (keyPress "<Enter>") {
_parent.gotoPage(Number(pageNum.text)+1);
}

But nothing happens. I knew there something wrong and I can't fix it..
I used flash for 5 years and still do not know all in the functions of actionscript. Specially now, FLASH is under ABODE.. By the way, pageNum is the name for INPUT TEXT.

Please help me on this.. thank you

raskolnikov
03-06-2008, 03:29 AM
i cant fully answer your question, but u can try using the "keyListener" method which could come in handy.

pageTurner = new Object();
pageTurner.onKeyDown = function() {
code = Key.getCode();

trace(code)

};
Key.addListener(pageTurner);

put this on frame 1 in a new file. press "spacebar" for instance and u can see the code for that key (32). somehow pressing "enter" dont work. maybe its a reserved key? i dunno know. good luck

raskol