Hello,
I’m trying to display one of buttons from the array randomly to the screen when the ‘space bar’ is pressed in the according square.
I have a feeling it could be something to do with the parent class but not sure.
My current code shown below navigates a character around the area and performs a hit test when in a correct square. Thanks for help
onClipEvent(enterFrame){
dx = Key.isDown(Key.RIGHT)-Key.isDown(Key.LEFT)
dy = Key.isDown(Key.DOWN)-Key.isDown(Key.UP)
if (d=(dy*3)+dx) gotoAndStop(d+15)
else if (_currentFrame > 10) gotoAndStop(_currentFrame-10)
prevx=_x; prevy=_y
l = obstacles.length
_x = Math.min(Math.max(_x+vx*dx, bounds.L), bounds.R)
for(i=0;i<l;i++) if (obstacles.hitTest(_x,_y,true)){_x = prevx; break;}
_y = Math.min(Math.max(_y+vy*dy, bounds.T), bounds.B)
for(i=0;i<l;i++) if (obstacles.hitTest(_x,_y,true)){_y = prevy; break;}
if (_currentFrame > 10 && _x == prevx && _y == prevy) gotoAndStop(_currentFrame-10)
}
onClipEvent(load){
vy = vx = 8
bounds = {L:0,R:1012,T:0,B:767}
obstacles = [_parent.clip1, _parent.clip2, _parent.clip3]
_parent.chest._visible = false;
_parent.boot._visible = false;
_parent.bones._visible = false;
_parent.hole._visible = false;
_parent.fish._visible = false;
_parent.inst_bubble._visible = false;
_parent.quit_bubble._visible = false;
//create array of buttons
myButtons = [chest,boot,bones,hole,fish];
}
onClipEvent(enterFrame){
if(this.hitTest("_root.square1"
){
if(Key.isDown(Key.SPACE)){_root[myButtons[boot]]._visible=true;
//Randomly pick out button from array and display to screen
myButtons[Math.random(myButtons.length)]._visible = true;
Hello,
I’m trying to display one of buttons from the array randomly to the screen when the ‘space bar’ is pressed in the according square.
I have a feeling it could be something to do with the parent class but not sure.
My current code shown below navigates a character around the area and performs a hit test when in a correct square. Thanks for help
onClipEvent(enterFrame){
dx = Key.isDown(Key.RIGHT)-Key.isDown(Key.LEFT)
dy = Key.isDown(Key.DOWN)-Key.isDown(Key.UP)
if (d=(dy*3)+dx) gotoAndStop(d+15)
else if (_currentFrame > 10) gotoAndStop(_currentFrame-10)
prevx=_x; prevy=_y
l = obstacles.length
_x = Math.min(Math.max(_x+vx*dx, bounds.L), bounds.R)
for(i=0;i<l;i++) if (obstacles.hitTest(_x,_y,true)){_x = prevx; break;}
_y = Math.min(Math.max(_y+vy*dy, bounds.T), bounds.B)
for(i=0;i<l;i++) if (obstacles.hitTest(_x,_y,true)){_y = prevy; break;}
if (_currentFrame > 10 && _x == prevx && _y == prevy) gotoAndStop(_currentFrame-10)
}
onClipEvent(load){
vy = vx = 8
bounds = {L:0,R:1012,T:0,B:767}
obstacles = [_parent.clip1, _parent.clip2, _parent.clip3]
_parent.chest._visible = false;
_parent.boot._visible = false;
_parent.bones._visible = false;
_parent.hole._visible = false;
_parent.fish._visible = false;
_parent.inst_bubble._visible = false;
_parent.quit_bubble._visible = false;
//create array of buttons
myButtons = [chest,boot,bones,hole,fish];
}
onClipEvent(enterFrame){
if(this.hitTest("_root.square1"
){
if(Key.isDown(Key.SPACE)){_root[myButtons[boot]]._visible=true;
//Randomly pick out button from array and display to screen
myButtons[Math.random(myButtons.length)]._visible = true;
I’m trying to display one of buttons from the array randomly to the screen when the ‘space bar’ is pressed in the according square.
I have a feeling it could be something to do with the parent class but not sure.
My current code shown below navigates a character around the area and performs a hit test when in a correct square. Thanks for help
onClipEvent(enterFrame){
dx = Key.isDown(Key.RIGHT)-Key.isDown(Key.LEFT)
dy = Key.isDown(Key.DOWN)-Key.isDown(Key.UP)
if (d=(dy*3)+dx) gotoAndStop(d+15)
else if (_currentFrame > 10) gotoAndStop(_currentFrame-10)
prevx=_x; prevy=_y
l = obstacles.length
_x = Math.min(Math.max(_x+vx*dx, bounds.L), bounds.R)
for(i=0;i<l;i++) if (obstacles.hitTest(_x,_y,true)){_x = prevx; break;}
_y = Math.min(Math.max(_y+vy*dy, bounds.T), bounds.B)
for(i=0;i<l;i++) if (obstacles.hitTest(_x,_y,true)){_y = prevy; break;}
if (_currentFrame > 10 && _x == prevx && _y == prevy) gotoAndStop(_currentFrame-10)
}
onClipEvent(load){
vy = vx = 8
bounds = {L:0,R:1012,T:0,B:767}
obstacles = [_parent.clip1, _parent.clip2, _parent.clip3]
_parent.chest._visible = false;
_parent.boot._visible = false;
_parent.bones._visible = false;
_parent.hole._visible = false;
_parent.fish._visible = false;
_parent.inst_bubble._visible = false;
_parent.quit_bubble._visible = false;
//create array of buttons
myButtons = [chest,boot,bones,hole,fish];
}
onClipEvent(enterFrame){
if(this.hitTest("_root.square1"
if(Key.isDown(Key.SPACE)){_root[myButtons[boot]]._visible=true;
//Randomly pick out button from array and display to screen
myButtons[Math.random(myButtons.length)]._visible = true;
Hello,
I’m trying to display one of buttons from the array randomly to the screen when the ‘space bar’ is pressed in the according square.
I have a feeling it could be something to do with the parent class but not sure.
My current code shown below navigates a character around the area and performs a hit test when in a correct square. Thanks for help
onClipEvent(enterFrame){
dx = Key.isDown(Key.RIGHT)-Key.isDown(Key.LEFT)
dy = Key.isDown(Key.DOWN)-Key.isDown(Key.UP)
if (d=(dy*3)+dx) gotoAndStop(d+15)
else if (_currentFrame > 10) gotoAndStop(_currentFrame-10)
prevx=_x; prevy=_y
l = obstacles.length
_x = Math.min(Math.max(_x+vx*dx, bounds.L), bounds.R)
for(i=0;i<l;i++) if (obstacles.hitTest(_x,_y,true)){_x = prevx; break;}
_y = Math.min(Math.max(_y+vy*dy, bounds.T), bounds.B)
for(i=0;i<l;i++) if (obstacles.hitTest(_x,_y,true)){_y = prevy; break;}
if (_currentFrame > 10 && _x == prevx && _y == prevy) gotoAndStop(_currentFrame-10)
}
onClipEvent(load){
vy = vx = 8
bounds = {L:0,R:1012,T:0,B:767}
obstacles = [_parent.clip1, _parent.clip2, _parent.clip3]
_parent.chest._visible = false;
_parent.boot._visible = false;
_parent.bones._visible = false;
_parent.hole._visible = false;
_parent.fish._visible = false;
_parent.inst_bubble._visible = false;
_parent.quit_bubble._visible = false;
//create array of buttons
myButtons = [chest,boot,bones,hole,fish];
}
onClipEvent(enterFrame){
if(this.hitTest("_root.square1"
if(Key.isDown(Key.SPACE)){_root[myButtons[boot]]._visible=true;
//Randomly pick out button from array and display to screen
myButtons[Math.random(myButtons.length)]._visible = true;