ActionScript 3.0 :: LocalToGlobal : How Does It Work
Dec 14, 2010
I have a some objects of same class type prgramatically generated on the stage.Inside these objects which are generally at x=300 on the stage is the code:
Code:
this.x+=2.3;
trace(parent.localToGlobal(new Point(this.x,this.y)), ", ", this.x , " ", this.y);
A sample of the trace output is as follows..
(x=2.3, y=0) , 2.3 0
Now im expecting some values in there somewhere to indicate its absolute location on the stage, ie, x=300.This isnt happening.Whats the correct syntax i should be using.Bare in mind these object will be of any name on the stage and will be dynamically created so its not easy to just reference their mc names.
View 9 Replies
Similar Posts:
Feb 16, 2010
I have a bunch of enemy ships in a container on the stage.I am moving the container around every second and I'm creating bullets that the enemy ship are firing.So I need to have the bullets get created on the stage where the enemy ship is located currently so I can have it y-- on an enter frame event.The Y coordiantes are accurate but for some reason the X coordinates get scaled across the screen. So the first enemy ship is only off by 10 pixels or so, but the 2nd ship, the bullet gets created about 50-60 pixels over to the right.Is there any reason why the Y would be right but the X isn't?[code]
View 1 Replies
Feb 20, 2009
function traceCoordinates(event:MouseEvent):void {
var clickPoint:Point = new Point(square.mouseX, square.mouseY);
trace("display object coordinates:", clickPoint);
trace("stage coordinates:", square.localToGlobal(clickPoint));
}
i just want to find extract the .x value? clickPoint.x does not work???
View 2 Replies
Nov 5, 2006
i am teaching myself how to use localToGlobal(), and i seem to be running into a scoping snag, at least i THINK it is a scoping snag. So when i use Code:
[Code].....
i get the desired effect, yippee. That is to say, the output says 299, which is what the global coordinate of the movie is. However when i try use the same code in the main time line like this
[Code].....
View 3 Replies
Mar 1, 2012
Here's what i have:
Code:
for(var i=x; i<y; i++)
{
[code]......
View 8 Replies
Sep 27, 2010
I'm adding several instances of an MC (bread_mc) into a container MC (wall_mc). wall_mc has been added to a shop class and that is where i'm called the rest of my functions from. Also the wall_mc is scrolled left and right with mouseX & mouseY values. I've set up a function to add the bread_mc to the wall at different x/y positions.
[Code]...
I really don't even know if i'm using it right, But I think my problem lies in the fact that I need the currMC path to travel up the display list tree and get the global stage X/Y position. I'm not too sure how to implement a dynamic path with the localToGlobal method.
View 1 Replies
Jan 13, 2009
I am using localToGlobal to get the _y coordinate of a nested movieClip in relation to the stage.[code]
View 1 Replies
May 2, 2011
i just cant make this function work. Using addChild player mc is added to stage, inside it theres a mc named ballCnt. I need to make that position global, but it keeps giving local coordinates. Heres the code line (the last one i tryed):
var point:Point = localToGlobal(new Point(player.ballCnt.x, player.ballCnt.y));
trace(point);
View 1 Replies
Oct 29, 2007
I have a movie clip that is nested inside 2 other clips and want to get it's coordinates on the stage. I am using the localToGlobal method but it is returning the wrong values. Here is my code:[AS]
var myPoint = new Point(this.skew_mc.grid_mc.dot_mc.x, this.skew_mc.grid_mc.dot_mc.y);
var newPoint = this.skew_mc.grid_mc.dot_mc.localToGlobal(myP);
trace(newP);[/AS]
I've attached an fla with an example of this in. If anyone can point out where I'm going wrong .
View 1 Replies
Nov 3, 2009
Let's say i have a 3 movieclips which are nested one in other like this:A-> B-> CAnd i would like to find out C movie clip (which is in B mc and B mc is in A mc) coordinates relative to global stage, how can i accomplish that?
View 3 Replies
Oct 20, 2004
I'm making a driving game in Flash Mx 2004, and I based my code in MarkFeller Game,but I can't make the code works, now I'm with problems in the skid routine, flash dont give me any error, but the code don't works (the LineTo and MoveTo dont do anything) and I think that my problem is with localToGlobal function....
Here is my code....
Code:
acel = .2;
angulo = 0;
atrito = .98;
VelocidadeMinima = -5;
[code]....
View 1 Replies
Nov 3, 2010
I have a movieclip A inside a movieclip B. A has a coords (10, 0) and B has a coords (0, 0). So technically the global point for A should be (10, 0) right? Well it's giving me (20, 0). I put A at (10, 10) and I get (20, 20). This is just the weirdest thing ever.
View 2 Replies
Oct 15, 2010
Say I have a movieclip called theScreen a 0,0. It is 800 wide, 700 hightheScreen contains a movieclip called theStatusArea at 600,0. It is 200 wide by 700 hightheStausArea contains a movieClip called pieces at 10, 410. It is 180 wide by 180 highpieces contains a number of movieclips (triangle, square, etc.),all of these sub movieclips are more narrow than the pieces container and are all set added to the pieces container at 0,0
var pt:Point = new Point(triangle.x, triangle.y)
pt= triangle.localToGlobal(pt);
trace(pt); // should be 610, 410 at least at the start.
[code]....
View 7 Replies
Sep 13, 2010
What I'm having the problem with is the proper usage of localToGlobal method. I have the hero mc, I put into it another mc called 'weapon'. Now, in the game, I want to fire a projectile and set it at the x and y of the weapon. The question is, how can I access the absolute x and y of the weapon.
View 3 Replies
Feb 19, 2011
My problems keep piling up. I was trying to figure out where child objects X and Y positions are on stage and not locally. Therefore i use the "localToGlobal" function and I'm pretty sure i use it correctly? The thing is that some Y values are true but the X are just completely spaced out. I use a function to find all child objects on stage and this works great.
Code:
private function findGameElements():void
{
// Array that will store all elements on screen and their values
fixedElements = new Array();
[Code].....
View 4 Replies
Oct 13, 2011
I got 23 boxes (box1, box2...) inside two movieclips (Circle.SizeableCircle). I need to bring all these to the front, using localToGlobal.This brings box1 to the front (or whatever it's called):
PHP Code: var cpBox1:Point=new Point(Circle.SizeableCircle.box1.x,Circle.SizeableCircle.box1.y);var gpBox1:Point=Circle.SizeableCircle.box1.parent.localToGlobal(cpBox1);
What can I do instead of making 23x that code?
View 11 Replies
Jan 12, 2009
I've got a clip on the stage at (100, 100) and I execute the following code:
[Code]....
Given that circle1 is on the stage, shouldn't localToGlobal leave the co-ordinates unchanged? I think the result of its call is wrong!
View 2 Replies
Oct 27, 2010
I have a small problem with usage localToGlobal and than back to local. I can get global coordinate of my nested mc in question alright. Than i check if this coordinate + value of my mc.width is more than my stage width. I get to this part with no problem. Than if value is bigger (so mc is not on the stage i mean if part is off the stage i change value so it is stage width - mc.width). So i get value in global coordinates that i need. But how do i apply this to my nested clip is my question? For reference here is my code:
[Code]...
View 3 Replies
Feb 12, 2010
So I am able to trace the correct coordinates. However the hitTest fails. Here is my code:
[code]....
View 1 Replies
Dec 4, 2010
Ive tried looking in a whole bunch of threads for a solution to this probably common issue but to no avail.I have a bunch of objects of same type on the stage which are generated through code.Inside these objects which are generally at x=300 on the stage.
Code:
this.x+=2.3;
trace(stage1.localToGlobal(new Point(this.x,this.y)), ", ", this.x , " ", this.y);
stage1 is the stage object I pass into my class.The trace output is as follows
(x=2.3, y=0) , 2.3 0
Now im expecting some values in there somewhere to indicate its actual location on the stage, ie, x=300.This isnt happening.Whats the correct syntax i should be using.
View 4 Replies
Aug 17, 2004
I'm working on an isometric-view prototype game, and I thought a good way to do the collision detection would be to put four empty movie clips on each of the character's base corners (it's a cube), convert those corner's _x and _y to the Stage, and go from there. Problem is, how to get it to work.My character is on the stage in an otherwise empty "clip" MovieClip. Here's what I have inside my character:
Code:
onClipEvent(enterFrame){
var point:Object = new Object();
point.rightX = right._x;[code]....
Whenever I trace any of these, it always traces the local coordinates. Otherwise, everything is fine.
View 1 Replies
Mar 19, 2012
I am trying to defeat my psychological block with dynamically loaded fonts in AS3, and I have an annoying problem. I am creating a clock with a textfield and I am loading fonts from a SWF library: the available classes/linkages are "Arial", "ArialBold", "MyriadPro", "MyriadProBold" and "Verdana".This is the line where I get the class from the SWF, and it extracts the class correctly
Code:
clock = new Clock( { fontClass: assetsLoader.getFontClass("skin", "Arial") } );
The constructor...
[code]......
View 7 Replies
Feb 22, 2010
I have run across a strange problem. When I load products2.swf by itself, I can call the two "copy" files and everything works. When I open 0342.swf (the index page), I can switch between the home and products2 pages, but I can't view the "copy" pages.I'm guessing there may be some sort of conflict with variable names, but I have been messing with it for most of today.I have uploaded all of the FLA files to here:[url]....
If you make an swf file out of each of the attached items, and open the 0342 file, you will see what is supposed to be happening.
on (release) {
if (_root.currMovie == undefined) {
_root.currMovie = "home";[code].....
View 3 Replies
Apr 21, 2010
I have a button object that I need to scale to align with the variable width of an array of images.However, when I set the width in code, the button does not actually become that width. Tracing out the width gives me the correct value, but on screen.. it's off.
I've proved it to myself by scaling the same button object manually in the properties pane and visually comparing. Both of the buttons below have a width of 410.
Code:
navigatorDown_btn.width = 410;
navigatorDown_btn.x = (stage.stageWidth/2)-(navigatorDown_btn.width/2);
trace(navigatorDown_btn.width); // output: 410
View 4 Replies
Jun 1, 2011
I am using Flash CS4 with actionscript 2 to create an interacitve portfolio.I have 2 text buttons that work when I test them with "enable simple buttons." When I publish to IE these buttons won't work. I have created over 50 buttons using the same methods, they all work.
View 8 Replies
Oct 15, 2010
I have a completed project (AS2) that contains a lot of FLVs. I burned it onto DVD and it works great on Mac (guide.app) and PC (guide.exe).Here's the web version of the project.http:[url]....Now, months later, I have to provide the project with source files (FLA's) and some other stuff - so I got an external HD, copied the files from the working DVD onto it. Running the guide.exe off of the external (connected to WinXP SP3) works just like running it off the DVD - EXCEPT for the FLVs which simply to not appear.
http:[url]...Everything up to that step works: When I click on "guide.exe", the "splash screen" opens showing the title and 4 buttons. These buttons are to choose a language and they work.When I select a language and click its button the GUI for the language with menus appear and they work. When I click on a topic from the menu, the topic's skin appears but the video inside the skin doesn't play. Everything works but the FLVs.
Even weirder - If I use VLC Player to open an FLV directly - the FLV will play. That tells me there is some path issue but how can a path change when it's compiled into the SWF? Besides - the paths from swf to flv has not changed when I copied all the files to the external.why the FLVs will not play on the external the same way they play when on the DVD?
View 9 Replies
Mar 23, 2009
i have a flash that I have tried to add my html link to the aboutus.htlm, billboard.html, and contac.html and it is not working? I am still new but would like to email the flash file for someone to tell me why its not working- I added the link for aboutus.html but its not working.
View 6 Replies
Apr 14, 2009
alright, here is the deal: i have published a .swf AND a macintosh projector file and the only thing the movie contains is one button with a link to a web page. here is my actionscript:
on(release) {
getURL("http://www.google.com");
}
i click on the button and absolutely nothing happens. has anyone ever come across something like this? is this a settings problem?
View 6 Replies
May 14, 2009
Whenever I try to import any .wav, .mp3, or any other kind of file, it always says that there was a problem reading them.
View 2 Replies
Jul 23, 2009
I have a swf that is pretty complicated, you can interact with the page and go to different keyframes and it stops and/or starts depending on buttons, but I want to put it in a fla or something so I can put other swfs next to it and build it up and put several of them together as one.
I don't care about making it too complicated, I just want one interactive swf to go to the next compiled swf when that movie ends, but when I try importing it or loading it it just runs straight through without stopping or paying any attention to the scripting.
View 16 Replies