ActionScript 3.0 :: GetChild (Index) But With X And Y Coordinates
Oct 11, 2011I was just wondering if there is a way I can get the same info as the flash.display.getChild() Method, but providing the x and y co-ordiantes of a object.
View 7 RepliesI was just wondering if there is a way I can get the same info as the flash.display.getChild() Method, but providing the x and y co-ordiantes of a object.
View 7 RepliesIs there a method that does this that I just cant see? I have two uints which represent an x, y position of an unknown object. I need a way to figure out what is that object at the known x and y position.
I've tried getObjectsUnderPoint which returned: [object Shape],[object Shape]
it's correct that there are two objects but doesn't tell me specifically what they are.
Does anyone here knows how to get the path or the filename of an object inserted to the stage?
Here's the scenario:I'm developing a flash app, that enables the user to insert background to the stage by using the Browse and select using the FileReference in flash. I have successfully inserted whatever image the user choose, but what i'm trying to do is that if the user clicks save, the background image that he/she has selected will be copied to another folder on the web (uploads folder). Thus i need to know the path and filename of the background image.
[Code]...
I found out that I can't target a object inside the main MC if I use getChildAt / getChildByName. It will return me
Error #1119: Access of possibly undefined property someProperty through a reference with static type flash.display:DisplayObject.
I was trying to use something like
this.getChildAt(0).getChildByName("objectName")....
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.
View 2 RepliesSo, for sending to individual streams we have to reference the connected netStream we want to send to in some way like this:
sendStream.peerStreams[0].send("MyFunction",param1,param2);
and I have to determine which peer I'm sending to by their ID such as "peerID1234"
I know that you can check the peerID of the stream by doing:
sendStream.peerStreams[0]["farID"]
how can I make my send stream function know to use the array index where the peerID is?
so basically it could be like:
sendStream.peerStreams[where peerStreams[]["farID"] == peerID].send("MyFunction",param1,param2);
I think it would be simplest to explain it like this:
[Code]...
not sure if this is possible but i'd like to get the X,Y coordinates of a button I drag. here's my problem:
PHP Code:
public function backbuttonDown(e:MouseEvent)
{
[code].....
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:
Code:
on(press)
{
[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 am trying to change the cursor with coordinates.
I have attached the cursor to the mouse, which is a Red Circle
what I want to happen is when it gets beyond the half way point on the screen for it to turn blue.
I can do it as a rollover but I need to make it to it with if statements and coordinates.
Below is the code I have used to attache the cursor to the mouse
circle_mc.onEnterFrame = function(){
this._x = _xmouse;
this._y =_ymouse;
Mouse.hide();
};
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...
for(var i:int = 0; i < xmlLen; i++){
addChild(myCapitol);
myCapitol.name = 'capitol'+ i;
[code]....
How can you get x and y coordinates of an instance? My instance is called "rock". This is what I have tried:
PHP Code:
onClipEvent(enterFrame){
trace(rock.x);
trace(rock.y);
}
but it does not work.Next, how can I make this instance go up by a certain angle?
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 RepliesWe 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?
View 2 RepliesI'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?
[Code]....
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")
}
How i can when someone click on button "Start position" to go on 0x 0y coordinates
View 8 RepliesI 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?
View 1 RepliesI 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.
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"
[code].....
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
View 2 RepliesI'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.
How to find uv coordinates while making custom primitive in papervision3D?
View 0 RepliesI 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.