I am sorry my center formula should be "((regcRCx+regcRCWidth/2),
>
> (regcRCy+regcRCHeight/2)", but with this formula also my code is giving
> inconsisten results. It seems like ti is keeping something in the memory and
> showing deletion stage of
> instance somewhere where I did not intend to.
Thanks
On Wed, Mar 5, 2008 at 3:02 PM, anuj sharma <[EMAIL PROTECTED]> wrote:
> Hi
> I am trying to drag and drop multiple instances of UILoader on stage. My
> goal is if user puts UILaoder partially on top of other UILoader , it should
> just stay on top of it. If user puts on top of UILoader more than the
> central point of other UILoader, the other UILoader will change the color of
> its border and on mouse release gets replaced by the placed UILoader.
> I am successful in getting all this but I am getting inconsistent results
> as an output. Sometimes I have to put exactly on top of other UILoader to
> replace it and sometimes I just touch the UILoader and it shows red border
> and gets replaced. I used the logic of calculating the center of
> rectangle(my UILoader container) and use hitPoint method, and as soon as
> dragged UILoader hits the calculated center of UILoader, it gets replaced.
> Please help me out in where I am messing things up.Any better idea than
> this will also be highly appreciated.
> ( Following is the function which is telling my UILoader to replace of
> stopDrag.)
> Thanks a lot
> Anuj
> /*************************CODE***************/
> function dropUILoader(e:MouseEvent):void
> {
>
> if(e.target is UILoader)
> {
> var myUILoader:UILoader = e.target as UILoader;
>
> if (mouseY<746)
> {
> myUILoader.stopDrag();
> //Putting video on top of already existed videos
> var trackChild:Number=container.getChildIndex(myUILoader);
> var childContainer:DisplayObject= container.getChildAt
> (trackChild);
> for (var z:Number=0; z<=container.numChildren-1; z++)
> {
> var restChild:DisplayObject=container.getChildAt(z);
>
> if (childContainer!=restChild)
> {
> if(restChild is UILoader)
> {
> var cRC:UILoader=restChild as UILoader;
>
> var regcRCx:Number=cRC.x;
> var regcRCy:Number=cRC.y;
>
> var regcRCWidth:Number=cRC.width;
> var regcRCHeight:Number=cRC.height;
>
>
> if(childContainer.hitTestPoint(((regcRCx+regcRCWidth)/2),(regcRCy+regcRCHeight)/2)==true)
>
> {
> trace("Totally Hit");
> container.removeChild(cRC);
> }
> else
> {
> trace("Partially Hit");
> }
> }
> }
> }
> }
> else
> {
> myUILoader.unload();
> container.removeChild(myUILoader);
> }
> }
> }
>
>
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders