ActionScript 3.0 :: Save The Mouse Coordinates Upon MouseClick?
May 20, 2011
I am making a game where when I click a movie clip on stage and the man will walk to that area. The man only moves one space when click, so it works if you continualy click the mouse. I just want to click the mouse 1 time and the character walks to that spot. Here is my code,
clickObject.addEventListener(MouseEvent.MOUSE_DOWN ,record_Mouse);
function record_Mouse(event:MouseEvent):void {
var record_MouseX:Number= mouseX;[code]........
/*I tried a loop for these last two lines, but it did not work, maybe I am doing it wrong, or maybe there is another solution? I also tried to return the value of man.x and man.y into a ENTER_FRAME event which does not seem possible with AS3*/
man.x+=vx;
man.y+=vy;
}
View 2 Replies
Similar Posts:
Jul 21, 2010
I have a widget that looks like an equalizer, the scrubbing on the slider is working. When I relaunch the swf file everything resets.
What can I do to save the setting.
View 1 Replies
Sep 16, 2011
Let's assume i have a class MyDisplayObject extending a Sprite.
I have placed several instances of that class on the same place on the stage (they are not nested) and each of them have a mouseclick listener defined within the class.
What i want is, that if i click on that area, where these objects are, that each of them triggers the mouseclick event...by default only the topmost object triggers the event. I would prefer a solution that i can implement within my class MyDisplayObject instead of iterating all children on the stage and triggering each event manually.
View 12 Replies
Nov 28, 2009
what i am trying to do is create a game that works on the same bases as battle ships but the difference is that its just at a single grid size scale so basically you only have to hit 5 squares in the 8x8 square grid. The trouble i am having is that i have set it up as a movieclip and i cant seem to get it to same the positions on the side that i select on (named the players side) it works fine for the otherside and will hit the 'enemy squares' and you can win the game but never loose the game that the problem.
View 0 Replies
Mar 12, 2010
I am developing a tool for analysis where you drag specific events onto a special wheel to analyze events based on time of day etc. I had a few users testing it and they asked for a save and load feature. I have done as much as I can at this point and am just growing confused. Can one of you experts take a look at my .fla and see what can be done...I think I am close but just can't figure it out. Also, if you can provide comments on cleaning up my code would be nice too.
View 4 Replies
Aug 27, 2010
I have a spark List with an item renderer and a tile layout. If I scroll by clicking with the mouse on the scroll bar and trying to scroll with the mouse wheel after that, there is a problem: The interval of the scrolling is oversized, instead of scrolling one item down (or up) the List scrolls 4 items down (or up).
[Code]...
View 1 Replies
Apr 18, 2011
I'd like to use the x and y mouse coordinates as variables in a program. I'm very new to Flash and ActionScript and I'm not even sure which classes I need to import or which listeners or handlers I need to use.
View 1 Replies
Jun 2, 2010
I have encountered really bad problem in one of our Flex projects. For some reason Flash can't get mouse coordinates properly. It returns something like (-107374182.4, -107374182.4) instead of good numbers. This happens when I'm using MOUSE_MOVE event in FF 3.6 on Mac OSX 10.6.3 with Flash Player 10. I have drag-n-drop in this projects, so with such ugly huge coords object goes far out of stage. Can't find solution in web, but there are some relative notes found...
For example, some info regarding 107374182.4 number can be found in internet.It seems 107374182.4 is something like NaN equivalent for some versions of Flash Player.Also I have found some notes regarding wrong mouse handling on Mac.The most interesting words there are: "on OSX it takes at least 1 frame to register the mouse's position". But it seems in my case it affects not only first frame after MOUSE_DOWN fired.Finally, there are movie on YouTube that demonstrates MOUSE_MOVE bug on FF/Mac.
I have tried:
- to get MouseEvent.stageX, MouseEvent.stageY (problem encountered);
- to get DisplayObject.root.mouseX, DisplayObject.root.mouseY (problem still appear, coordinates are bad);
- to use startDrag, stopDrag (it looks bugged too);
- to embed SWF into HTML with different wmode values.
View 0 Replies
May 8, 2007
I need to get the mouse x and y coords for a game I'm making. I know how to do it with fererence to another movie clip, button, textbox, ... but not to the stage.If all else fails, I will attach a movie clip at (0,0) and then get the x and y coords from there, but if there is a simpler way, I would like to do that.
View 1 Replies
Mar 12, 2008
I'm trying to create a simple site that when you move the mouse to the right of the screen a movie clip rotates one way abt 45 degrees and moves the other way when the mouse moves to the left.
I'm trying to get the effect of a horizon line rotating to the mouses movement around the screen.
View 10 Replies
Sep 29, 2011
how to put mouse coordinates into an if statement, but as an 'if more than' but also 'if less than'. Something like:
Code:
if (mouseX > 190, but also <210) {
//do something
}
Is it possible to also do a similar thing to also include the Y position, to create a box of some sorts based on mouse position?
Something like:
Code:
if (mouseX > 190, but also < 210, mouseY > 20, but also < 100) {
//do something
}
I think it may have something to with setting each position as a var and pushing them into an array, but I can't get my head around it.
View 4 Replies
Oct 24, 2003
I have a new project which requires getting the Longitude and Latitude coordinates on a world map. I have searched everywhere for either the code or a tutorial,
View 4 Replies
Jul 19, 2004
I am looking to create a menu similar to the one found here:All I need to know is how do you get the bar on this site the white rectangle) to go to a specific x-axis location on mouse over?
View 3 Replies
Jul 1, 2004
trying to make a MC to change s x location according to the mouse position. Les say that the Mc moves to x=100 when the mouse_x is > 300 and y < 200. and moves back when the mouse goes back.
View 9 Replies
Apr 6, 2009
How can I put the X and Y coordinates of the mouse in two variables, but only on a click on the workspace.
View 1 Replies
Feb 1, 2010
how to create a movie with a sequence of pictures and controlling the timeline frames with mouse x-coordinates?
View 4 Replies
Feb 1, 2010
I want to take a folder with 20 pictures, in some way convert them into a movie. And then apply so that I can navigate the frames one by one in the movieclip by moving the mouse right and left (move mouse left - navigate backwards frame by frame, move mouse right - navigate forward frame by frame).
View 2 Replies
Nov 24, 2009
my mission is to select an item in a DataGrid instance with nothing but the coordinates on screen.
We are implementing right-click functionality in our Flash application, with the goal of being able to right-click a DG row, which would select that row plus show a popup window containing some context commands.
I have managed to get the right click event into my Flex app with the help of this site.
Further progress so far has been to obtain the DataGrid instance via
var objects : Array = this.getObjectsUnderPoint(new Point(this.mouseX, this.mouseY));
and then to investige each of the array's items, for one of those 'parent.parentList' refers to the DataGrid instance.
I couldn't find any point-to-item converter function or anything.
PS: Using the standard Flash ContextMenu is, unfortunately, not an option.
View 3 Replies
Mar 17, 2011
I am working on panoramic scene . And I want to move a plane with cursor. When I move mouse, plane must be mouse coordinates. And I want to take plane 3D coordinates (x,y,z) expecially z-coordinate. I try below code. But it doesnt work correctly. Mouse and plane are not be same coordinates on screen. How I can do?
public class RayTracer
{
public static function getIntersection(viewport:Viewport3D, camera:CameraObject3D, normal:Array):Number3D
[Code]....
View 3 Replies
Dec 1, 2010
I have a turret in the middle of the screen and I want to draw a laser from there to the mouse coordinates. I could do this with this.graphics.lineTo(mouseX,mouseY) etc. but I'm not happy with the graphics I can get programmaticly so I want to get the same effect but with a graphic I've imported.But I'm stumped on how I can scale the graphic to the mouse coordinates.I'm also concerned that even if I can scale it it will look stretched. Does anyone know of a good way to do this?
View 0 Replies
Sep 14, 2007
A few people asked me how to get isometric (3d) coordinates from the mouse click (2d).
The answer is: you have to assume that one of the x, y or z coordinates is fixed.
The original tutorial: [URL]
Original equations:
Code:
xFla = (x-z)*Math.cos(0.46365) + xOrigin
yFla = yOrigin - y - (x+z)*Math.sin(0.46365)
Legend:
[Code].....
View 2 Replies
Mar 9, 2004
I've been reading through all the various threads related to the drawing API and saving drawings. About a hundred times I've seen mention of "log mouse positions into an array" and stuff like that, but I can't find any clear and simple examples of how to do this. Let's take a very simple use of the drawing object to do freeform drawing. What is the AS to capture the mouse XYs as the user draws and put that into an array. I can't figure out how to get Flash to keep updating things as I go, it invariably grabs the fist point and that's it.
Let's use the most basic drawing example I can find:
[AS]_root.createEmptyMovieClip("line",1);
_root.onMouseDown = function(){
line.moveTo(_xmouse,_ymouse);
line.lineStyle(0,0x000000,100);
this.onEnterFrame = function(){
line.lineTo(_xmouse,_ymouse);
}}
_root.onMouseUp = function(){
this.onEnterFrame = null;
}[/AS]
Where/what gets added to just capture all those _xmouse and _ymouse?
View 14 Replies
Aug 31, 2011
I'm figuring out a way to update my mouse x and y inside a loop. In this small test block, I'm tracing the mouseX and mouseY twice. The first one is outside a loop. The second one is inside a loop.
When I test the SWF, you can see that the first trace changes constantly and seamlessly. But when you hold your mouse down, the code starts tracing the 2nd trace. Even though the mouse is down and moving, the mouseX and mouseY traced is not changing.
Actionscript Code:
import flash.events.MouseEvent;import flash.events.Event;var mouseIsUp:Boolean = true;stage.addEventListener(MouseEvent.MOUSE_DOWN, mouseDown);stage.addEventListener(MouseEvent.MOUSE_UP,
[Code]....
Closely related to the main question, when you click the stage, you would get 100 lines of the 2nd trace. Is there a way to break the loop as soon as the mouse is up?
View 4 Replies
May 27, 2010
i'm trying to trace the x and y coordinates from within a sprite. i've added a rectangle to the stage:
var rect:Rectangle = new Rectangle(10, 10, 200, 200);
addChild(rect);
rect.x = rect.y = 100;
adding a Mouse_Move event to the rect, i can trace mouseX and mouseY to receive the coordinates of the stage while moving over the rect, but how do i get the local x and y coordinates? so if i mouse over the very top left of the rect sprite, the mouseX and mouseY return 10 as the global coordinates, but how do i make it return 0 and the local coordinates of the sprite?
i assumed localX and localY was what i was looking for, but this doesn't work:
function mouseOverTraceCoords(evt:MouseEvent):void
{
trace(mouseX, mouseY, evt.localX, evt.localY);
}
View 3 Replies
Feb 24, 2011
Within my component, I'm drawing some rectangles as below:
[Code]...
I need to display a custom tooltip for each rectange when the mouse cursor is hovering over it.
How can I do this? I'm using the MouseMove event to track when the cursor moves over these coordinates (that part is working), but when I change the tooltip text it's not refreshing
private function this_MOUSE_MOVE(event:MouseEvent):void
[code]...
EDIT: The problem seems to be with the following line:
ToolTipManager.destroyToolTip(_myToolTip);
If I comment out the preceding line, it will display the new tooltip, but it will keep creating new ones and the old ones never get removed. But if I add that line, it doesn't add any tooltips! Is the code not being executed sequentially, i.e., is the code to remove the tooltip somehow getting executed after the code to add the tooltip?
View 1 Replies
Jul 29, 2011
When tracing the mouseX / mouseY or localX / localY coordinates of a display object, why does x start at 1 while y starts at 0? For example, I've drawn a simple 400 x 400 pixel sprite onto the stage with a MouseEvent.MOUSE_MOVE event listener that calls a handler function to trace the local coordinates of the mouse. The first, top-left pixel returns {x:1, y:0} and the last, bottom-right pixel returns {x:400, y:399}. Shouldn't both the x and y start and end with the same value? I'm not sure which makes more sense for a the first mouse coordinate (either 0 or 1) but it certainly doesn't make sense that they are different?
[SWF(width = "1000", height = "600", backgroundColor = "0xCCCCCC")]
import flash.display.Sprite;
import flash.events.MouseEvent;
var darkBlueRect:Sprite = createSprite();
darkBlueRect.x = 23;
[Code] .....
View 1 Replies
Jul 29, 2009
I was wondering if there was a way using actionscript to set a larger target area for the mouse_over even, i.e. if the mouse is not necessarily over an object, but is maybe 20 px away from it could i trigger a mouse_over event?My other idea would be to create a movie clip that follows the mouse everywhere but to be honest Im not too sure about this. I don't know how to track the coordinates of the mouse.
View 1 Replies
Mar 24, 2005
I want to know how can a listener know the exact coordinates of the mouse, and control it(move the mouse to 100,100 for example).I used this:
lis=newObject(); //Listener
lis.onMouseMove=function(){ // Iwant this function to be able to control the
//mouse position[code]...
View 3 Replies
Mar 15, 2011
PHP Code:
private function thumb_dragStart(e:TouchEvent):void {
StartstageX = mouseX;
prevX = mouseX;
addEventListener(Event.ENTER_FRAME,checkMouseDir);
addEventListener(TouchEvent.MOUSE_UP, dragStop);
function checkMouseDir(e:Event):void {
I am trying to use the ENTER_FRAME to update the coordinate of my mouse when the mouse click is down but when I extend to touch, the enter frame doesn't seems to work, because my mouse is no more on that stage, the enter frame cannot locate the movement of my mouse on the SimTouch neither on CCV. What other method I should use so that I can check the coordinate of my mouse or finger movement on the flash platform?
View 1 Replies
Jun 30, 2010
how to make it work.I have 3 layers.
1. top layer is an image of a cell phone with a blank screen (where I'd like the mask to be utilized)
2. the mask... which is paired with the cell phone image above.
3. the main/maskable image, which is only revealed by the cell phone's screen.
4. the very bottom image, visible all the time.
I need the base layer image (#3) to be static, and I need the top two layers to be able to follow the same mouse x/y coordinates. So far, I've only known how to have the mask and the masked image be one together, rather than be able to move the mask independently of the image I want to mask.
View 4 Replies