-
moving problem
Hi,
I am trying to make 2 circles (MC) move with the LEFT arrow after I click on one of them (selecting witch to move)(ex.clic ball1 move it with the key, then click ball2 and move it..). But I can move only one circle, the other it doesn't respond when I click on it. Can you help me with this?
---------ball1
on (press){ sel=1; } on (keyPress "<Left>"){ if(sel==1) this._x = this._x -5 }
---------ball2
on (press){ sel=2; } on (keyPress "<Left>"){ if(sel==2) this._x = this._x -5 }
------------first frame
sel=0
Reply With Quote
-
Re: moving problem
Xara flash animations do not support the same features that are available in Flash or SwishMAX.
What you are wanting to do cannot be done in Xara Xtreme.
NOTE: This thread was originally posted in the Xara Flash forum
-
1 Attachment(s)
Re: moving problem
I'll move this thread to the Flash forum in a couple of days, but as Pops is a new member I'll leave it here at present.
In frame1 put the following code:
Code:
var distance:Number = 2;
this.createTextField("display_txt", 999, 0, 0, 100, 20);
var keyListener:Object = new Object();
keyListener.onKeyDown = function() {
if (Key.isDown(Key.LEFT)) {
if (sel=="ball1") {
ball1_mc._x = Math.max(ball1_mc._x - distance, 0);
} else if (sel=="ball2") {
ball2_mc._x = Math.max(ball2_mc._x - distance, 0);
} else if (sel=="ball3") {
ball3_mc._x = Math.max(ball3_mc._x - distance, 0);
}
display_txt.text = "Left";
} else if (Key.isDown(Key.RIGHT)) {
if (sel=="ball1") {
ball1_mc._x = Math.max(ball1_mc._x + distance, 0);
} else if (sel=="ball2") {
ball2_mc._x = Math.max(ball2_mc._x + distance, 0);
} else if (sel=="ball3") {
ball3_mc._x = Math.max(ball3_mc._x + distance, 0);
}
display_txt.text = "Right";
}
}
Key.addListener(keyListener);
for each MC give them the following code and instance names:
Code:
on (press) {
_root.sel="ball3"
}
That will work fine. Test it below. Click on a ball and use the left right keys.
-
Re: moving problem
Thanks Egg Bramhill , from all the forums where I heve asked this question you are the only one who can give me a complet and working answer.Thanks again.
-
Re: moving problem
Yes I saw your post in ActionScript.org
-
Re: moving problem
One last thing, if I want to make them move on click not on keyPress how should I modifiy the script?
-
Re: moving problem
Hi again, what's "on click" supposed to mean?
-
1 Attachment(s)
Re: moving problem
Actually I have attached my game here so you can see it. The problem is that I want to be able to move both this balls after I select them. I have only managed to make one move, the top on, but I don' t manage to make both move, it's a listener thing, I really don't know how to implement that listener to select my MC here, maybe you can help with this.Thanks .
-
Re: moving problem
pop,
You must be using Flash 9 as I can't open your file, I've only got Flash 8.
Could you save it in Flash 8 and upload it again.
Egg
-
Re: moving problem
Ok I have attached my fla.(You can only move on the black squares,, I am trying to make a game like this http://pc.gamezone.com/gamesell/p17418.htm but I can't get the moving part right).