PDA

View Full Version : UILoader move not in control (Coordinate issue)



anujsharma181
March 6th, 2008, 10:07 PM
Hi
I am trying to move my UILoader across the screen but it is little bouncy. MY UILoader is in the sprite container and on the mouse down I use stop drag function where I am leaving my UILoader to mouseX and mouseY. But it is taking the top left corner of my rectangular shape UIloader as the mouseX and mouseY. So wherever i leave myUIloader it is bouncing its top left corner to my mouseX and mouseY. I applied algo in which I used calculations to calculate the distance between top left corner of my UIloader and my mouse cursor but that also did not work.
Can anybody please tell me where I am wrong.
Thanks a lot
Anuj
/******************CODE**************/

function dropUILoader(e:MouseEvent):void
{

if(container is Sprite)
{

if(e.target is UILoader)
{
var myUILoader:UILoader = e.target as UILoader;
myUILoader.move(mouseX,mouseY);
}
}
}
Alternative approach which I tried


//myUILoader.x=mouseX;
// myUILoader.y=mouseY;
//
// var x1:Number=myUILoader.x;
// var y1:Number=myUILoader.y;
//
// var neX:Number=(x1+myUILoader.width)-mouseX;
// var neY:Number=(y1+myUILoader.height)-mouseY;
//
// var neFx:Number=Math.sqrt(neX*neX+neY*neY);
//
// myUILoader.move(mouseX-neFx,mouseY-neFx)

Felixz
March 7th, 2008, 11:09 AM
try with mouseChildren=false

anujsharma181
March 7th, 2008, 06:16 PM
Hey guys
Problem has been solved.I tooke width and height of UILoader and place that mouseX-width/2 and mouseY-height/2. Works
Thanks for ur help
Anuj