Copy link to clipboard
Copied
Hi. If I am moving an object, any sort of object (let's say a drawn layer) using the left and right arrow keys, is it possible to jump to a specified frame based on where that object is? So let's say that I am moving it one frame at a time, can I write some sort of javascript or anything to say "once the object is in this quadrant jump to frame xx"? I want it to be like a video game scenario where users and make the character walk through a door and then have everything jump to a new frame when the character has crossed that threshold.
document.onkeydown = keyF.bind(this);
function keyF(e){
switch(e.keyCode){
case 37:
//move left
break
case 38:
// move up
break
case 39:
// right
break
case 40:
//down
break
}
if(this.obj1.x<x1 && this.obj1.x>x2 && this.obj1.y<y1 && this.obj1.y>y2){
this.gotoAndStop(wherever);
}
}
Copy link to clipboard
Copied
are you asking about something the user does with your finished app (move an object using arrow keys) or something you do while creating your app?
Copy link to clipboard
Copied
Something the user does. As in they would be moving the character around with their arrow keys.
Copy link to clipboard
Copied
use an if-statement (in your key listener) checking the object's position.
p.s. your question is baffling because you're asking about the most basic actionscript (goto) and not asking about more complicated actionscript (moving an object with arrow keys).
Copy link to clipboard
Copied
Ok sorry, I will try that and report back.
Copy link to clipboard
Copied
Is there any chance you could be more specific? I’m new to this.
Copy link to clipboard
Copied
actionscript (swf/mobile) or javascript (canvas)?
Copy link to clipboard
Copied
Javascript, would be eternally grateful.
Copy link to clipboard
Copied
document.onkeydown = keyF.bind(this);
function keyF(e){
switch(e.keyCode){
case 37:
//move left
break
case 38:
// move up
break
case 39:
// right
break
case 40:
//down
break
}
if(this.obj1.x<x1 && this.obj1.x>x2 && this.obj1.y<y1 && this.obj1.y>y2){
this.gotoAndStop(wherever);
}
}
Find more inspiration, events, and resources on the new Adobe Community
Explore Now