Copy link to clipboard
Copied
I have a graphic symbol being moved along the X axis programmatically via button press.
How can I limit the movement of that symbol to a certain point on the stage, e.g. along X axis?
I assume I can get the position of the symbol like:
var leftFrame_X = this.LeftFrame.x;
Is that position different from the x position shown in properties?
How would I test for that position and stop the symbol from moving further in that direction?
Like this?
function updateLF_Move_Right(){
if(leftFrame_X != leftFrame_X){
root.LeftFrame.x+=1
} else {
root.LeftFrame.x+=0
}
This is the code I currently have:
this.ButtonLeftFrameMoveRight.addEventListener("mousedown", LF_MoveRight_Down.bind(this));
this.ButtonLeftFrameMoveRight.addEventListener("pressup", LF_MoveRight_Up.bind(this));
var frameLeft = this;
function LF_MoveRight_Down() {
createjs.Ticker.addEventListener("tick",updateLF_Move_Right);
}
function LF_MoveRight_Up() {
createjs.Ticker.removeEventListener("tick",updateLF_Move_Right);
}
function updateLF_Move_Right(){
frameLeft.LeftFrame.x+=1
}
Sorted:
function updateLF_Move_Right(){
if(root.LeftFrame.x <= 597.3){
root.LeftFrame.x+=1;
}
}
function updateLF_Move_Left(){
if(root.LeftFrame.x >= 508.3){
root.LeftFrame.x-=1
}
}
Copy link to clipboard
Copied
That shoul read:
if(leftFrame_X != some pos X){
Copy link to clipboard
Copied
Sorted:
function updateLF_Move_Right(){
if(root.LeftFrame.x <= 597.3){
root.LeftFrame.x+=1;
}
}
function updateLF_Move_Left(){
if(root.LeftFrame.x >= 508.3){
root.LeftFrame.x-=1
}
}