To make your approach work, you can draw a rectangle in ldrBdr and
bdrRep (one in red and one in green) and toggle the alpha of one of them
sits above the other (if you addChild() it goes above everything already
in the display list).
Or just change the colour of one border Sprite instead.
Kenneth Kawamoto
http://www.materiaprima.co.uk/
anuj sharma wrote:
Hi Kenneth
Thanks for the reply. So what's the solution of my problem?
Thanks
Anuj
On Tue, Mar 4, 2008 at 1:01 PM, Kenneth Kawamoto
<[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>> wrote:
I think it's a typo but your BdrRep has no rectangle drawn, and even if
you did have the rectangle, toggling the alpha of Sprite underneath will
not give you any visual feedbacks...
Kenneth Kawamoto
http://www.materiaprima.co.uk/
anuj sharma wrote:
> Hi all
> I am trying to implement hit object in my project. I have sprite
class and I
> am loading multiple instances of UI Loader in my sprite class and
displaying
> it on the main screen. The user can drag and drop those UILoaders
on the
> main stage wherever they want.My aim was that if user drops one
UIloader on
> top of already placed UiLoader, then the already placed UILoader
will be
> replaced with the dropped UILoader. I am successful in
implementing that by
> hitting hitTestObject method. All of my UIloaders are having
green color
> border. Now my requirement is that as soon as the user places
UILoader on
> top of already existing UILoader , the UILoader which is going to be
> replaced changes border color from green to red showing the user
that the
> UIloader is being replaced and on Mouse release the UiLoader is
going to be
> replaced.
> In short on mouse over, the border color has to be changed and on
mouse
> release, object has to be replaced. I am adding my rectangle(in
Sprite
> Container) as the border to the UILoader. Below is some code to
make things
> little clearer
> Please help me in figuring out the problem.
> Any help will be appreciated.
> Thanks
> Anuj
> /*********************CODE********************
> //UILoader Being Created
> function CreateUILoaderObject(num:Number):DisplayObject
> {
> var myUILoader:UILoader = new UILoader();
> var container:Sprite=new Sprite();
> myUILoader.name="myUILoader";
> myUILoader.source = "/video/pic_"+(num+1)+".swf";
> myUILoader.load();
>
> //Defining Border for the Selected Camera
> var ldrBdr:Sprite = new Sprite();
> ldrBdr.name = "border";
> ldrBdr.alpha=0;
> ldrBdr.graphics.lineStyle(2, 0x00ff00);
> ldrBdr.graphics.drawRect(myUILoader.x+23, myUILoader.y+45,
> myUILoader.width, myUILoader.height);
>
> //Defining Border for the replaced Camera
> var BdrRep:Sprite=new Sprite();
> BdrRep.name="RepBorder";
> BdrRep.alpha=0;
> ldrBdr.graphics.lineStyle(2, 0x00ff00);
> ldrBdr.graphics.drawRect(myUILoader.x+23, myUILoader.y+45,
> myUILoader.width, myUILoader.height);
>
> myUILoader.addChild(ldrBdr);
> myUILoader.addChild(BdrRep);
> container.addChild(myUILoader);
>
>
> //Enabling Dragging & Dropping of Video Loader Anywhere
>
myUILoader.addEventListener(MouseEvent.MOUSE_DOWN,dragUILoader);
>
myUILoader.addEventListener(MouseEvent.MOUSE_UP,dropUILoader);
>
myUILoader.addEventListener(MouseEvent.MOUSE_OVER,showBorder);
> myUILoader.addEventListener(MouseEvent.MOUSE_OUT,hideBorder);
> return myUILoader;
> }
>
> //Show the selected Camera with green Border
> function showBorder(e:MouseEvent):void
> {
> e.target.getChildByName("border").alpha=1;
> }
> function hideBorder(e:MouseEvent):void
> {
> e.target.getChildByName("border").alpha=0;
> }
> //UILoader to be replaced
> function dropUILoader(e:MouseEvent):void
> {
>
> if(e.target is UILoader)
> {
> var myUILoader:UILoader = e.target as UILoader;
>
> if (mouseY<746)
> {
> myUILoader.stopDrag();
> 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)&&(
> childContainer.hitTestObject(restChild))==true)
> {
> container.removeChild(restChild);
> }
> }
> }
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders