   Selection Code in Actionscript 3
  Hello, I'm learning develop in actionscript 3(I know something already :P), well, I tried to make a selection, like when you press the left button on mouse and move it than create a selection. I need it on actionscript, can someone or give me a example of a code, or some tips for me? Thanks   
  Moved to For Beginners.   ;  See selection methods: TextField;  Hi, I would gladly like to help you but you doesn't really offer much info so it's hard for me to do that.I mean, it could be an RTS-game where you select soldiers, a texteditor where you select some characters, a desktop where you select icons...Be specific and detailed!   ;  ok I am sorry I didn't make the idea clear, thanks Wan, but this isn't the selection that I want, sorry about the mistake.AJirenius, well, will be like a rts-game where I select soldiers, I need this kind of selection thanks.   ;Quote:Original post by j_johnnypok I am sorry I didn't make the idea clear, thanks Wan, but this isn't the selection that I want, sorry about the mistake.Okay, never mind. [smile]   ;  Can you specify whether you are using MovieClips/Sprites?I only ask because in my Flash games I use abstract "GameObjects" instead that supply renderdata to the RenderManager, where it uses copyPixels (where possible) for massively better performance.Anyway...the principle doesn't change much, but superficially the code would be very different.Basically, when the mouse is first clicked, store the x,y location. Set a boolean flag that the mouse is down, so that your per-frame function (whether it's an update() method or an enterFrame listener) can do appropriate marquee display. Every frame, update the current x,y & display based on bound/rect created by the two pairs of coordinates. You would til the mouse is released before calculating which units are included (I would think), or maybe not. In any case, you have a rectangle and should easy be able to calculate whether a unit is inside or outside of it.It's hard to know your level of actionscript and exactly which bit you're stuck on with this task.I would not recommend taking a chunk of "marquee-selection" code and dumping it into your project. The principles are very simple and worth learning to the degree that could write them yourself. Otherwise you'll just get stuck at the next point, and then the next again...look for tutorials on mouse dragging in AS3 - as these will contain everything you need, primarily these two things:addEventListener(MouseEvent.MOUSE_DOWN,myMouseDownFunction);addEventListener(MouseEvent.MOUSE_UP,myMouseUpFunction);   