Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Bouncing ball as navigational button

Status
Not open for further replies.

exphtur

Technical User
Jul 23, 2003
23
IE
I have a number of bouncing balls that I want to use as navigational buttons. At the moment I have an on(release) event on each ball which brings the user to the relevant page, the problem is that sometimes the way the balls fall they can be behind or in the way of other balls, you can move them and throw them around but if you move the ball in front of the one you want to get at, you get taken to this balls link. Is there any other events I could use, for instance that you have to double click to go to the link ?

Thanks in advance
 
One solution would be to have the bouncing balls collide, perhaps. This prevents any link overlap. And the user is not put in the dark on how to link.

There are two possible problems with changing how the links work.

1) Modifying linking behavior stupefies and confuses the untrained user. Their previous windows/webpage experiences tell them that single-clicking does the linking. As a result,

2) You have to somehow tell new users on how to link the new way.

Keep in mind, these issues are only as important as the size of your target audience.

Hope that helps.
Mike
 
Many thanks for your reply, I would love to be able to have the balls collide with each other, unfortunately my scripting is not that great, any suggestion on how I might make this happen. Each ball has three frames of script as seen below. Any help on this would be sincerely appreciated !


************ Frame 1 ********************
//Set the bounds
bounds = new Object();
bounds.left = 50;
bounds.right = 730;
bounds.top = 100;
bounds.bottom = 488;

//Set initial speed vector
speed = new Object();
speed.x = 10;
speed.y = 10;

//Set friction to act on ball
friction = .98;

//Set boolean for drag property
drag = false;

//Gravity and Friction toggle variables
friction_t = true;
gravity_t = true;

************** Frame 2 ***********************
if(drag) {

//If the ball is being dragged, recalculate it's speed
if(old_x <> this._x || old_y <> this._y) {
speed.x = (this._x - old_x) / 4;
speed.y = (this._y - old_y) / 4;
}
old_x = this._x;
old_y = this._y;

} else {

//move ball
this._x += speed.x;
this._y += speed.y;

//Check bounds
if(this._x < bounds.left) {
speed.x *= -1;
this._x = bounds.left;
} else if(this._x > bounds.right) {
speed.x *= -1;
this._x = bounds.right;
} else if(this._y < bounds.top) {
speed.y *= -1;
this._y = bounds.top;
} else if(this._y > bounds.bottom) {
speed.y *= -1;
this._y = bounds.bottom;
}

if(friction_t) {
//apply friction to horizontal plain
speed.x *= friction;

//apply y friction if gravity is off
if(!gravity_t){
speed.y *= friction;
}
}

if(gravity_t) {
//apply gravity to vertical plain
if(speed.y > 0){
speed.y *= 1.3;
} else if(speed.y < 0){
speed.y *= .68;
}

if((speed.y < 2) && (speed.y > -2) && (this._y < (bounds.bottom - 2))) {
speed.y = 2;
}

if((speed.y == 2) && (this._y > (bounds.bottom - 3))) {
speed.y = 0;
this._y = bounds.bottom;
}
}

}

********************* Frame 3 *******************
 
Many thanks for your reply, I would love to be able to have the balls collide with each other, unfortunately my scripting is not that great, any suggestion on how I might make this happen. Each ball has three frames of script as seen below. Any help on this would be sincerely appreciated !


************ Frame 1 ********************
//Set the bounds
bounds = new Object();
bounds.left = 50;
bounds.right = 730;
bounds.top = 100;
bounds.bottom = 488;

//Set initial speed vector
speed = new Object();
speed.x = 10;
speed.y = 10;

//Set friction to act on ball
friction = .98;

//Set boolean for drag property
drag = false;

//Gravity and Friction toggle variables
friction_t = true;
gravity_t = true;

************** Frame 2 ***********************
if(drag) {

//If the ball is being dragged, recalculate it's speed
if(old_x <> this._x || old_y <> this._y) {
speed.x = (this._x - old_x) / 4;
speed.y = (this._y - old_y) / 4;
}
old_x = this._x;
old_y = this._y;

} else {

//move ball
this._x += speed.x;
this._y += speed.y;

//Check bounds
if(this._x < bounds.left) {
speed.x *= -1;
this._x = bounds.left;
} else if(this._x > bounds.right) {
speed.x *= -1;
this._x = bounds.right;
} else if(this._y < bounds.top) {
speed.y *= -1;
this._y = bounds.top;
} else if(this._y > bounds.bottom) {
speed.y *= -1;
this._y = bounds.bottom;
}

if(friction_t) {
//apply friction to horizontal plain
speed.x *= friction;

//apply y friction if gravity is off
if(!gravity_t){
speed.y *= friction;
}
}

if(gravity_t) {
//apply gravity to vertical plain
if(speed.y > 0){
speed.y *= 1.3;
} else if(speed.y < 0){
speed.y *= .68;
}

if((speed.y < 2) && (speed.y > -2) && (this._y < (bounds.bottom - 2))) {
speed.y = 2;
}

if((speed.y == 2) && (this._y > (bounds.bottom - 3))) {
speed.y = 0;
this._y = bounds.bottom;
}
}

}

********************* Frame 3 *******************
Many thanks for your reply, I would love to be able to have the balls collide with each other, unfortunately my scripting is not that great, any suggestion on how I might make this happen. Each ball has three frames of script as seen below. Any help on this would be sincerely appreciated !


************ Frame 1 ********************
//Set the bounds
bounds = new Object();
bounds.left = 50;
bounds.right = 730;
bounds.top = 100;
bounds.bottom = 488;

//Set initial speed vector
speed = new Object();
speed.x = 10;
speed.y = 10;

//Set friction to act on ball
friction = .98;

//Set boolean for drag property
drag = false;

//Gravity and Friction toggle variables
friction_t = true;
gravity_t = true;

************** Frame 2 ***********************
if(drag) {

//If the ball is being dragged, recalculate it's speed
if(old_x <> this._x || old_y <> this._y) {
speed.x = (this._x - old_x) / 4;
speed.y = (this._y - old_y) / 4;
}
old_x = this._x;
old_y = this._y;

} else {

//move ball
this._x += speed.x;
this._y += speed.y;

//Check bounds
if(this._x < bounds.left) {
speed.x *= -1;
this._x = bounds.left;
} else if(this._x > bounds.right) {
speed.x *= -1;
this._x = bounds.right;
} else if(this._y < bounds.top) {
speed.y *= -1;
this._y = bounds.top;
} else if(this._y > bounds.bottom) {
speed.y *= -1;
this._y = bounds.bottom;
}

if(friction_t) {
//apply friction to horizontal plain
speed.x *= friction;

//apply y friction if gravity is off
if(!gravity_t){
speed.y *= friction;
}
}

if(gravity_t) {
//apply gravity to vertical plain
if(speed.y > 0){
speed.y *= 1.3;
} else if(speed.y < 0){
speed.y *= .68;
}

if((speed.y < 2) && (speed.y > -2) && (this._y < (bounds.bottom - 2))) {
speed.y = 2;
}

if((speed.y == 2) && (this._y > (bounds.bottom - 3))) {
speed.y = 0;
this._y = bounds.bottom;
}
}

}

********************* Frame 3 *******************
Many thanks for your reply, I would love to be able to have the balls collide with each other, unfortunately my scripting is not that great, any suggestion on how I might make this happen. Each ball has three frames of script as seen below. Any help on this would be sincerely appreciated !


************ Frame 1 ********************
//Set the bounds
bounds = new Object();
bounds.left = 50;
bounds.right = 730;
bounds.top = 100;
bounds.bottom = 488;

//Set initial speed vector
speed = new Object();
speed.x = 10;
speed.y = 10;

//Set friction to act on ball
friction = .98;

//Set boolean for drag property
drag = false;

//Gravity and Friction toggle variables
friction_t = true;
gravity_t = true;

************** Frame 2 ***********************
if(drag) {

//If the ball is being dragged, recalculate it's speed
if(old_x <> this._x || old_y <> this._y) {
speed.x = (this._x - old_x) / 4;
speed.y = (this._y - old_y) / 4;
}
old_x = this._x;
old_y = this._y;

} else {

//move ball
this._x += speed.x;
this._y += speed.y;

//Check bounds
if(this._x < bounds.left) {
speed.x *= -1;
this._x = bounds.left;
} else if(this._x > bounds.right) {
speed.x *= -1;
this._x = bounds.right;
} else if(this._y < bounds.top) {
speed.y *= -1;
this._y = bounds.top;
} else if(this._y > bounds.bottom) {
speed.y *= -1;
this._y = bounds.bottom;
}

if(friction_t) {
//apply friction to horizontal plain
speed.x *= friction;

//apply y friction if gravity is off
if(!gravity_t){
speed.y *= friction;
}
}

if(gravity_t) {
//apply gravity to vertical plain
if(speed.y > 0){
speed.y *= 1.3;
} else if(speed.y < 0){
speed.y *= .68;
}

if((speed.y < 2) && (speed.y > -2) && (this._y < (bounds.bottom - 2))) {
speed.y = 2;
}

if((speed.y == 2) && (this._y > (bounds.bottom - 3))) {
speed.y = 0;
this._y = bounds.bottom;
}
}

}

********************* Frame 3 *******************
Many thanks for your reply, I would love to be able to have the balls collide with each other, unfortunately my scripting is not that great, any suggestion on how I might make this happen. Each ball has three frames of script as seen below. Any help on this would be sincerely appreciated !


************ Frame 1 ********************
//Set the bounds
bounds = new Object();
bounds.left = 50;
bounds.right = 730;
bounds.top = 100;
bounds.bottom = 488;

//Set initial speed vector
speed = new Object();
speed.x = 10;
speed.y = 10;

//Set friction to act on ball
friction = .98;

//Set boolean for drag property
drag = false;

//Gravity and Friction toggle variables
friction_t = true;
gravity_t = true;

************** Frame 2 ***********************
if(drag) {

//If the ball is being dragged, recalculate it's speed
if(old_x <> this._x || old_y <> this._y) {
speed.x = (this._x - old_x) / 4;
speed.y = (this._y - old_y) / 4;
}
old_x = this._x;
old_y = this._y;

} else {

//move ball
this._x += speed.x;
this._y += speed.y;

//Check bounds
if(this._x < bounds.left) {
speed.x *= -1;
this._x = bounds.left;
} else if(this._x > bounds.right) {
speed.x *= -1;
this._x = bounds.right;
} else if(this._y < bounds.top) {
speed.y *= -1;
this._y = bounds.top;
} else if(this._y > bounds.bottom) {
speed.y *= -1;
this._y = bounds.bottom;
}

if(friction_t) {
//apply friction to horizontal plain
speed.x *= friction;

//apply y friction if gravity is off
if(!gravity_t){
speed.y *= friction;
}
}

if(gravity_t) {
//apply gravity to vertical plain
if(speed.y > 0){
speed.y *= 1.3;
} else if(speed.y < 0){
speed.y *= .68;
}

if((speed.y < 2) && (speed.y > -2) && (this._y < (bounds.bottom - 2))) {
speed.y = 2;
}

if((speed.y == 2) && (this._y > (bounds.bottom - 3))) {
speed.y = 0;
this._y = bounds.bottom;
}
}

}

********************* Frame 3 *******************
gotoAndPlay(this._currentframe-1);
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top