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

A conflict exists with inherited definition

New Here ,
Aug 21, 2019 Aug 21, 2019

An error pops up when im using this code to move a character in one of my games. Im using actionscript and im not sure if this coding is for HTML so it doesn't work. I'm extremely new to coding and your help is very much needed.

"A conflict exists with inherited definition flash.display:DisplayObject.root in namespace public."

var root = this;

document.addEventListener("keydown", handleKeyDown);

function handleKeyDown(event) {

//left and right arrow key

if (event.which == 37 || event.which == 39) {

var newX = root.characterGame.x + (10 * (event.which - 38));

createjs.Tween.get(root.characterGame).to({x: newX}, 1);

}

//up and down arrow key

if (event.which == 38 || event.which == 40) {

var newY = root.characterGame.y + (10 * (event.which - 39));

createjs.Tween.get(root.characterGame).to({y: newY}, 1);

}

}

TOPICS
ActionScript
1.6K
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

LEGEND , Aug 21, 2019 Aug 21, 2019

From what I can see, you should probably avoid trying to create a variable named 'root'.  Actionscript already has an animal by that name.  Either use 'this' or don't even bother using either.  AS3 already understands what 'this' is without having to say so.

Translate
LEGEND ,
Aug 21, 2019 Aug 21, 2019

From what I can see, you should probably avoid trying to create a variable named 'root'.  Actionscript already has an animal by that name.  Either use 'this' or don't even bother using either.  AS3 already understands what 'this' is without having to say so.

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
New Here ,
Aug 21, 2019 Aug 21, 2019
LATEST

Thank you! Is there a variable or edit I could use instead?

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