Yes, I see.
Sorry, I misunderstood. 

-----Oorspronkelijk bericht-----
Van: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Namens Allandt
Bik-Elliott (Receptacle)
Verzonden: woensdag 27 februari 2008 16:53
Aan: Flash Coders List
Onderwerp: Re: [Flashcoders] quick scoping question

i've amended my function to be

                        function m(evt:MouseEvent):void
                        {
                                setChildIndex(DisplayObject(evt.target),
numChildren-1);
                        }


which works but forcing the object type seems a bit hacky to me and doesn't
really teach me anything


On 27 Feb 2008, at 14:58, Allandt Bik-Elliott (Receptacle) wrote:

> hi guys
>
> i'm playing with some as3 to get my head around it and i've come 
> across a little wierdness in the drawing api that i hope you can shed 
> some light on
>
> here is my script - it's an amended version of one from Essential
> Actionscript:
>
> <CODE>
>
> package com.receptacle.drawingtest
> {
>       import flash.display.*;
>       import flash.text.TextField;
>       import flash.events.MouseEvent;
>       
>       public class GreetingApp extends Sprite
>       {
>               public function GreetingApp()
>               {
>                       //var rectAndCircle:Shape = new Shape(); shape
changed to sprite to 
> support mouse event
>                       var rectAndCircle:Sprite = new Sprite();
>                       //adding multiple shapes to a single Shape()
instance is akin to 
> creating a graphic instance
>                       rectAndCircle.graphics.lineStyle(10,0x999999,1); //
draw lines 
> around all rectAndCircle objects
>                       rectAndCircle.graphics.beginFill(0x0000FF,1); // set
colour on 
> object
>                       rectAndCircle.graphics.drawRect(125,0,150,75); //
rectangle
>                       rectAndCircle.graphics.beginFill(0xFF0000, 0.8); //
change colour 
> on object
>                       rectAndCircle.graphics.drawCircle(150,100,50); //
circle
>                       rectAndCircle.x = 125;
>                       rectAndCircle.y = 100;
>                       //without this, rectAndCircle will not display
>                       addChild(rectAndCircle);
>                       //just for fun
>
rectAndCircle.addEventListener(MouseEvent.MOUSE_OVER,m);
>
>                       var triangle:Sprite = new Sprite()
>                       triangle.graphics.beginFill(0xFF5500,0.8);
>                       triangle.graphics.moveTo(50,0);
>                       triangle.graphics.lineTo(100,100);
>                       triangle.graphics.lineTo(0,100);
>                       triangle.graphics.lineTo(50,0);
>                       triangle.graphics.endFill();
>                       triangle.x = 175;
>                       triangle.y = 75;
>                       addChildAt(triangle, getChildIndex(rectAndCircle));
// puts 
> triangle BELOW rectAndCircle
>                       triangle.addEventListener(MouseEvent.MOUSE_OVER,m);
>                       
>                       function m(event:MouseEvent):void
>                       {
>                               setChildIndex(this, numChildren-1);
//doesn't work - 'this' is 
> scoped to the holding object
>                       }
>                       
>                       var greeting_txt:TextField = new TextField();
>                       greeting_txt.text = "hello world";
>                       greeting_txt.x = 200;
>                       greeting_txt.y = 300;
>                       addChild(greeting_txt);
>               }
>       }
> }
>
> </CODE>
>
> is what i've done possible? ie can i set a single mouseListener method 
> (m in my example) to be used by any of the sprites to move themselves 
> to the front of the display stack or would i have to write an explicit 
> statement for each one?
>
> thanks for your time
> a
>
>
>
> _______________________________________________
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


--
No virus found in this incoming message.
Checked by AVG Free Edition. 
Version: 7.5.516 / Virus Database: 269.21.1/1300 - Release Date: 26-2-2008
19:50


No virus found in this incoming message.
Checked by AVG Free Edition. 
Version: 7.5.516 / Virus Database: 269.21.1/1300 - Release Date: 26-2-2008
19:50
 

No virus found in this outgoing message.
Checked by AVG Free Edition. 
Version: 7.5.516 / Virus Database: 269.21.1/1300 - Release Date: 26-2-2008
19:50
 

_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to