ID:30326
 
I am almost done making a ball in flash that you can throw around and such, but am having trouble with one thing: When you drag it too quickly, and then let go, it dosen't release. It consists of a single movie clip: ball. It is on the stage with the instance name of b, and has the following actions in frame one:

_quality = "MEDIUM";
xSpd = 0;
ySpd = 0;
posX = b._x;
posY = b._y;
grav = 2.1;
bounce = -.75;
radius = b._height/2;
ground = 400;
dragging = false;
oldX = 0;
oldY = 0;
friction = .85;
mouseOutBox = function () {
if (_xmouse>550 || _xmouse<0 || _ymouse<0 || _ymouse>400) {
dragging = false;
stopDrag();
}
};
_root.onEnterFrame = function() {
mouseOutBox();
b.onPress = function() {
startDrag(b, true);
dragging = true;
};
b.onRelease = function() {
stopDrag();
dragging = false;
};
if (dragging == false) {
ySpd += grav;
b._x += xSpd;
b._y += ySpd;
if (b._y+radius>ground) {
b._y = ground-radius;
ySpd *= bounce;
xSpd *= friction;
}
if (b._y+radius<0) {
b._y = -radius;
ySpd *= bounce;
}
if (b._x+radius>550) {
b._x = 550-radius;
xSpd *= bounce;
}
if (b._x-radius<0) {
b._x = radius;
xSpd *= bounce;
}
} else {
oldX = posX;
oldY = posY;
posX = b._x;
posY = b._y;
xSpd = (b._x-oldX)/2;
ySpd = (b._y-oldY)/2;
}
};

If someone can help me with this (especially someone sexy like Elly or DC), it would be much appreciated.
Answer my question and I'll try to answer yours :D

http://members.byond.com/Spade489/forum?id=161&view=0

Applying for a job right now, though >_>
ever heard of tabs?
Are we on the same page? I'm talking about Flash.

Edit: Oh, you mean the format of the code. Thats just how it got cropped in the comment. I actually have it tabbed and formatted nicely in the .fla. You can copy-paste into the .fla and auto-format it.
Can you put it in dm tags.
Right-o.
Hmmmm. Ok, first, I assume "b" is the ball MovieClip?

Try putting a "trace("<3");" under b.onRelease and see if it's still being called in the case you mentioned. Also, when you move it really fast, are you making sure to stay within the box? If not, try placing a trace under mouseOutBox and check that it's being called correctly.
Oh, and here's a new "Flashy" CSS :D

http://members.byond.com/DarkCampainger/files/spadeflash.css
http://members.byond.com/DarkCampainger/files/redgrad.png

Oh, and sorry about the tiny touch of red... I think I got carried away >_>
What DC said. Also what frame rate are you running the animation at? I'm not sure if it'd be relevent but uh, it might.
b.onPress = function() {
startDrag(b, true);
dragging = true;
};
b.onRelease = function() {
stopDrag();
dragging = false;
};


I'm fairly sure those functions only need to be applied once, not every frame. Do it once when the ball is created.
About the frame rate, since its just a test with the ball and nothing else, I used 50 fps. Problem diagnosed. I found out that the onRelease isn't called when I move too fast by using trace. Any ideas on how to resolve this?

And thanks for the CSS DC. <333333333333333333333333
Spade489 wrote:
About the frame rate, since its just a test with the ball and nothing else, I used 50 fps. Problem diagnosed. I found out that the onRelease isn't called when I move too fast by using trace. Any ideas on how to resolve this?

Try what Elation said. Defining the function every iteration may be causing some lag between its being called. If that doesn't work, we'll probably have to look for a work around.


And thanks for the CSS DC. <333333333333333333333333

You're welcome <333333333333333333333333333

P.S. If you actually want the background that I included, you need to change the url from './Spade489/files/redgrad.png' to '/Spade489/files/redgrad.png' in the css (It's like the third line) >_>
Wouldn't I need to upload the file to my hosted files then? If so, can you e-mail it to me? [email protected]