Groups | Blog | Home
all groups > flash actionscript > october 2006 >

flash actionscript : Controlling a MC with another MC


pindus
10/15/2006 4:41:55 PM
Hi,

I've created a rectangle and converted it into a MC. I named the MC 'map'.

I have then created 6 small mc:s (right, left, up, down, zoomOut, zoomIn)

I've added the following code to each of the small MC:s. Modified for each of
the functions. The problem is, if I add the code to two mc:s it's no longer
working. And how do I get the big MC to move continiously while holding the
mousebutton down? Right now I have to click everytme I want to move it.

Does anyone know how to fix, or maybe a page where I can read more?

Thanx for any help. I'm stuck, and can't find anything about this on the net.
Although it's probably very simple.



onClipEvent(enterFrame){
this.onMouseDown = function() {
this._parent.map._y = this._parent.map._y -1;
};
}
kglad
10/15/2006 5:22:34 PM
mouseDown methods execute whenever the left mouse button is pressed no matter
where the mouse pointer is located (assuming flash has focus).

you want to use an on(press) handler and initiate a loop that continues to
execute until an on(release,releaseOutside) is detected, at which point you'll
want to terminate your loop.
pindus
10/15/2006 7:03:14 PM
I tried now with a loop. But it moves too fast. I tried to set the increase to
0.01, but then nothing happens.

on (press){
for (i=0; i<500;i++){
this._parent.map._y = this._parent.map._y + 0.1;
}
}

I also tried with the release handler, but it's not allowed. =(

on (press){
for (i=0; i<500;i++){
this._parent.map._y = this._parent.map._y + 0.01;
this.onRelease() = function {
break;
}
}
}

I'm a newbee to all this and I understand it's basic, but I just can't work it
out..
kglad
10/15/2006 11:35:03 PM
AddThis Social Bookmark Button