I'm changing the canvas background colour when the dragenter event
fires..
like this.
foo.addEventListener(dragEvent.DRAG_ENTER,function
(event:DragEvent) {foo.setstyle("background","colour") };
i thought that each object i create is its own instance in memory,
therefore when i apply an event listener that event is it's own
entity for each object regardless of naming.
Would an better alternative be something along the lines of this..
<<pseudo>>
BEGIN LOOP
ARRAY[counter] = NEW extendedCanvasObj
ARRAY[counter]. setstyles
ARRAY[counter].addEventListener
container.addChild(ARRAY[counter])
END LOOP
Or is there a smarter way of doing it, any links where i can read up
on this would be appreciated.
cheers
--- In [email protected], "Alex Harui" <[EMAIL PROTECTED]>
wrote:
>
> Depending on how you change the canvas background color, you may
have
> written that code incorrectly and are always changing the last
instance.
> Watch out for those anonymous functions, they can be tricky to get
> right.
>
>
>
> ________________________________
>
> From: [email protected]
> [mailto:[EMAIL PROTECTED] On Behalf Of applecoremilo
> Sent: Wednesday, January 16, 2008 9:58 PM
> To: [email protected]
> Subject: [flexcomponents] Extended Canvas with Event Listener of
drag
> enter - n00b
>
>
>
> I'm trying to add an eventListener to my extended Canvas Class but
> seem to be having a slight problem.
>
> I've created a loop which runs 16 times (in the main mxml
component),
> it adds a new instance of the canvas to a container and sets an
drag
> enter event listener for each one, however when i drag over any of
> teh canvas' only one the last one added reacts to the drag enter -
> regardless of where i drag the object.
>
> Am i going about this the wrong way?
>
> any help would be appreciated..
>
> heres some example code
>
> for(var i = 0; i < 16;i++)
> {
> var foo:extendedCanvasObj = new extendedCanvasObj();
>
> foo.setstyle.......
>
> foo.addEventListener(dragEvent.DRAG_ENTER,function
> (event:DragEvent) {change the canvas backgroundcolour };
>
> container.addChild(foo);
> }
>