PDA

View Full Version : [MX] Dynamic MC Placement!



lrhb
October 13th, 2003, 02:22 PM
For reference, to help illustrate my question:

http://lrhb.org/illustration.gif

The question is this: is it possible to get an uh... "absolute" X and Y for _root.dropDown1MC.listMC.item?

As is stands, I'm placing dropDown2MC on the stage using the following code:

_root.attachMovie("dropDown2", "dropDown2", 30, {_x:_xmouse, _y:_ymouse});

and that gets it on the stage, but it doesn't function as I need it.

In a perfect world, I'd like to place dropDown2MC at the X and Y of item, BUT, there is a mask to only show a certain area of listMC (it's how I'm making a scrollable dynamically populated list).

So, is there a way to get some sort of absolute value, relative to root or something, of item's X and Y coordinates?

Sorry if this is a bit complicated... I'm trying to be as clear as possible, but you know how hard that can be when you're connected to Flash directly though a firewire cable to the brain :hat:

thanks in advance!

lrhb

lostinbeta
October 13th, 2003, 02:24 PM
There sure is....

_root.attachMovie("dropDown2", "dropDown2", 30, {_x:xCoordValueHere, _y:yCoordValueHere});

look in the script where it says xCoordValueHere and yCoordValueHere, just put the values in the right place and it should work :)

senocular
October 13th, 2003, 02:25 PM
I dont know your setup, but you might want to look into localtoglobal and globaltolocal

lrhb
October 13th, 2003, 02:29 PM
lostinbetaSavior:

the tricky part is:

item._x is relative to it's placement inside listMC, so the first item's X coordinate is 0...

So, to put that coordinate into the aforementioned bit of code would place it at _x:0 on the root...

see what I mean? (-:

senocularSavior:

I will look into that, thanks (-:

lrhb :hat:

lrhb
October 13th, 2003, 04:18 PM
Woo hoo! Success, almost! It works, but something odd is happening...

In my illustration, item also acts as a button, so I used the following code:

on(rollOver){
point = new Object();
point.x = this._x;
point.y = this._y;
trace(point.x); trace(point.y);
localToGlobal(point);
trace(point.x); trace(point.y);

_root.generateSubMenu(this.item.text, point.x, point.y);
}

the generateSubMenu function accepts the newly converted point.x and point.y coordinates, and uses them in the following manner:

function generateSubMenu(citySelect, x, y){
_root.attachMovie("dropDown2MC", "dropDown2MC", 30, {_x: x, _y: y});
}

Looking at the trace results, subtracting one coordinate from the next, I notice that in the pre-localToGlobal coordinates, the difference between two items is 21.4 or so, which is good.

However, the distance between the POST-localToGlobal coordinates is something like 42.8! Double the original!

Any idea of why this is happening, other than Flash caught me looking at another application and is now using this to extract it's jealous revenge?

Thanks! :hat:

lrhb