Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Possible to change frame based on object location?

Engaged ,
Mar 16, 2018 Mar 16, 2018

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.

574
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Mar 22, 2018 Mar 22, 2018

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);

}

}

Translate
Community Expert ,
Mar 17, 2018 Mar 17, 2018

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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Mar 17, 2018 Mar 17, 2018

Something the user does. As in they would be moving the character around with their arrow keys.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 17, 2018 Mar 17, 2018

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).

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Mar 17, 2018 Mar 17, 2018

Ok sorry, I will try that and report back.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Mar 18, 2018 Mar 18, 2018

Is there any chance you could be more specific? I’m new to this.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 18, 2018 Mar 18, 2018

actionscript (swf/mobile) or javascript (canvas)?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Mar 21, 2018 Mar 21, 2018

Javascript, would be eternally grateful.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 22, 2018 Mar 22, 2018
LATEST

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);

}

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines