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




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);
}




View Complete Forum Thread with Replies

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

LocalToGlobal And Vice Versa
Hi - this looks easy but is more complex than it seems.

When I mouse over a clip which is embedded two levels down
(_root -- loaded swf -- clip with mouseover), I want capture the x y position of the clip relative to the _root and then a function which places a label on the _root next to the clip but off set by -30 on the _x.

At the moment I am capturing the the X Y of the mouse and using that as a point, but obviously it looks a little messy because it depends on where the mouse hits the clip - yMouse could be 100, or 105 or 110, so each time the label is attached at slightly different Y positions. Currently I am doing XPosition = _parent._parent._xMouse and the same for Y.

Any ideaS?

thanks

frank

Sound...going To The Next Loop And Vice Versa
check out www.seasonsrecordings.com

...

i have two mp3 loops converted to swfs and would like to be able to go back in forth between the two using a next and a back button such as the ones on the site...also, what code would i put in the stop and play buttons?

any help would be much appreciated..
peace

Why Use Symbols Over Swfs, Or Vice Versa?
across several flas, i have about a dozen movie clips that will be used in one product. the easiest route seems to be to use external swfs and loadMovie functions with a few instances of some see-through buttons - is there a reason not to do this? will the file size or runtime performance suffer? the libraries share virtually no symbols, so that part's not a concern.

pros? cons? doen't matter?

tyia.

[F8] Buttons Over Movies And Vice-versa
I have a floating block that follows my mouse curor around the screen, which is a movie clip, but I want to put a button that links to another scene and the movieclip block stops following my mouse. Even if the movieclip and buttons are in different layers.

How do you get around this simple idea?

Communicate Flash With C++ & Vice-versa
Hello all,
I am developing an app for MAC OS X using C++ Flash as UI. what I exactly need is the communication between Flash & C++. how can I accomplish it?(using ExternalInterface or any other way is there... like shared object or XMLsockets?) I want to transfer data(string format) vice versa in flash & C++, I know Its possible to communicate between two swfs using LocalConnection API, but I got stuck in how to communicate between C++ and flash.
any tutorial/code snippet is greatly appreciated.
Thanks in advance.
please help!

How Can I Make Sized Windows? And VICE VERSA?
Hi all

Such question again... how can I make a sized window with or without the tool bar?

And then my next question is how to collect the windows size that containing the swf -- so that I can use that information in my movie...?!

Thanks in advance...

MKit de HK

String Compression From PHP To FLASH And Vice Versa
im wondering if flash has an equiv to PHPs gzuncompress()

If not, are there any compression/decompression functions that exist both in PHP and actionscript?

I was able to bring the size of data down from 400k to 135k using gzuncompress in php. but its not useful unless i can undo it! haha

thanks!

HTML Embedded Within Flash Or Vice Versa
I was wondering how I would go about this. To incorporate a small HTML page within a flash movie. basically I want the HTML page to be surrounded by the flash content. Or, is it an HTML page that incorporates flash. How would I do start this? I know this is possible I was just wondering how I could do it? Below is an example of what i mean. the text content in the middle is all HTML.

http://www.2advanced.com/realtybid/flash_index.htm

Thanks

Can A Button Control A Combobox And Vice Versa?
When I click a button, I want it to display the corresponding label in the ComboBox. If so, how???

Passing Variables From Flash To PHP And Vice Versa...
Here is what I need:

A button in Flash that when pressed will make a variable called "command" in a php file change value. (ie command=1).

I need to make another separate Flash file that will check to see the value of that variable.

I need help writing the actionscript for the button, the PHP file, and the file that looks for the new variable.

Can anyone help me or point me to a beginner's tutorial?

Html Form Embed Into Flash Or Vice Versa
Hey all you gurus,
Is it possible to emebed an html form onto a flash html page

Here is the flash page:

http://www34.brinkster.com/ugamis/order_test.html
with that space on the flash page i want to show an html form

Here is the html form:

http://www34.brinkster.com/ugamis/form.html

I am resorting to this because I could not get a form to work in flash. If you feel up to it email me or notify you want to take a crack at it and I will post a link on the list serve.

Embedding HTML Into Flash Documents (and Not The Vice-versa)
does ANYBODY know how to view html in a flash document. i have a script written that writes news to an html file. but now i'm making a flash version of my site, and want the same news posted in flash. i know you can use the "Field1.html=true;" and everything, but there's too much incompatability between my html and flash. (eg, i use "&" in the links, <font> tags cause problems, etc)

i attached .SWF document, so take a look at it please! (couldn't post .fla .... the file size was too big)

Whats The Best Method For Navigating Html From Flash & Vice Versa?
hey all

ok, so basically i need to find out the best Method for navigating html from flash & vice versa.

HERES MY CURRENT STRATEGY...
flash;
the flash banner will be just the one swf, it will navigate through the html content with the getURL function

html
each html page has the flash swf embedded using swfobject, a unique 'loadstate' variable will be passed from the html to flash,
eg. for the homepage it'll be;

HTML Code:
<script type="text/javascript">
// <![CDATA[
var so = new SWFObject("/swfs/header.swf", "sotester", "924", "350", "8", "#69be28");
so.addVariable("loadstate", "home");
so.write("flashcontent");
// ]]>
</script>
flash;
flash will receive this loadstate variable, then using switch/case it will gotoAndStop on the appropriate frame.
e.g


ActionScript Code:
// check variable passed from html, then play approiate frame switch (loadstate) {case "Home" :    castMC.gotoAndPlay(1);    break;case "Renewal" :    castMC.gotoAndPlay(2);    break;case "Growth" :    castMC.gotoAndPlay(3);    break;case "Harvest" :    castMC.gotoAndPlay(4);    break;case "Use" :    castMC.gotoAndPlay(5);    break;}



is there a better way of achieving the same result using swfobject to pass the variables to the .swf?

many thanks
Cam

Listbox Switcher: Move Items From Listbox1 To Listbox2 & Vice Versa
I have two listbox components side by side. "listbox1_mc" contains a list of users. "listbox2_mc" is empty.

I would like to create the code to allow the user to select one or many users from listbox1_mc and drag and drop them into listbox2_mc and vice versa (ie, once a user has been dropped into listbox2_mc, they can be removed and dropped back into listbox1_mc.

I will also have arrows ( < > ) between the listboxes to allow the user to manually move selected users between the two boxes if they don't use drag and drop (same end, different means).

Anyone Has The Asp Code For Fetching Info From Microsoft Access To Flash N Vice Versa
hi... im doing an application which needs the user to input their id no. and password(which will be given to them)..so i need an asp code to do that? anyone knows where shld i refer? pls reply a.s.a.p... Thanks

How Do You Go From A Shape To Text (and Vice Versa)using Shape Tweening?
How do you use tween a shape into text or text into a shape? Anybody know?

If (fullscreen, True) { Fullscreen, False } & Vice Versa
Heya,

on (release) {

if (fscommand("fullscreen") == true) {
fscommand("fullscreen", "false");
} else {
fscommand("fullscreen", "true");
}
}


this doesn't work in both directions.. it only makes fullscreen if it's not already. i have it on a button, which is meant to toggle fullscreen.

lil help ?

ta

FK

Is There Any Way To Load A Movie Thats Made In AS2 On An AS3 Movie And Vice Versa?
If I was to make a movie using Flash AS2 and then loadMovie thats made using AS3 into my AS2 movie, is this possible? or vice versa.

Like make a movie using AS3 then load a movie that uses AS2 with MC Tween maybe.

Are they backward compatible? I am wondering how could you mix and match and load different movie versions and actionscripts.

The Vice ...
does anyone know why using device fonts won't show when masked???

thnx

Button Makes Another Disappear, But Not Vica Versa.
///
/ Solved, I was using a graphic from another library which had
had it's it own personal agenda.......a button attached to it with it's own actionscript, back to square one then.
/
///



Probably one of those basic concepts that I miss sometimes, but this one has been bugging me for almost an hour now.

I want to make a checkbox, I have made two buttons, a tick and a cross.

They sit on the same place on the stage, here is the script.

On the first frame....

_root.tick._visible=false;
_root.tick.enabled=false;

On the cross button....

on(release){
_root.tick._visible=true;
_root.cross._visible=false;
_root.tick.enabled=true;
_root.cross.enabled=false;
}

On the tick button....

on(release){
_root.tick._visible=false;
_root.cross._visible=true;
_root.tick.enabled=false;
_root.cross.enabled=true;
}

What happens when I test the movie is that the cross button appears, after click the tick button appears, clicking on the tick button makes everything disappear.

How Do You Convert Text From Upper Case To Lower And Visa Versa?
hello people,

1) is it possible to convert from upper to lower case in flash 4 or not? if so how?

2) i have a text field where a person inputs their first name, which i want to use later on in the movie. if they enter 'JOHN' of 'john' i want to be able to display 'John' later on, with first letter capitalized and all the rest lower case.

how is this done?

thanks ahead of time!

-tm

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

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.

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

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

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.

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

[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!

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

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

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)
}

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

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