icutenewb
09-22-2009, 03:13 AM
All right, I'm making a game and I have the 1st frame with this code:
stop();
Mouse.hide();
stage.addEventListener(MouseEvent.CLICK, startPlaying);
function startPlaying (e:MouseEvent):void {
gotoAndPlay("game");
}
And the second frame (labeled "game") with this code:
stop();
Mouse.hide();
var mc1x:Number = -3;
var mc1y:Number = -3;
var mc2x:Number = 3;
var mc2y:Number = -3;
var mc3x:Number = -3;
var mc3y:Number = 3;
var mc4x:Number = 3;
var mc4y:Number = 3;
stage.addEventListener(Event.ENTER_FRAME, enterFrameHandler);
stage.addEventListener(Event.ENTER_FRAME, mcHandler);
function enterFrameHandler (e:Event):void {
polyMouse.x = mouseX;
polyMouse.y = mouseY;
polyMouse.rotation += 3;
}
function mcHandler (e:Event):void {
//mc1 movement
mc1_mc.x += mc1x;
mc1_mc.y += mc1y;
if (mc1_mc.hitTestObject(s1)) {
mc1x = 3;
}
if (mc1_mc.hitTestObject(s2)) {
mc1x = -3;
}
if (mc1_mc.hitTestObject(s3)) {
mc1y = 3;
}
if (mc1_mc.hitTestObject(s4)) {
mc1y = -3;
}
//mc2 movement
mc2_mc.x += mc2x;
mc2_mc.y += mc2y;
if (mc2_mc.hitTestObject(s1)) {
mc2x = 3;
}
if (mc2_mc.hitTestObject(s2)) {
mc2x = -3;
}
if (mc2_mc.hitTestObject(s3)) {
mc2y = 3;
}
if (mc2_mc.hitTestObject(s4)) {
mc2y = -3;
}
//mc3 movement
mc3_mc.x += mc3x;
mc3_mc.y += mc3y;
if (mc3_mc.hitTestObject(s1)) {
mc3x = 3;
}
if (mc3_mc.hitTestObject(s2)) {
mc3x = -3;
}
if (mc3_mc.hitTestObject(s3)) {
mc3y = 3;
}
if (mc3_mc.hitTestObject(s4)) {
mc3y = -3;
}
//mc4 movement
mc4_mc.x += mc4x;
mc4_mc.y += mc4y;
if (mc4_mc.hitTestObject(s1)) {
mc4x = 3;
}
if (mc4_mc.hitTestObject(s2)) {
mc4x = -3;
}
if (mc4_mc.hitTestObject(s3)) {
mc4y = 3;
}
if (mc4_mc.hitTestObject(s4)) {
mc4y = -3;
}
}
My problem is when, while I'm playing on the second frame, I click, it brings back up the first frame and when I click again it restarts everything.. I don't want anything to happen when I click right now because it will disrupt gameplay. Any tips on how to fix it?
If you need any more info just ask.
Please and thank you ^.^
stop();
Mouse.hide();
stage.addEventListener(MouseEvent.CLICK, startPlaying);
function startPlaying (e:MouseEvent):void {
gotoAndPlay("game");
}
And the second frame (labeled "game") with this code:
stop();
Mouse.hide();
var mc1x:Number = -3;
var mc1y:Number = -3;
var mc2x:Number = 3;
var mc2y:Number = -3;
var mc3x:Number = -3;
var mc3y:Number = 3;
var mc4x:Number = 3;
var mc4y:Number = 3;
stage.addEventListener(Event.ENTER_FRAME, enterFrameHandler);
stage.addEventListener(Event.ENTER_FRAME, mcHandler);
function enterFrameHandler (e:Event):void {
polyMouse.x = mouseX;
polyMouse.y = mouseY;
polyMouse.rotation += 3;
}
function mcHandler (e:Event):void {
//mc1 movement
mc1_mc.x += mc1x;
mc1_mc.y += mc1y;
if (mc1_mc.hitTestObject(s1)) {
mc1x = 3;
}
if (mc1_mc.hitTestObject(s2)) {
mc1x = -3;
}
if (mc1_mc.hitTestObject(s3)) {
mc1y = 3;
}
if (mc1_mc.hitTestObject(s4)) {
mc1y = -3;
}
//mc2 movement
mc2_mc.x += mc2x;
mc2_mc.y += mc2y;
if (mc2_mc.hitTestObject(s1)) {
mc2x = 3;
}
if (mc2_mc.hitTestObject(s2)) {
mc2x = -3;
}
if (mc2_mc.hitTestObject(s3)) {
mc2y = 3;
}
if (mc2_mc.hitTestObject(s4)) {
mc2y = -3;
}
//mc3 movement
mc3_mc.x += mc3x;
mc3_mc.y += mc3y;
if (mc3_mc.hitTestObject(s1)) {
mc3x = 3;
}
if (mc3_mc.hitTestObject(s2)) {
mc3x = -3;
}
if (mc3_mc.hitTestObject(s3)) {
mc3y = 3;
}
if (mc3_mc.hitTestObject(s4)) {
mc3y = -3;
}
//mc4 movement
mc4_mc.x += mc4x;
mc4_mc.y += mc4y;
if (mc4_mc.hitTestObject(s1)) {
mc4x = 3;
}
if (mc4_mc.hitTestObject(s2)) {
mc4x = -3;
}
if (mc4_mc.hitTestObject(s3)) {
mc4y = 3;
}
if (mc4_mc.hitTestObject(s4)) {
mc4y = -3;
}
}
My problem is when, while I'm playing on the second frame, I click, it brings back up the first frame and when I click again it restarts everything.. I don't want anything to happen when I click right now because it will disrupt gameplay. Any tips on how to fix it?
If you need any more info just ask.
Please and thank you ^.^