Or this tested and functionnal...
//Init before the onEnterFrame
var Move:Number = 5;//Could be modified via a control
var leftEdge:Number = 0;//All the way to the edge
var rightEdge:Number = this.frame._width;//All the way to the edge
this.onEnterFrame = function() {
//Conditions to invert the movement...
if((image._x + image._width) > rightEdge or image._x < leftEdge){
Move = -Move;
}
image._x += Move;
}
martin schioeth wrote:
Hi Claudia,
A quick thought. I think this will work.
onEnterFrame:
var leftEdge = 0;
var rightEdge = image._width – frame._width;
var move;
if(image._x >= leftEdge){
move = "left";
}else if(image._x+image._width <= rightEdge){
Move = "right";
}
If(move == "left"){
Image._x -= 5;
}else{
Image._x += 5;
}
-[ flashbordon
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Claudia
Barnal
Sent: 10. januar 2006 13:02
To: [email protected]
Subject: [Flashcoders] Image movement
Hi,
I am stuck with a few logic conditionals for moving an image.
The situation is:
I have an image that is wider than the stage that needs to be moved from
right to left and vice versa when it reaches the end of the image, changing
direction. The image is to use a manual (mouse quided) or an “automatic”
movement.
What I have looks something like this (onEnterFrame):
//var automatic:Boolean;
var leftEdge = 0;
var rightEdge = image._width – frame._width;
if ( image._x <= rightEdge ){
image._x -= 5;
}
if ( image._x >= leftEdge ){
image._x += 5;
}
As you might see, this code doesn’t really work. So the question is, how can
I detect when the image has reached one edge and goes to a “goLeft” or
“goRight” state and won’t change until it has reached the other edge?
Thanks,
Claudia
_________________________________________________________________
The new MSN Search Toolbar now includes Desktop search!
http://toolbar.msn.co.uk/
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
--
===============================================================
Éric Thibault
Programmeur analyste
Réseau de valorisation de l'enseignement
Université Laval, pavillon Félix-Antoine Savard
Québec, Canada
Tel.: 656-2131 poste 18015
Courriel : [EMAIL PROTECTED]
===============================================================
Avis relatif à la confidentialité / Notice of Confidentiality / Advertencia de
confidencialidad <http://www.rec.ulaval.ca/lce/securite/confidentialite.htm>
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders