Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    Flash




Localtoglobal / Globaltolocal Issues =/



Hello,

here is my problem .. first a small diagram



now my problem ..

First i want to make an hittest between the x/y coordinate of "Object1" and the "Collision" object.. that woorks good .. but the second is that i rotate the whole "MC1" around (the center is the center of "Object1") not the problem is to make an hittest between the x/y coords of "Object2" and the "Collision" object .. i try to use localtoglobal but it dont work, did someone know how i can "convert" the global coords that it work with the "collision" object?

sorry for my bad english



FlashKit > Flash Help > Flash ActionScript
Posted on: 08-11-2003, 03:59 PM


View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread

LocalToGlobal And GlobalToLocal -
Hi... every one.
I have a serious problem. I am scratching my head for the second day...but...can't make it myself. Pls....solutions!!!

I have a mc inside another mc which is again inside another mc.
---------------------------------------
"_root.mainwindow.section.container"
---------------------------------------
Similiarly I also have...
---------------------------------------
"_root.sidewindow.object.box"
---------------------------------------

All I should do is to drag "box" and place on "container"

When I release the "box" I am checking if the _droptarget is "conatainer" or not. If yes then I should place "box" at container's XY position.

I just make it as simple as I could. Actually I have lots of CONTAINERS and lots of BOX. They are all created dynamically using duplicatMovieClip().......

Thanks.

Localtoglobal/globaltolocal
Hello all

I know there have been many posts on this, but I still seem to be doing something wrong. The file is at:

http://www.the-web-works.co.uk/clien.../test/game.fla

What I am trying to do is this:

1. Create a rectangular MC (the road graphic, _root.board) with an embedded MC (the green square, hidden at the start, _root.board.player) which can be moved by cursor keys (pretty simple).

2. Skew an instance if this MC on the stage to create an isometric 3D appearance, then set the coordinates of another MC (the red cube, _root.cube) to match those of the embedded MC controlled by the user.

The initial positioning of , _root.cube is spot on, but as you move away from the original position, it becomes apparent that it is moving double the distance it should be. You can see the green square (_root.board.player) moving and stopping at the edge of the road as it should, but the coordinates of _root.cube are not mapping precisely to them.

Any thoughts anyone? Many thanks.

Cav

Use For GlobalToLocal And LocalToGlobal
Hi there - just doing some reading up on areas I'm not 100% on and I've come across the globalToLocal and localToGlobal methods. I know how they work and have seen examples of code getting the mouse position and converting the coordinates; but I've not seen any good reasons or explanations as to why you would do that?

I know that the coordinates of the _root movie and the MC are different, but can anyone tell me why you would want to convert the coordinates?

thanks

frank

GlobalToLocal And LocalToGlobal
i don't understand how the globalToLocal and localToGlobal works. i have a movie clip inside a movieclip and i want the movieclip that is inside the movieclip to have the same x's and y's as the stage to make it work and i found the globalToLocal and the localToGlobal actions but have no idea how to make that movieclip have the main movies co-ordinates

LocalToGlobal/globalToLocal
Hey All,

I'm trying to get my head around the localToGlobal and globalToLocal thing.

What I'm going for is when I click on my box clip on the left side, it should move to the left side of the stage. Which it will. Using the global to local and tweening it based on that. I also wish that when I click the right side of the clip that it should move to the right side of the stage, but instead, it moves about the width of the clip...which makes sense, but not what I want to do.

Code so far:


Code:
import fl.transitions.Tween;
import fl.transitions.easing.*;

box.addEventListener(MouseEvent.CLICK, clickHandler);
box.buttonMode=true;

function zoom(what,startSize,endSize,duration){
var spot:Point = what.globalToLocal(new Point(mouseX,mouseY));
var myTweenmX:Tween = new Tween(what,"x",Strong.easeOut,what.x,spot.x,duration,true);
}
function clickHandler(event:MouseEvent):void{
zoom(box,1,3,2)
}

LocalToGlobal & GlobalToLocal - What About ROTATION?
Hi,
localToGlobal & globalToLocal are pretty cool methods for movie clips.

Except one thing. Rotations go bad. Let me explain it to you:

Say you have a movie_B inside a movie_A, loaded externally. And say you need to make a duplicate of movie B on stage at new coordinates newx,newy and rotated around its center by rot degrees. So I write the code:

Quote:




//load external movie_A
var newClip:MovieClip = this.createEmptyMovieClip(holderName, this.getNextHighestDepth());
var jClip:MovieClip = newClip.createEmptyMovieClip("jClip", newClip.getNextHighestDepth());
jClip.loadMovie("path_to_swf_movie");
jclip._x = 0;
jClip._y = 0;
newClip._x = xPos;
newClip._y = yPos;
//convert global target point to local coordinates
var point:Object = {x:newx, y:newy};
obj.globalToLocal(point);
//duplicate movie
movieB.duplicateMovieClip("newName", depth, {_xoint.x,_yoint.y,_rotation:rot});




Is this OK? NO, it's not, because duplicate movie will rotate NOT around its center, but around original movie center. Which sucks.

HOW can this be fixed, please?

Thanks

LocalToGlobal & GlobalToLocal - What About ROTATION?
Hi,
localToGlobal & globalToLocal are pretty cool methods for movie clips.

Except one thing. Rotations go bad. Let me explain it to you:

Say you have a movie_B inside a movie_A, loaded externally. And say you need to make a duplicate of movie B on stage at new coordinates newx,newy and rotated around its center by rot degrees. And we do the code:

Quote:




//load external movie_A
var newClip:MovieClip = this.createEmptyMovieClip(holderName, this.getNextHighestDepth());
var jClip:MovieClip = newClip.createEmptyMovieClip("jClip", newClip.getNextHighestDepth());
jClip.loadMovie("path_to_swf_movie");
jclip._x = 0;
jClip._y = 0;
newClip._x = xPos;
newClip._y = yPos;
//convert global target point to local coordinates
var point:Object = {x:newx, y:newy};
obj.globalToLocal(point);
//duplicate movie
movieB.duplicateMovieClip("newName", depth, {_xoint.x,_yoint.y,_rotation:rot});




Is this OK? NO, it's not, because duplicate movie will NOT rotate around its center, but around original movie center. Which sucks.

HOW can I fix this, please?

Thanks

LocalToGlobal/globalToLocal: ARGH
Hey guys!
Again, I get stuck with localToGlobal. This is where my projects always fail!!
I'm trying to figure out how to check if I'm hitting the lightmap or not, but somehow my coordinates are really getting messed up!


PHP Code:



var point = new Object();        point.x = Game.Background.Lightmap._x;        point.y = Game.Background.Lightmap._y;        this.globalToLocal(point);                if (this.hitTest(point.x,point.y, false)) {             trace("hit!");        } 




Can anybody tell me what I'm doing wrong here?

LocalToGlobal & GlobalToLocal - What About ROTATION?
Hi,
localToGlobal & globalToLocal are pretty cool methods for movie clips.

Except one thing. Rotations go bad. Let me explain it to you:

Say you have a movie_B inside a movie_A, loaded externally. And say you need to make a duplicate of movie B on stage at new coordinates (newx,newy) and rotated around its center by rot degrees. And we do the code:

Quote:




//load external movie_A
var newClip:MovieClip = this.createEmptyMovieClip(holderName, this.getNextHighestDepth());
var jClip:MovieClip = newClip.createEmptyMovieClip("jClip", newClip.getNextHighestDepth());
jClip.loadMovie("path_to_swf_movie");
jclip._x = 0;
jClip._y = 0;
newClip._x = xPos;
newClip._y = yPos;
//convert global target point to local coordinates
var point:Object = {x:newx, y:newy};
obj.globalToLocal(point);
//duplicate movie
movieB.duplicateMovieClip("newName", depth, {_x:point.x,_y:point.y,_rotation:rot});




Is this OK? NO, it's not, because duplicate movie will rotate NOT around its center, but around original movie center. Which sucks.

HOW can this be fixed, please?

Thanks

LocalToGlobal/globalToLocal Ignores _xscale/_yscale?
For one reason or another i have a map and some buttons residing on the same level. Inside the map i have some other markers. I'm trying to scale the map and keep the marker's positions matched - so the ones on the same level as the map match the ones inside the map.

i'm doing a localToGlobal transformation to get the position but when the map scales the positions don't change. Which suggests the the transformation isn't taking into account the relative size of the map.

can anyone suggest an alternative route around this problem? I've tried several solutions for a couple of days now and don't seem to be able to match them up. multiplying the x and y positions of the markers by the _xscale and _yscale of the map doesn't seem to work...

Issues With GlobalToLocal
Hi. This is my first post.
Here's my problem.

I have a a main document with several movie clips in it.
I have a movie clip called 'map', and one called 'slider'.

So here is my problem:

In the main timeline I can get the oldPoints position in the local coords of the map movie:
------
//declare point objects
var oldPoint = new object();

//set oldPoint to center of display
oldpoint.x = 400;
oldpoint.y = 400;
//get center of display as local map coords
map.globalToLocal(oldPoint);
-----
The result, in this case is that oldPoint = 1858,1859 which I think is correct.
But when I am inside of the movie slider, I want to do the same thing, but this doesn't work. I get a completely wacky result for oldPoint.
------
//declare point objects
var oldPoint = new object();

//set oldPoint to center of display
oldpoint.x = 400;
oldpoint.y = 400;
//get center of display as local map coords
_root.map.globalToLocal(oldPoint);
------
But here oldPoint is 403,636 which to me doesn't make sense.

So does anybody know what is happening?

Thanks.

GlobalToLocal Help
Here's my problem.

I have a a main document with several movie clips in it.
I have a movie clip called 'map', and one called 'slider'.

So here is my problem:

In the main timeline I can get the oldPoints position in the local coords of the map movie:
------
//declare point objects
var oldPoint = new object();

//set oldPoint to center of display
oldpoint.x = 400;
oldpoint.y = 400;
//get center of display as local map coords
map.globalToLocal(oldPoint);
-----
The result, in this case is that oldPoint = 1858,1859 which I think is correct.
But when I am inside of the movie slider, I want to do the same thing, but this doesn't work. I get a completely wacky result for oldPoint.
------
//declare point objects
var oldPoint = new object();

//set oldPoint to center of display
oldpoint.x = 400;
oldpoint.y = 400;
//get center of display as local map coords
_root.map.globalToLocal(oldPoint);
------
But here oldPoint is 403,636 which to me doesn't make sense.

So does anybody know what is happening?

Thanks.

Globaltolocal
I can make heads nor tails of this. I have a movie clip that is buried within 3 different levels of movie clips. I want to have it set its own x and y coordinates equal to an mc on the main timeline ( that will be loaded into _level10 eventually). I suppose I could have the main timeline set the properties but it would make more sense in the organization of this code if I could do it this way.

Anybody know this voodoo?

-Brad

Globaltolocal?
What is globaltolocal and how is it used in flash?

What is a parent and a node? I have seen these wierd things while messing with flash.. so almost any respone helps.


Thanx cool.

[AS] GlobalToLocal
I have lots of clips around my stage, each containing thier own unique graphic underneath an instance of a mask_mc.
Although the clips will be in different positions on the stage, the instances of the mask that they contain, must always have the same global coordinates.
I have put the following code in the first frame of the mask_mc.

Code:
pt = new Object();

pt.x = 183;
pt.y = 35;
this.globalToLocal(pt);
this.x = pt.x;
this.y = pt.y;
trace("localx: " + this.x + " localy: " +this.y);
stop();

can anyone spot my error here, because it isn't working. d'oh!
Thank you very much,

Tim.

GlobalToLocal
hello,
i've got this problem,
i have an mc1, in it mc2 is placed
mc1 have enormous size, width = 1100; height = 1400,
my stage is w=400, h=400;

i startDrag(); my mc1.
now i want my mc2 to be always at _root.x=0; _root.y=0
so it will look like the mc2 is always at the upper left corner of stage.

i think i'll use the localToGlobal, but i don't know how
to make it work.
maby someone could direct me to a tutorial?
or already knows how to do this ?

GlobalToLocal?
I've been developing a slider and want it to follow the mouse. Since the MC doing the following is nested in another MC I think I need to convert the mouseY to a local value...using globalToLocal?

Can someone provide an example of point me in the right direction...haven't found much in the way of resources?

Globaltolocal
Hi,

I am trying to check for hittest on movieclips in different other
movieclips (sorry don't find the words). To do that I created a
prototype to convert the coordinates. But it doesn't give me the results
I hoped for.

Here is my code. The trace command should give similar positions when
the clips are at the same position on the screen but they don't.

MovieClip.prototype.getLocalCoordinates = function (targetMc) {
var p= { x : this._x , y : this._y };
this.localToGlobal(p);
targetMc._parent.globalToLocal(p);
return p;
};

p1x = mc1.getLocalCoordinates(mc3);

trace(mc3.mc_unter._x + " " + p1x.x)
if (mc3.mc_unter.hitTest(p1x.x ,p1x.y ,true)){
trace("hit ")
distance = 0;
}


Any ideas what I am doing wrong?

[MX] GlobalToLocal ?
Ok I'm still working on my loaded swf which is an infinite menu.

I've been informed that globalToLocal is what I need (I want the code in the loaded swf to refer to its own (local) x/y cordinates not the main stage 9global0 cordinates). From what I've read it seems like this method should solve my problems... however I can't really find a good explanation of how to use it anywhere. It isnt very intuitive - at least for me. I've search these forums, did a google, and have looked it up in the AS dictionary... to no avail.

here is what I've got:

Code:
onClipEvent(load) {
loadMovie("infiniteRES.swf",_root.pages.containerRES);
//something here involving point = new object() ???
//point.x = _root._xmouse; ???
//point.y = _root._ymouse; ???
_root.pages.containerRES.globalToLocal(??);
}
I'm not very clear on this point object it says to use in the as dictionary... also do I want to perform globalToLocal on the container MC or the loaded swf directly? and why in the AS dictionary does it do this:
_root.MCtoGetMethod.globalToLocal(point) - it directs it at point? but is targeted to the MC I want??

For the life of me I cant find a clear explanation of this method.... some help on this would be great.

oh and here is the code on the infinite MC inside the loaded swf:

Code:
onClipEvent (load)
{
xcenter=125;
speed=1/10;
}
onClipEvent (enterFrame)
{
if (_root._xmouse < 33 | _root._xmouse > 218 | _root._ymouse < 18 | _root._ymouse > 62) speed=0;
else speed=1/10;
var distance=_root._xmouse-xcenter;
_x-=(distance*speed);
if (_x > 0) _x=-893;
if (_x < -893) _x=0;

}
peace

Another GlobalToLocal() Q --
Hello --

I also suspect that I need to be using some manner of globalToLocal or localToGlobal ...

I have two maps on a screen, one underneath smaller and one on top larger.

The top map is masked so the two maps should move and synch up at a specific co-ordinate point to show the country the user clicked.

I have used setInterval and a move() method to get the two maps moving smoothly ... this is fine.

BUT --- I cannot control the maps to always align on the correct country when the user starts to toggle the country text links which fire the movement of the two maps...

Please help me if you can. sure this MUST have something to do with localToGlobal reading the bounds of the stage and then making the movement occure relative to the stage or container clip's x/y 00 points.

Any pointers would be greatly appreciated.

THanks.

vagabond007

I Just Can't Get This GlobalToLocal
I think this is the answer I'm looking for.

Basically I have a "alert" box that pops up when an error accurs. Now my file is composed of this, basically I have a index.swf that is the shell, it loads in sub pages into a movie clip located say x:100 & y:100 (shouldn't matter). The dialog box command to place it's self center in the screen is:


Code:

this._x = Math.round((Stage.width-this.width)/2);
this._y = Math.round((Stage.height-this.height)/2);
This works fine if the alert box is in the index file, but when it's in a sub page the location is screwy since it's the movie is at x:100 y:100. I'm trying to find a way to make it center itself no matter what by converting the x&y coords.

[MX] GlobalToLocal ?
Ok I'm still working on my loaded swf which is an infinite menu.

I've been informed that globalToLocal is what I need (I want the code in the loaded swf to refer to its own (local) x/y cordinates not the main stage 9global0 cordinates). From what I've read it seems like this method should solve my problems... however I can't really find a good explanation of how to use it anywhere. It isnt very intuitive - at least for me. I've search these forums, did a google, and have looked it up in the AS dictionary... to no avail.

here is what I've got:

Code:
onClipEvent(load) {
loadMovie("infiniteRES.swf",_root.pages.containerRES);
//something here involving point = new object() ???
//point.x = _root._xmouse; ???
//point.y = _root._ymouse; ???
_root.pages.containerRES.globalToLocal(??);
}
I'm not very clear on this point object it says to use in the as dictionary... also do I want to perform globalToLocal on the container MC or the loaded swf directly? and why in the AS dictionary does it do this:
_root.MCtoGetMethod.globalToLocal(point) - it directs it at point? but is targeted to the MC I want??

For the life of me I cant find a clear explanation of this method.... some help on this would be great.

oh and here is the code on the infinite MC inside the loaded swf:

Code:
onClipEvent (load)
{
xcenter=125;
speed=1/10;
}
onClipEvent (enterFrame)
{
if (_root._xmouse < 33 | _root._xmouse > 218 | _root._ymouse < 18 | _root._ymouse > 62) speed=0;
else speed=1/10;
var distance=_root._xmouse-xcenter;
_x-=(distance*speed);
if (_x > 0) _x=-893;
if (_x < -893) _x=0;

}
peace

Another GlobalToLocal() Q --
Hello --

I also suspect that I need to be using some manner of globalToLocal or localToGlobal ...

I have two maps on a screen, one underneath smaller and one on top larger.

The top map is masked so the two maps should move and synch up at a specific co-ordinate point to show the country the user clicked.

I have used setInterval and a move() method to get the two maps moving smoothly ... this is fine.

BUT --- I cannot control the maps to always align on the correct country when the user starts to toggle the country text links which fire the movement of the two maps...

Please help me if you can. sure this MUST have something to do with localToGlobal reading the bounds of the stage and then making the movement occure relative to the stage or container clip's x/y 00 points.

Any pointers would be greatly appreciated.

THanks.

vagabond007

Is It A GlobalToLocal? Or Something Else. Get You Head Around This
As I had NO replies to my last posting let me simplify my problem.
If I had a move call ‘main’ on my main time line and I wanted a user to be able to click on a part on ‘main’ and by doing so ‘main’ would then move the point where the user click to the centre on the stage.
I want ‘main’ to move slowly like a tweeny, and not just jump.

Also this may have the same answer as the above question. But if I had a movie on the main time called ‘mc’. ‘mc’ is longer than the width of the main stage.
I need a button actionscript that will telltarget”mc” to move its _x to move so that the part of the ‘mc’ movie that was hidden off stage will scroll in. I know this sound like it can be done with just a tweenie but I need to be able to move ‘mc’ from position A to B to C to F to B or what ever order the user wish to view.

I hope I have made myself clear.
Thanx
Ste

[AS] GlobalToLocal Problem
I am new to the globalToLocal function and I've been battling with it all day I have made a super basic .fla example of what I am doing.I have multiple clips (clip1_mc,clip2_mc,clip3_mc), sitting on level1_mc, sitting on the stage.Clips 1,2 and 3 contain a mask and a contents layer.The mask layer contains an instance of the mask_mcNow crucial bit of my problem. My clips are in different places and their instances of the mask clip are in different places, however, I need the mask_mc to always have the same global coordinates.
I have written some script onto the mask_mc but it doesn't work.

Code:
pt = new Object();
pt.x = 300;
pt.y = 20;
this.globalToLocal(pt);
this._x = pt.x;
this._y = pt.y;

can any of you flash gurus see what is wrong?
Many many thanks,

Tim

GlobaltoLocal Problem
I'm building a particle emitter system you can view at :
http://www.lesud.com/annexes/test_flash/emitter.html

Every thing works except for gravity when the emitter has a rotation.

for gravity I ask the particles to have a _y motion. But I must tell them to have a Global _y motion.
I tried the LocaltoGlobal command, but with it I can only read the global coordinates, but not set them.

Is there a solution ?

thanks.
(I hope my question is clear enough!!!!)

Problem With GlobalToLocal(), Please Help
I'm trying to make it so when I click somewhere on the main stage, a small mc that lies within another one will pop up where the mouse is. so, i have a main mc called map, and the small one inside it is called rs. my problem is that the small mc is not popping up where the mouse is, but somewhere in its local coordinates..sorry if i explained this bad, but here is the simple code i have which lies in _root.map.rs
Code:
onClipEvent(load){

coords = new Object();

coords.x = _root._xmouse;
coords.y = _root._ymouse;

globalToLocal(coords);

this._x = coords.x;
this._y = coords.y;
}
any help would be appreciated.

GlobalToLocal Function
i went to the actionscript dictionary and looked up for the meaning and purpose of this function but i still don't understand what it means. it says: Method; converts the point object from Stage (global) coordinates to the movie clip's (local) coordinates.
But i don't really understand this. I am still a rookie to action scripts. I hope somebody could define the meaning of this function in simple terms but much easier to understand.

"Stage (global) coordinates to the movie clip's (local) coordinates"
what does it mean by stage coordinates and local coordinates?
thanks

GlobalToLocal Question
i am trying out with globalToLocal function and I realise something and that is if I put two movies into another movie clip, it wont work well.
Let's say if there are aMC and bMC on the stage. when the actionscript is something like...
x = new Object();
x.x = aMC._x;
x.y = aMC._y;
_root.bMC.globalToLocal(x);

and i move the aMC onto bMC and place aMC onto bMC's starting corner, it will appear as 0,0 as the coordinates during runtime.

however now, if i put both aMC and bMC together into another movie called cMC and do the samething, when aMC is moved onto bMC's starting corner, it doesnt appear the coordinates as 0,0 anymore. It will show the coordinates of the cMC's I guess since it appear to be some big negative numbers when I try.
How can I get 0,0 coordinates, which is what I needed when aMC is placed onto bMC's starting point even though both are in cMC?

I know its a little perplexing and so I have made a .fla just incase u dont get what I mean. the .fla will roughly give you what I am trying to ask.

Thanks!

Waht Is Globaltolocal() ?
how i can use it ? and what it does ?

I have been told to use it , but how ?

can i get example ?

GlobalToLocal, Is This The Right Direction?
Ciao Guys,
Once again I need your expertise.
I am developing a dynamic images scroller and this is the scenario:
Thumbnails scroll left to right, when you click on a thumbnail it enlarges while moving to the center of the stage.

Here is my problem, since my image is in in a nested movieclip with its own coordinates, i don't know how to move it to the center of my stage.

For instance if my stage is 1024x768 and I move my nested movie clip to x:512 and y:384, the mc doesn't move to the center of the screen but in a different position according with the clicked picture.

If I am pretty sure i should use GlobalToLocal but the posts i read describe a different scenario and i couldn't figure out how to adapt the solution to my issue.

Any Help?
Thanks

How Does GlobalToLocal Work?
Hi,

I'm trying to make it very simple but it refuses to work?!! :P

I created a main.as,

I create a new sprite object of type MyCircleClass (which creates a circle).

in MyCircleClass.as I try to read the coordinates of the global but i can't seem to reference to the stage.

in MyCircleClass, when I try to reference in this way:
trace(this.parent);
or
trace(stage)

I get null and error 1009
but when I do the same from the main.as on the object,
I do get a result (trace(MyCircleObj.parent))

Why do I keep getting null when I run the command from the MyCircleClass.as and i do get a reference to the stage if I run the command on the object on the main code of main.as?

I can't convert coordinates from classes?

btw, All the object are added by using this.addChild.


Please help,
thanks,
Guy

GlobalToLocal, Is This The Right Direction?
Ciao Guys,
Once again I need your expertise.
I am developing a dynamic images scroller and this is the scenario:
Thumbnails scroll left to right, when you click on a thumbnail it enlarges while moving to the center of the stage.

Here is my problem, since my image is in in a nested movieclip with its own coordinates, i don't know how to move it to the center of my stage.

For instance if my stage is 1024x768 and I move my nested movie clip to x:512 and y:384, the mc doesn't move to the center of the screen but in a different position according with the clicked picture.

If I am pretty sure i should use GlobalToLocal but the posts i read describe a different scenario and i couldn't figure out how to adapt the solution to my issue.

Any Help?
Thanks

GlobalToLocal() Problem
i am trying out with globalToLocal function and I realise something and that is if I put two movies into another movie clip, it wont work well.
Let's say if there are aMC and bMC on the stage. when the actionscript is something like...
x = new Object();
x.x = aMC._x;
x.y = aMC._y;
_root.bMC.globalToLocal(x);

and i move the aMC onto bMC and place aMC onto bMC's starting corner, it will appear as 0,0 as the coordinates during runtime.

however now, if i put both aMC and bMC together into another movie called cMC and do the samething, when aMC is moved onto bMC's starting corner, it doesnt appear the coordinates as 0,0 anymore. It will show the coordinates of the cMC's I guess since it appear to be some big negative numbers when I try.
How can I get 0,0 coordinates, which is what I needed when aMC is placed onto bMC's starting point even though both are in cMC?

I know its a little perplexing and so I have made a .fla just incase u dont get what I mean. the .fla will roughly give you what I am trying to ask.

Thanks!

I'm Just Lost With GlobalToLocal
I know there are tons of threads but nothing has helped. I've attached an FLA I'm using to try and figure this out.

Basically I'm trying to write a function that can look at any movieClip no matter how far down it is nested and then tell a MC sitting in the root movie to lay over it.

GlobalToLocal Broken?
I have some displayObjects and some instances of Tooltip class. The position is counted by
ActionScript Code:
var coordinates:Point=globalToLocal(new Point(stage.mouseX,stage.mouseY));
The first invoking works perfect, the second something else, third ok, 4th again not. Sometimes when I invoke this method in different instances this method gives me RANDOM!? values after some invokes
Here is trace:
Code:
(x=184, y=48) (x=584, y=298)
(x=-1, y=1) (x=583, y=299)
(x=185, y=46) (x=584, y=297)
(x=-3, y=-1) (x=582, y=295)
(x=185, y=47) (x=582, y=296)
(x=-3, y=1) (x=582, y=298)
(x=183, y=48) (x=580, y=299)
(x=157, y=-30.650000000000002) (x=198, y=407)
(x=0, y=4) (x=198, y=411)
(x=161, y=-21.650000000000002) (x=202, y=420)
(x=-16, y=4) (x=186, y=420)
(x=170, y=-18.650000000000002) (x=195, y=423)
(x=-23, y=3) (x=188, y=422)
(x=226, y=-23.650000000000002) (x=244, y=417)
(x=13, y=9) (x=280, y=423)
(x=-42, y=-12) (x=541, y=286)
(x=149, y=15) (x=549, y=265)
(x=183, y=62) (x=541, y=300)
(x=2, y=-1) (x=551, y=264)
(x=152, y=10) (x=554, y=259)
(x=-59, y=-17) (x=524, y=295)
(x=3, y=5) (x=555, y=265)
(x=153, y=3) (x=556, y=258)
(x=155, y=69) (x=496, y=302)
(x=-23, y=14) (x=530, y=267)
(x=25, y=-28) (x=580, y=291)
(x=202, y=1) (x=579, y=265)
(x=150, y=69) (x=575, y=291)
(x=-64, y=17) (x=538, y=268)
(x=-12, y=-21) (x=538, y=298)
(x=202, y=0) (x=538, y=267)
(x=148, y=59) (x=536, y=288)
(x=-67, y=15) (x=535, y=265)
(x=-14, y=-16) (x=534, y=293)
of this:
ActionScript Code:
trace(globalToLocal(new Point(stage.mouseX,stage.mouseY)),new Point(stage.mouseX,stage.mouseY));
Here are Mouse handlers:
ActionScript Code:
protected function showTooltip(event:MouseEvent):void {   this.dictionary[event.target].showDelayed();  }  protected function hideTooltip(event:MouseEvent):void {   this.dictionary[event.target].hide();  }
Here methods of Tooltip class
ActionScript Code:
public function showDelayed(time=400):void {   this._intervalId=setTimeout(show,time);  }  public function show():void {   this._intervalId=0;   trace(globalToLocal(new Point(stage.mouseX,stage.mouseY)),new Point(stage.mouseX,stage.mouseY));   var coordinates:Point=globalToLocal(new Point(stage.mouseX,stage.mouseY));   this.x=coordinates.x;   this.y=coordinates.y;   invalidate();   if (this._soundURL) _playSound();   this._tweenAlpha.removeEventListener(TweenEvent.MOTION_FINISH,_clear);   this._tweenAlpha.start();   this._tweenSize.start();  }
To see what i mean see link below and rollOver and Out couple of times SzybkieNewsy window or one of textFields in ControlPanel, I want tooltips always show under cursor.

GlobalToLocal() Problem
i am trying out with globalToLocal function and I realise something and that is if I put two movies into another movie clip, it wont work well.
Let's say if there are aMC and bMC on the stage. when the actionscript is something like...
x = new Object();
x.x = aMC._x;
x.y = aMC._y;
_root.bMC.globalToLocal(x);

and i move the aMC onto bMC and place aMC onto bMC's starting corner, it will appear as 0,0 as the coordinates during runtime.

however now, if i put both aMC and bMC together into another movie called cMC and do the samething, when aMC is moved onto bMC's starting corner, it doesnt appear the coordinates as 0,0 anymore. It will show the coordinates of the cMC's I guess since it appear to be some big negative numbers when I try.
How can I get 0,0 coordinates, which is what I needed when aMC is placed onto bMC's starting point even though both are in cMC?

I know its a little perplexing and so I have made a .fla just incase u dont get what I mean. the .fla will roughly give you what I am trying to ask.

Thanks!

Prototype And GlobalToLocal
Hi
I'm trying to make a prototype for my buttons that displays a tooltip when rolled over but Im having trouble positioning the tips in the right place.

The buttons are in various locations in my move sometimes burried deeply within several MCs.

Heres my prototype


ActionScript Code:
Button.prototype.ToolTips = function(Show, Message) {
    if (Show) {
        point = new Object();
        point.x = this._x;
        point.y = this._y;
        localToGlobal(point);
// Got position now display tips
        _root.ShowTips(Message, point.x, point.y);
    } else {
        _root.HideTips();
    }
};


I think theres a problem with my localToGlobal code although if I take this out of the prototype and apply it directly to the button it works which is why im confussed.

The ShowTips() and HideTips() are seperate functions that actually display the tips and position the tips box depending on the _x _y cords I pass in

Can anyone help?
Thanks

GlobalToLocal With External Mc's
I have an external mc that has code in its timeline to move stuff around within that mc. It works fine by itself.

Course it dont work when i load it into another mc.

Do I need to convert everything to global in order to get it working within another mc??

Is it better to place all code on the main timeline and ref through the path??

The external is not really interacting with the main mc is there anyway to keep the local coardinates?? and make it work within another mc.

[AS] GlobalToLocal - Mask
I have lots of clips around my stage, each containing thier own unique graphic underneath an instance of a mask_mc.
Although the clips will be in different positions on the stage, the instances of the mask that they contain, must always have the same global coordinates.
I have put the following code in the first frame of the mask_mc.

Code:
pt = new Object();

pt.x = 183;
pt.y = 35;
this.globalToLocal(pt);
this.x = pt.x;
this.y = pt.y;
trace("localx: " + this.x + " localy: " +this.y);
stop();
can anyone spot my error here, because it isn't working.
Thank you very much,

Tim.

GlobalToLocal And Vice Versa
I am haveing a hellofa time trying to understand the globalToLocal and localToGlobal thing. I have read countless threads and nothing about it is clicking. I just know that once I get it I will be able to complete my project. I have some code and this is just a quick movie that I put together so I can isolate just the globalToLocal thing in action. My finished files have tweening and easing in it but that just complacates things for me visually. But this code is structured like my final file.

I have a mc "MC_B" with artwork inside a holder mc "MC_A. the holder mc is dragable by way of the second MC_B. so this main clip moves around and drops were ever you want. A button when pressed needs to send MC_B to about a 100 pixels from the Stage.width (the browser window). The code posted here is what I can't get to work. when you press the button MC_B goes flying off the screen. Ultimately I will have a button that will bring MC_B back to the x0 y0 of MC_A. If I could get some help and advice I would really appreciate it. And please don't direct me to a link on globalToLocal. I have been reading them for about 4 days. And a comment about how I get this working with the tween function would be helpful.


Code:
Stage.align = "TL";
// *** Stop the stage from scaling with the browser window.
Stage.scaleMode = "noScale";
stop ();


var myPoint:Object = {x:0, y:0};

//MC_A._x = 100; // _x for movieclip x position
//MC_A._y = 100; // _y for movieclip y position

MC_A.globalToLocal(myPoint);
trace ("x: " + myPoint.x); // output: -100
trace ("y: " + myPoint.y); // output: -100

MC_B.globalToLocal(myPoint);
trace ("B" +"x:" + myPoint.x);
trace ("y:" + myPoint.y);


////////Drag and drop function

this.MC_A.MC_B.onPress = function() {
this._parent.startDrag();

MC_A.globalToLocal(myPoint);
trace ("A" +"x: " + myPoint.x); // output: -100
trace ("A" +"y: " + myPoint.y); // output: -100

MC_B.globalToLocal(myPoint);
trace ("B" +"x:" + myPoint.x);
trace ("B" +"y:" + myPoint.y);

this.onRelease = function() {
this._parent.stopDrag();
};
}


/////////
this.toStageWidth.onPress = function() {
MC_A.globalToLocal(myPoint);
MC_A._x = Stage.width - 100;
trace (Stage.width)

trace ("A" +"x: " + myPoint.x);
trace ("A" +"y: " + myPoint.y);

trace ("B" +"x:" + myPoint.x);
trace ("B" +"y:" + myPoint.y);
}

GlobalToLocal For Scale And Rotation?
One thing I like with AS3 is you can remove a child from one movieclip and add it to another. But the thing is, I want a way to do that but have it stay in the same place on screen, even though its parents are in different places.

Now, I can use localToGlobal and globalToLocal to translate a particular point from one context to the other, but I'm wondering if there's a way to do the same thing with the scale and rotation properties.

Particle Gravity GlobaltoLocal Problem
I'm building a particle emitter system you can view at :
http://www.lesud.com/annexes/test_flash/emitter.html

Every thing works except for gravity when the emitter has a rotation.

for gravity I ask the particles to have a _y motion. But I must tell them to have a Global _y motion.
I tried the LocaltoGlobal command, but with it I can only read the global coordinates, but not set them.

Is there a solution ?

thanks.
(I hope my question is clear enough!!!!)

GlobalToLocal Giving Alternate Values
i have a movieclip with this code:


Code:
this.onMouseMove = function (){
var point = new Object();
point.x = _root._xmouse;
point.y = _root._ymouse;
globalToLocal(point);
trace(point.x + " " + point.y);
this._x = point.x
this._y = point.y;
}
what happens is that the point values shifts between showing the correct values and incorrect values. here's an excerp of trace:

Quote:




134 27
-1 0
133 27
-2 1
132 27
-3 1
131 28
-4 1
130 28
-5 1
128 28
-7 1
127 28




am i using the function wrong?? the idea is that the movieclip (this) shall follow wherever the cursor is.

Volume Slider, Loader Component, And GlobalToLocal
I'll set the stage...

I have a main timeline (main.swf) which loads with the loader component, a file called music.swf which links to streaming mp3s. I've created a sliding component (composed of an x-axis_MC called "volume_mc" and a moving y-axis_MC called slider_mc), which controls volume of the streaming mp3 as it's played. This works flawlessly in the music.swf from 100% sound to muted.

Now, when I load the main.swf and access the music section, the slider still works, but only works between 100% and about 40% (roughly)...it does NOT go all the way down to mute (this physical slider goes down all the way, but the music does not).

I tried allowing the y-axis to extend farther than the x-axis and yes, it does mute eventually, but only far past the slider area. That's why I figure it's got something to do with the coordinates of the slider not being properly relayed to the main timeline when it loads in the Loader component.

Can anyone help? Please?

Here's the AS i'm using in the music.swf:
this._lockroot = true

var mp3_snd:Sound = newSound();
mp3_snd.attachSound("mp3_ldr);

slider_mc.onPress = function() {
this.startDrag(false,
_root.volume_mc._x,
_root.volume_mc._y - 100,
_root.volume_mc._x,
_root.volume_mc._y);
};

slider_mconRelease = function() {
stopDrag();
};

slider_mc.onMouseMove = function() {
var volPoint:Object = new Object();
volPoint.x = this._x;
volPoint.y = this._y;
_root.volume_mc.globalToLocal(volPoint);
mp3_ldr.setVolume(-volPoint.y);
};

The lockroot property is in there because other wise, immediately upon movement of the slider_mc, it jumps to coordinates 0, 100 at the top of the main timeline page.

Thanks in advance...

Localtoglobal
Hi Everyone,
When I load a movie into level one in Flash5 I would like to be able to assign it "x,y" coordinates. I gather this can be done with "localtoglobal". I can't seem to figure out the script. Any help would be much appreciated. Thanks.

JR

LocalToGlobal
~~~You may need to look into using the localToGlobal method for converting MC coordinates to the main timeline~~~

Hi folks the above was a sugestion for a query I had earlier, thanks to deadbeat... What I was now wanting is someone who knows how to do this???

Below is the original question and response
-------------------------------------------------------
my question<<<

Ok!! I have my main swf index.swf into this I'm loading some other .swf with loadmov action some just at a certain point and others onclick, one of the .swf that I load into this main movie (dragmov.swf) has a drag and drop point so if you drop it somewhere it puts it back to its original spot... This works fine when I export dragmov.swf and view it, but when It loads into the main movie everything works except the drop point, WHY????
-------------------------------------------------------
deadbeat responce<<

This is because movieclips and loaded movies each have their own internal coordinate system...so an x position of 100 in a movieclip is not necessarily the same as an x position of 100 on the main timeline...

You may need to look into using the localToGlobal method for converting MC coordinates to the main timeline...

HTH,

-------------------------------------------------------

Thanks to any who can help!!!

D

How Do You Use LocalToGlobal?
I have a mc that moves randomly in another mc and I want a mc on the main timeline to follow the randomly moving mc...
I know that I need to use localToGlobal, But I don't know how please help!!!!!

LocalToGlobal Help
do you have an easy to understand tutorial or page for

localToGlobal ????

thanks

Copyright © 2005-08 www.BigResource.com, All rights reserved