mrpickle
2010-08-19 16:30:15
So, I've started AS3 just about 1 month ago.
I want the user to be able to click and hold down the mouse anywhere on the screen, and a ball will appear. As the user keeps holding down the ball will grow bigger without moving. As the ball reaches max size, it will simply hold that position.
Ball can drop anytime after it has been created, but only when the user lets go of the mouse button.
Source DL: http://www.mediafire.com/?xvd24wjk2zb3zsg
Compiled DL:http://www.mediafire.com/?1hdafc7wrvtb1md
So the problem I have is that the Ball drops automatically when max size is reached when there is NO code that tells it to. I tried debugging with tracing, and it actually holds at the Max size for split second before just dropping.
Yes, I do prefer to ask here rather than the actual AS sites xD.
I want the user to be able to click and hold down the mouse anywhere on the screen, and a ball will appear. As the user keeps holding down the ball will grow bigger without moving. As the ball reaches max size, it will simply hold that position.
Ball can drop anytime after it has been created, but only when the user lets go of the mouse button.
Source DL: http://www.mediafire.com/?xvd24wjk2zb3zsg
Compiled DL:http://www.mediafire.com/?1hdafc7wrvtb1md
//mrpickle needz help! It auto drops ball when reach max size. + it drops really fast (only @ max size)
// You'll have to manually create and linkage 2 movieClips named (Boulder, RandomSymbol) to make it work
import flash.display.Sprite;
import flash.events.Event;
import flash.display.IBitmapDrawable;
import flash.text.TextField;
var mainBall:Boulder = new Boulder();
var rS:RandomSymbol = new RandomSymbol();
var rSizeNow,mX,mY,gravUpdate:int = 0;
const maxBoulderSizeNow = 55;
const gravity = 9.8;
stage.addEventListener(MouseEvent.MOUSE_DOWN, createBall);
stage.addEventListener(MouseEvent.MOUSE_UP,dropBoulder);
function createBall(event:MouseEvent):void
{
trace("1");
//
mX = mouseX;
mY = mouseY;
rS.x = mX;
rS.y = mY;
addChild(rS);
stage.addEventListener(Event.ENTER_FRAME,doCreateBall);
}
function doCreateBall(event:Event):void
{
trace("2");
if (rSizeNow <= maxBoulderSizeNow)
{
rSizeNow = rSizeNow + 1;
mainBall.x = mX;
mainBall.y = mY;
mainBall.width = 40 + rSizeNow;
mainBall.height = 40 + rSizeNow;
addChild(mainBall);
}
else if (rSizeNow > maxBoulderSizeNow)
{
addChild(mainBall);
}
}
function dropBoulder(event:MouseEvent):void
{
stage.removeEventListener(Event.ENTER_FRAME,doCreateBall);
rSizeNow = 0;
stage.addEventListener(Event.ENTER_FRAME,doDropBoulder);
gravUpdate = 0;
}
function doDropBoulder(event:Event):void
{
trace("4");
gravUpdate = gravUpdate + (gravity^2)/10;
mainBall.y = mainBall.y + gravUpdate;
}
//}
So the problem I have is that the Ball drops automatically when max size is reached when there is NO code that tells it to. I tried debugging with tracing, and it actually holds at the Max size for split second before just dropping.
Yes, I do prefer to ask here rather than the actual AS sites xD.