Actionscript 3 :: Get ContextMenuItem X And Y Coordinates?
Jan 14, 2011
i build a contextmenu i want when user click any item then i get the x and y coordinate of the contextmenuitem............actully i want to dispaly a textbox infornt of contextmenuitem when user click on the item........ or any other solution that i will show inputtext control as submenuitem in contextmenuitem
Is there any way to pass an argument to a function being called by a ContextMenuItem?The effect I want would be what one might expect from this pseudocode:
Code: var cm = new ContextMenuItem("Start Alt", set_row_style('start_alt_here'), separatorBefore=true, enabled=true, visible=true);
Which obviously doesn't work, or I wouldn't be asking.So far I've tried using the captions as a basis for a switch condition, which works.
Code: function set_row_style(obj, cm) { switch (cm.caption) { case 'start_alt_here' : ...
But I'd rather not use an arbitrary string as part of a function.The only other option I see is using a listener for each ContextMenuItem, then calling the function with its arguments from there.Is there any more direct a way to pass an argument to a function from a ContextMenuItem?
im tryng to call a function with a argument in the ContextMenuItem class.[code]It seems that when ever I try to send an argument with the down function, it simpley dont work and without it, it does work
I was trying to convert global coordinates to local coordinates of a UIComplenent in my flex project using below code using below code
var gp:Point = new Point(e.stageX,e.stageY); //global point var lp:Point = uic.globalToLocal(gp); //local point
uic is UIComponent in which I have subclass of Sprite for drawing something I have set the sprite's mouseEnabled and mouseChildren to false to not interrupt the mouse event. above code is within uic's mousemove event where I was tracing the gp and lp gp was giving correct value and suprisingly lp was giving negetive values. when I move the move to the top left corner of uic i expect lp to be 0,0 but it is giving the -width of of uic. I broke my head for hours and ended up finding an alternate by using offsets. Infact my original code was much simpler like this which was same issue
var lp:Point = new Point(e.localX,e.localY);
I am not sure what exactly is causing this problem. the workaround had lot of issues and it creating a mess in my rest of the algorithms.Just now I found even more interesting thing (which is actually weird). for some reason I went and create a new lp2
var lp2:Point = new Point(e.localX,e.localY);
now surprisingly it was giving correct values as expected and I went back and changed the code as
var gp:Point = new Point(e.stageX,e.stageY); //global point var lp:Point = uic.globalToLocal(gp); //local point var lp2:Point = new Point(e.localX,e.localY); var lp2:Point = uic.globalToLocal(gp);
now it is expected to have all the lp, lp2 and lp3 variables to be same but weiredly lp two is giving wrong value and lp2 and lp3 were giving correct. I am suspecting using the variable lp has something to do. I am not sure about that but above proves it so right now I am using lp2.
I was reading the 'Isometric Transformations' tutorial by Danko Kozar and I have a few questions. I understand what all the code does, but not how it does it. First of all, how does the following code work:
transforms x,y,z coordinates into Flash x coordinate xFla = function (x, y, z) { // cartesian coordinates[code].....
I understand that it converts 3d coordinates to 2d coordinates, but I don't understand how. What numbers whould be punched into x, y, and z to acquire certain desired effects?Also, what's the difference between moveTo and lineTo:
red line style(1, "0xFF0000", 100); plot(0, 0, 0); draw(200, 0, 0);
Im making a little app in flash using papervision I want to make a regular movieClip show up in the same place as a papervision object. The coordinates seem like perspective is affecting the number displayed.
this is probably something thats solved verry easy, but I tried all kinds of google terms etc and I can't find a solution.On my stage, I have a symbol, in this symbol (button) the following code:
I have a movieclip inside another movieclip.[code]...
I can get mc_inside._x and mc_inside._y properties relative to the container movieclip, but how can I get the mc_inside._x and mc_inside._y relative to the _root (the stage)?
I'm having a helluva time trying to figure out why I can't load a display list object, (multiple times) at different coordinates specified in my xml file.tremendous as I am not the most accomplished with AS3. Here's the code I'm working with...
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.
We have a client server architecture where a C++ server talks to Flash clients. I'm developing the server and would like to send through tcp an xy coord to simulate a button press where the receiving flash client would find the topmost visible object at that coord and send a mouse event to it such that we could simulate play without a human present. I'm told this is incredibly difficult, but it seems to me that there must be a way to do this. Am I off the mark? Or is there a mechanism in flash to iterate through all objects regardless of parent child relationships to find a visible button at an x, y coord and signal a press event?
I've been racking my brain for the last week, and Im trying to use a map to zoom into certain city locations on the map. I believe each city locatio needs to be its own mc on the map, but don't know if I need to zoom into the coordinates of that mc? Here's what I have so far which zooms in on the appropritea x/y coordinates. Does anyone have any advice as how to change this or some other way to zoom into certain locations on a a map?
This code below works, but I'd like to modify it so that if my dragged item passes over a region in the x coordinates. So if I pass the dragged item over the range of 600 - 700 then it would play the frame labelled "square", and when it passes out of that region, go back to play the frame labelled "circle". So realy I'm asking how can I modify the <=600 to instead 600 to 700, and else refer to circle.
if (me.x <=600){ me.gotoAndStop("Square") } else if (me.x>= 700){ me.gotoAndStop("Circle") }
I wanted to write a simple 3d image rotating around the y-axis as the Image carousel. I can place all the photo around the axis but I can't get the main image facing towards the screen. I mean the z-axis isn't pointing towards the screen. Instead, the z-axis is towards the top left corner. How do I make the z-axis pointing perpendicular to the screen?
I'm trying to update a clients site and the original developer left almost no instructions.The code is all updated through XML.Here is a sample of the code
enter code here<FOLDER NAME="COMMERCIAL"> <GALLERY NAME="LOCANDA VERDE: New York"> <IMG HEIGHT="500" CAPTION="Some photo" WIDTH="393" SRC="locanda1.jpg" DX="60" DY="40"
I'm trying to move movieclip Ball along the borders of movieclip Ground. You would move the Ball with the arrow keys which would increase and decrease its x value, but the y value will always be equal to the top edge of the Ground movieclip.
To do this I need to find the y value of the points on the edges of movieclip Ground. How is this possible?This is what the Ground MovieClip would look like. It is an irregular shape. What I want is for any x point a y point at the top edge of this shape.
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.
if AS supports anything similar to hashes in perl (okay, it's been a long time since I've done any coding).If I want to get the x and y coordinates of an object I do it like this:
ActionScript Code: thumbnails[0].getXY()[0]; // Get X thumbnails[0].getXY()[1]; // Get Y
and I'd rather it look more like this:
ActionScript Code: thumbnails[0].getXY(){"x"}; // Get X thumbnails[0].getXY(){"y"}; // Get Y
I am using a hit test to allow a mc to only drop (on MOUSE_UP) in a specific area. I was wondering if there is a way to make it so that if you drop it in any area other than the one specified by the hit test, it returns back to its previous x and y coordinates? As of now I have it returning to a a specific x and y coordinate if it is not dropped on the hit test object but I want it to go back to the last spot it was at, not the same spot every time. I am assuming that you need to trace or capture the current or last x and y of the mc but I am not sure. This is the code that I am using right now for a reference...
Code: if (magnetFour.hitTestObject(myWhite)) { } else {
[Code].....
As you can see in my code, this mc is returning to an x of 502 and a y of 428 if it does not hit the hit test object...I need it to not just go to the same x and y but go to the last x and y it was dropped at.
I have made a few posts now, and I'd like to especially Prid for not only answering them, but for giving me guidance on how to learn AS2. I am progressing very nicely, and have made a couple of simple games without any tutorials, but theres one thing I couldn't find. I have this character which can move, up and down, left and right. I also have an enemy trying to shoot at him. However, this enemy needs to know where the character is. I already have the shooting code (Prid), but it was for shooting in the direction of the mouse. What I need now is to replace the bit of code that finds the mouse coordinates with code that finds the coordinates of the player.
The shooting code is on the frame (doubt that is important to say, but still) and the instance AND name of the Character is, well, Character. So basically, I need a code to calculate coordinates of a movie clip that does not have a fixed position. Oh and one more thing, should I post simple stuff like this in the beginner section, because I've seen waaay more complicated stuff there than in the AS2 section.
I just have a problem when a point goes *behind* the camera: if point.z < 0. It's ok if there's an MC that just becomes invisible - but if I try to draw a line to this point with the drawingAPI, the point's screen x/y coordinates are weird. I can't figure out how to modify the scaleRatio to get correct values. Here's a code snippet:
var scaleRatio = focalLength/(focalLength + z); screen_x = x * scaleRatio; screen_y = y * scaleRatio;
I have 12 clips on the stage. I want to get each one of their X and Y coordinates when they appear on stage. This will give a value to their starting position.I will then use that starting position to create a reset function for them to obey after I rollout of each individual cliploop for name of 12 clips (these are all named mc1, mc2, etc)thenget the starting x and y coordinates for the clipsassign variable to the values (mc1x, mc1y, etc
I have a whole stack of tile instances arranged in a grid on the stage. Each mc has a button in it. All I want is when the user clicks the 'mc', to return the coordinates of that mc relative to the main stage. I've tried _root, _parent ... everything.
Does each tile have to be named? Of course I have been able to find the coordinate if I name them all but I'm dealing with about 600 of them. Also, they are arranged in a weird way that I can't use AS to generate it at runtime. Check out the attachment and you will see what I mean.