I programmed the following code so that an array of buttons
can be dragged across the screen when either on :
var buttons:Array=[button1, button2, button3];
for (var i:uint=0; i<buttons.length; i++)
buttons[i].addEventListener(MouseEvent.CLICK, alignButtons )
function alignButtons (e:Event)
for (var i2:uint=0; i2<buttons.length; i2++)
for (var i3:uint=0; i3<buttons.length; i3++)
function buttonDrag (e:Event)
It works pretty much how I'd like it to work, except for the fact that I have to click the mouse to update the screen. However, when I change the first event listener from "MouseEvent.CLICK" to "Event.ENTER_FRAME" the code goes haywire. Is there another event listener I should be using here?
Due to what appears to be an incomplete set of curly braces, it is hard to tell how much nesting you have there, but there should be none. Each listener and event handler function should be able to stand on its own. You should not have to put any functions inside a loop.
Having the CLICK event listener is redundant if you have a MOUSE_DOWN and a MOUSE_UP because a MOUSE_DOWN followed by a MOUSE_UP is a CLICK.
If your goal is to have the buttons all follow each other around x-wise, then what you can do is assign a MOUSE_MOVE event listener at the same time you execute the startDrag and use its event handler for adjust button positions. When you stopDrag, you also remove the MOUSE_MOVE listener.
As far as why things go haywire when you change to using an ENTER_FRAME, you should show the code when it is in that form so that whatever error is evident.
Europe, Middle East and Africa