ActionScript 2.0 :: Tracking Mouse Coordinates Into Array
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?
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. Could one of you AS gods just write out a super simple routine for this? I know I'm not the only one that needs this (as it seems to be asked every week) Let's use the most basic drawing example I can find:
I've got a movie clip, with another clip (let's say its a rectangle) nested inside it. Now I've got another movie clip on the _root of my movie that I want to track to the _x, _y of the rectangle. I want it to follow the rectangle when the rectangle's parent is dragged or scaled.
i'm having trouble targeting the _x / _y of the rectangle relative to the stage rather than its relative _x / _y relationship with its parent. is there a way to find these values?
Trying to create a banner ad as a one-off project for a client. I am using Flash Builder / AS 3 and with my simple hello world example. Google Adwords rejects the add with: Encountered flash error - ad cannot use mouse tracking.
I Have not been able to figure out what I am doing that signals to Adwords that I am mouse tracking. Follows is my simple mxml file: (the handleClick is to adhear to their clickTAG specification)[code]...
If you look at my reference, I'd like the gray arrowed-rectangle to only appear when the mouse is inside the lighter gray rectangle (the navigation bar). When a user mouses outside of that area, the gray arrowed-rectangle will disappear.Perhaps we have to set an area where the mouse will load the movie clip and an area that will unload the movie clip?
Can you pliz help me with a script to make this effect? the 3D text effect that follows with the mouse.URL...i got a script that tracks the mouse till the end of the screen but i needed something like this that only tracks it slightly. i'm only a beginner in flash.
I have a square movieclip named squarepad. What I want is when I click on it to do [some stuff] according to where the square is clicked. It should be something like this: if ([mouseclickedx] > 1) and ([mmouseclickedx] < 10) then [do this] end if
So I've got a button that spawns a block and when pressed spawns another to the right of that block, if pressed again the process repeats. These blocks are all placed into an Array. When the user click on the blocks, they are removed.I would like the blocks to track their position in the Array so I can splice out the value on click and all the other "building spots" will move to their Array position * building spot width, so when a block is cut out, the others all move a long and remove that space.Since Arrays aren't my strong point, I wish to see what you think would be the best option here. Now keep in mind I am not a Flash Pro, so the way I have coded may not be the best, but I like to think I try Here is the code currently:
I'm trying to keep track of several movie clips with an array, but I'm running into some issues. I'm making a shooter game that requires hitTesting a list of projectiles and removing the projectiles from the list when they leave the screen or hit stuff. I've got the projectiles being added to the stage with this:
[Code]...
At first that appeared to work fine, but the bullets aren't always removed in the order they were created, so when I remove one from the array in this manner, it shifts the index numbers for all the ones that came after it back one, thus making their "num" variable no longer correspond to their index number; so when they try to splice themselves, they end up splicing the wrong ones. (Like, if I removed [3], the bullet that was in [4] is now in [3], but it doesn't know that, so it tries to splice [4], which now refers to whatever was in [5], and so on.) What's the correct way to handle this kind of situation? I feel like I must be missing something obvious, but I haven't been able to figure out a solution.
I've got two rather large arrays which I put a bunch of movieclips into and I'm just stumped on how I can possibly track if a specific movieclip in the array is right or wrong. Determing right/wrong is something I need to be able to set and then check again later when a function getItem is called.
I've got two rather large arrays which I put a bunch of movieclips into and I'm just stumped on how I can possibly track if a specific movieclip in the array is right or wrong. Determing right/wrong is something I need to be able to set and then check again later when a function getItem is called.
I just quickly made this example code because the actual file's code is much longer and contains a bunch of other code that is irrelevant to this issue.
Code: Select allvar mcArray:Array = new Array(); mcArray = [movieClip01, movieClip02, movieClip03]; button.addEventListener(MouseEvent.CLICK, getItem); function getItem(e:MouseEvent):void {
What's the correct way to track mouse position, from Adobe Flash, when someone has: Started a drag within the Flash application (a MOUSE_DOWN event), Dragged the mouse outside the app or even the browser window (a MOUSE_MOVE event), and Released the mouse button (a MOUSE_UP event)? For example (imagine Stack Overflow is a Flash application):
Within the app, I'm able to track the mouse X and Y positions with a MOUSE_MOVE event listener, but I lose it when it goes outside of the browser... So, how do I track the position of the mouse no matter where it goes? For a good example, try Google Finance. Try dragging the chart around; it'll still drag around if you move your mouse out of the browser window, and the mouse will be outside of the browser when you release it.
Also, check out KOKO KAKA; If you click on the scrollbar (make the browser window really small) and move outside of the browser window, the scroll bar moves just like a real one would. I believe both only work because the MOUSE_DOWN event "captures" the mouse, allowing the Flash application to track the position of the mouse even when it is outside of the browser.
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.
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.
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.
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.
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,
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?
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.
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).
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.
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
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?
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*/
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.
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?