Re: [Flashcoders] AS3 MouseEvent target?

2008-04-02 Thread Muzak

So in general, where you in AS2 were using e.target you should now use
e.currentTarget.


+1 ;-)

Must read: Event propagation
http://livedocs.adobe.com/flex/3/html/events_08.html

regards,
Muzak

- Original Message - 
From: "EECOLOR" <[EMAIL PROTECTED]>

To: "Flash Coders List" 
Sent: Wednesday, April 02, 2008 2:22 PM
Subject: Re: [Flashcoders] AS3 MouseEvent target?



which is mouseChildren = false.


In my humble opinion I do not think this is what he needs. He should not be
referencing target, but instead he should reference currentTarget.

If you are adding a listener, the handlers e.currentTarget will point to the
object that you added the listener to, e.target is the object that initiated
the event (event bubbling).

So in a general way, where you in AS2 were using e.target you should now use
e.currentTarget. You only use
e.target if you want to reference the displayObject that initiated the event.



Greetz Erik


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


Re: [Flashcoders] AS3 MouseEvent target?

2008-04-02 Thread EECOLOR
This behaviour can not emulated precisely because there is no way for us to
set the target and currentTarget properties. This is done by internal
EventDispatcher code.

The EventDispatcher code works something like this:

- check if the target property of the event has been set, if not set it
- set the currentTarget property
- check if the event has the bubbles property set to true
- check if the class is a DisplayObject
- check if the parent property is set
- clone the event and dispatch it at the parent and repeat the above steps


Greetz Erik


On 4/2/08, Meinte van't Kruis <[EMAIL PROTECTED]> wrote:
>
> so how does it work internally for displayObjects? Can a developer emulate
> this behaviours somehow?(cant imagine it since target and currentTarget
> are
> readonly)
>
>
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] AS3 MouseEvent target?

2008-04-02 Thread EECOLOR
> which is mouseChildren = false.

In my humble opinion I do not think this is what he needs. He should not be
referencing target, but instead he should reference currentTarget.

If you are adding a listener, the handlers e.currentTarget will point to the
object that you added the listener to, e.target is the object that initiated
the event (event bubbling).

So in a general way, where you in AS2 were using e.target you should now use
e.currentTarget. You only use
e.target if you want to reference the displayObject that initiated the event.



Greetz Erik


On 3/31/08, Steven Sacks <[EMAIL PROTECTED]> wrote:
>
> IMO, explaining Event Bubbling as the reason the TextField is the target
> is complicating the immediate solution he needs, which is mouseChildren =
> false.
>
> Yes, it's Event Bubbling that's causing the target to be the TextField.
>  To understand Event Bubbling, read about it in the docs, or better yet, in
> a book (like Moock's).  But, then you MUST do it yourself to learn how it
> works.  If you don't play with it yourself, you will never "get it" no
> matter how much somebody explains it to you.  I'm fully convinced of that.
>  You gotta mess around with it to fully understand why it's so amazingly
> awesome.
>
> ___
> 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


Re: [Flashcoders] AS3 MouseEvent target?

2008-04-02 Thread Meinte van't Kruis
so how does it work internally for displayObjects? Can a developer emulate
this behaviours somehow?(cant imagine it since target and currentTarget are
readonly)

On Tue, Apr 1, 2008 at 10:01 PM, Merrill, Jason <
[EMAIL PROTECTED]> wrote:

> Well, you still haven't convinced me it isn't kludy, but no bother
> your perspective - my perspective - both different, doesn't matter in
> the end. :)
>
> Jason Merrill
> Bank of America
> GT&O and Risk L&LD Solutions Design & Development
> eTools & Multimedia
>
> Bank of America Flash Platform Developer Community
>
>
> Are you a Bank of America associate interested in innovative learning
> ideas and technologies?
> Check out our internal  GT&O Innovative Learning Blog & subscribe.
>
>
>
>
>
>
> >>-Original Message-
> >>From: [EMAIL PROTECTED]
> >>[mailto:[EMAIL PROTECTED] On Behalf
> >>Of Steven Sacks
> >>Sent: Tuesday, April 01, 2008 3:05 PM
> >>To: Flash Coders List
> >>Subject: Re: [Flashcoders] AS3 MouseEvent target?
> >>
> >>Extending DisplayObject to access some of its native
> >>functionality (e.g.
> >>event bubbling) seems fine to me, especially if you look at
> >>it from the perspective of EventDispatcher has events and
> >>DisplayObject extends EventDispatcher and adds bubbling
> >>functionality.  If you need bubbling, extend the class that
> >>provides that.
> >>
> >>The whole non-visual argument is a bit of a red herring
> >>considering we're using Flash and, until recently, all
> >>Actionscript was inside of or attached to a display object
> >>(MovieClip).  Technically, it still is.  ;)
> >>
> >>Flash is a visual tool, and I maximize my productivity by
> >>leveraging it fully.  Flash has all kinds of great
> >>Flash-centric features and you can definitely use them to
> >>your advantage.  It's not "hacking" to use the API given to you.  :)
> >>
> >>___
> >>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
>



-- 
M.A. van't Kruis
http://www.malatze.nl/
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


RE: [Flashcoders] AS3 MouseEvent target?

2008-04-01 Thread Merrill, Jason
Well, you still haven't convinced me it isn't kludy, but no bother
your perspective - my perspective - both different, doesn't matter in
the end. :) 

Jason Merrill
Bank of America  
GT&O and Risk L&LD Solutions Design & Development 
eTools & Multimedia 

Bank of America Flash Platform Developer Community


Are you a Bank of America associate interested in innovative learning
ideas and technologies? 
Check out our internal  GT&O Innovative Learning Blog & subscribe.




 

>>-Original Message-
>>From: [EMAIL PROTECTED] 
>>[mailto:[EMAIL PROTECTED] On Behalf 
>>Of Steven Sacks
>>Sent: Tuesday, April 01, 2008 3:05 PM
>>To: Flash Coders List
>>Subject: Re: [Flashcoders] AS3 MouseEvent target?
>>
>>Extending DisplayObject to access some of its native 
>>functionality (e.g. 
>>event bubbling) seems fine to me, especially if you look at 
>>it from the perspective of EventDispatcher has events and 
>>DisplayObject extends EventDispatcher and adds bubbling 
>>functionality.  If you need bubbling, extend the class that 
>>provides that.
>>
>>The whole non-visual argument is a bit of a red herring 
>>considering we're using Flash and, until recently, all 
>>Actionscript was inside of or attached to a display object 
>>(MovieClip).  Technically, it still is.  ;)
>>
>>Flash is a visual tool, and I maximize my productivity by 
>>leveraging it fully.  Flash has all kinds of great 
>>Flash-centric features and you can definitely use them to 
>>your advantage.  It's not "hacking" to use the API given to you.  :)
>>
>>___
>>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


Re: [Flashcoders] AS3 MouseEvent target?

2008-04-01 Thread Steven Sacks
Extending DisplayObject to access some of its native functionality (e.g. 
event bubbling) seems fine to me, especially if you look at it from the 
perspective of EventDispatcher has events and DisplayObject extends 
EventDispatcher and adds bubbling functionality.  If you need bubbling, 
extend the class that provides that.


The whole non-visual argument is a bit of a red herring considering 
we're using Flash and, until recently, all Actionscript was inside of or 
attached to a display object (MovieClip).  Technically, it still is.  ;)


Flash is a visual tool, and I maximize my productivity by leveraging it 
fully.  Flash has all kinds of great Flash-centric features and you can 
definitely use them to your advantage.  It's not "hacking" to use the 
API given to you.  :)


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


RE: [Flashcoders] AS3 MouseEvent target?

2008-04-01 Thread Merrill, Jason
>>I don't necessary see extending DisplayObject as a hack.  
>>It's creative leveraging of AS3's native architecture. 

Extending a display object to get the event bubbling of for a non-visual
class - if not a hack, then it's certainly kludgy. 

Jason Merrill
Bank of America  
GT&O and Risk L&LD Solutions Design & Development 
eTools & Multimedia 

Bank of America Flash Platform Developer Community


Are you a Bank of America associate interested in innovative learning
ideas and technologies? 
Check out our internal  GT&O Innovative Learning Blog & subscribe.




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


Re: [Flashcoders] AS3 MouseEvent target?

2008-04-01 Thread Steven Sacks
I don't necessary see extending DisplayObject as a hack.  It's creative 
leveraging of AS3's native architecture.  :)



Merrill, Jason wrote:


I think that's because only display objects can bubble events, I don't
think non-visual classes can bubble events (unless they extend a display
object like Sprite, but that's a hack).  I don't know why it is this
way, but that has been my understanding.  I wish non-visual classes
could bubble too.  If someone knows otherwise, please advise.
  


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


RE: [Flashcoders] AS3 MouseEvent target?

2008-04-01 Thread Merrill, Jason
>>the problem with most explanations about event bubbling is 
>>that it concentrates on the displaylist (understandable), i'd 
>>like to see an example of custom events being bubbled.

I think that's because only display objects can bubble events, I don't
think non-visual classes can bubble events (unless they extend a display
object like Sprite, but that's a hack).  I don't know why it is this
way, but that has been my understanding.  I wish non-visual classes
could bubble too.  If someone knows otherwise, please advise.


Jason Merrill
Bank of America  
GT&O and Risk L&LD Solutions Design & Development 
eTools & Multimedia 

Bank of America Flash Platform Developer Community


Are you a Bank of America associate interested in innovative learning
ideas and technologies? 
Check out our internal  GT&O Innovative Learning Blog & subscribe.



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


Re: [Flashcoders] AS3 MouseEvent target?

2008-04-01 Thread Meinte van't Kruis
the problem with most explanations about event bubbling is that it
concentrates on the displaylist (understandable), i'd like to see an example
of custom events being bubbled. Though Steven's probably right, playing with
it helps alot.

On Tue, Apr 1, 2008 at 12:49 PM, Allandt Bik-Elliott (Receptacle) <
[EMAIL PROTECTED]> wrote:

> thanks Jiri
>
> i've just got the design patterns book so i'll be digging into that
> at some point in the near future
>
> a
>
> On 1 Apr 2008, at 10:40, Jiri Heitlager wrote:
>
> > I think the best way to learn about Event Bubbling is understanding
> > the Composite desing pattern. This is the pattern the DisplayList
> > is implementing and bubbling will make much more sense when you
> > understand the workings of the Composite Pattern. At least it did
> > for me.
> >
> > Jiri
> >
> > Steven Sacks wrote:
> >> IMO, explaining Event Bubbling as the reason the TextField is the
> >> target is complicating the immediate solution he needs, which is
> >> mouseChildren = false.
> >> Yes, it's Event Bubbling that's causing the target to be the
> >> TextField.  To understand Event Bubbling, read about it in the
> >> docs, or better yet, in a book (like Moock's).  But, then you MUST
> >> do it yourself to learn how it works.  If you don't play with it
> >> yourself, you will never "get it" no matter how much somebody
> >> explains it to you.  I'm fully convinced of that.  You gotta mess
> >> around with it to fully understand why it's so amazingly awesome.
> >> ___
> >> 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
> >
>
>
> ___
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>



-- 
M.A. van't Kruis
http://www.malatze.nl/
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] AS3 MouseEvent target?

2008-04-01 Thread Allandt Bik-Elliott (Receptacle)

thanks Jiri

i've just got the design patterns book so i'll be digging into that  
at some point in the near future


a

On 1 Apr 2008, at 10:40, Jiri Heitlager wrote:

I think the best way to learn about Event Bubbling is understanding  
the Composite desing pattern. This is the pattern the DisplayList  
is implementing and bubbling will make much more sense when you  
understand the workings of the Composite Pattern. At least it did  
for me.


Jiri

Steven Sacks wrote:
IMO, explaining Event Bubbling as the reason the TextField is the  
target is complicating the immediate solution he needs, which is  
mouseChildren = false.
Yes, it's Event Bubbling that's causing the target to be the  
TextField.  To understand Event Bubbling, read about it in the  
docs, or better yet, in a book (like Moock's).  But, then you MUST  
do it yourself to learn how it works.  If you don't play with it  
yourself, you will never "get it" no matter how much somebody  
explains it to you.  I'm fully convinced of that.  You gotta mess  
around with it to fully understand why it's so amazingly awesome.

___
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




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


Re: [Flashcoders] AS3 MouseEvent target?

2008-04-01 Thread Jiri Heitlager
I think the best way to learn about Event Bubbling is understanding the 
Composite desing pattern. This is the pattern the DisplayList is 
implementing and bubbling will make much more sense when you understand 
the workings of the Composite Pattern. At least it did for me.


Jiri

Steven Sacks wrote:
IMO, explaining Event Bubbling as the reason the TextField is the target 
is complicating the immediate solution he needs, which is mouseChildren 
= false.


Yes, it's Event Bubbling that's causing the target to be the TextField.  
To understand Event Bubbling, read about it in the docs, or better yet, 
in a book (like Moock's).  But, then you MUST do it yourself to learn 
how it works.  If you don't play with it yourself, you will never "get 
it" no matter how much somebody explains it to you.  I'm fully convinced 
of that.  You gotta mess around with it to fully understand why it's so 
amazingly awesome.


___
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


Re: [Flashcoders] AS3 MouseEvent target?

2008-04-01 Thread Allandt Bik-Elliott (Receptacle)
ah yes - i couldn't get the mouseChildren to work before when i had  
drawn in the movieclip but now i've separated the container movieclip  
from the drawn-in shape, it' s working


thanks for your help guys

here's a copy of my code in case anyone else is interested:
CODE
// on xml load complete
private function periodCompleteListener(e:Event):void
{
periodXmlDoc = periodXmlLoader.doc;
trace (periodXmlDoc.toXMLString());

for each (var period:XML in periodXmlDoc.*)
{
createPeriodBar([EMAIL PROTECTED], [EMAIL PROTECTED], [EMAIL PROTECTED],  
[EMAIL PROTECTED]);

}
}

		private function createPeriodBar(dateStart:int, dateEnd:int,  
pbTitle:String, pbDate:String, pbList:Array = null):void

{
var pixelStart:int = yearsToPixels(dateStart);
var pixelEnd:int   = yearsToPixels(dateEnd);

var pbX:int = pixelStart;
var pbWidth:int = pixelEnd - pixelStart;

			var pbYStart:int = taTitleBarHeight + pbSpace; // start point for  
all period bars
			var pbY:int = pbYStart + pbGetY(dateStart, dateEnd) * (pbHeight 
+pbSpace);  // pbGetY(below) returns a level which is multiplied by  
the hight and the spacing


			var pbcontainer:MovieClip = new MovieClip(); // movieclip that  
holds a variable (rolloverText), textfield and shape

var pb:Shape = new Shape();

if (uint(dateEnd-dateStart) > 1)
{
pb.graphics.beginFill(0xFF,.3);// white 50% 
alpha

pb.graphics.drawRoundRect(0,0,pbWidth,pbHeight,pbHeight);
pb.graphics.endFill();
pbcontainer.x = pbX;
pbcontainer.y = pbY;

var pbText:SimpleTextField = new SimpleTextField(0xFF, 14,  
headingFont, 4, -2, pbWidth-4, 25, pbTitle, false);

pbText.selectable = false;
pbText.text += " ";
pbText.text += pbDate;
var pbf:TextFormat = new TextFormat();
pbf.font= 
subheadingFont;
pbf.size= 10;
var pbCurrentLength = 
pbTitle.length+1;
var pbDateLength= pbText.length;
pbText.setTextFormat(pbf, pbCurrentLength, 
pbDateLength);

pbcontainer.addChild(pbText);
pbcontainer.addChild(pb);
pbcontainer.mouseChildren = false;
} else
{
pb.graphics.beginFill(0xFF,.5);// white 50% 
alpha
pb.graphics.drawCircle(0,0,pbHeight/2);
pb.graphics.endFill();
pbcontainer.x = pbX;
pbcontainer.y = pbY+(pbHeight/2);

pbcontainer.addChild(pb);
}
pbcontainer.rolloverText = pbTitle + "\n" + pbDate;
			pbcontainer.addEventListener(MouseEvent.MOUSE_OVER,  
pbMouseOverListener);


scrollableBase.addChild(pbcontainer);
}

		// replaces the mousefollower.text with what's in the rolloverText  
variable

private function pbMouseOverListener(e:MouseEvent):void
{
mfTextField.text = e.target.rolloverText;
mouseFollower.visible = true;
}

		// this stacks the period bars automatically based on if the dates  
overlap

private function pbGetY(dateStart:int, dateEnd:int):int
{
var level:int = 0;
for (var i=0; ipreviousDateEnd_ar[level])
{
previousDateEnd_ar[level] = dateEnd;
return level;
}
level++;
}
previousDateEnd_ar.push(dateEnd);
return level++;
}




On 1 Apr 2008, at 00:52, Steven Sacks wrote:

> Take off the t

Re: [Flashcoders] AS3 MouseEvent target?

2008-03-31 Thread Steven Sacks
> Take off the true flag for bubbling and set mouseChildren = true.  
This should solve your issue.


Er, I meant set mouseChildren = false.


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


Re: [Flashcoders] AS3 MouseEvent target?

2008-03-31 Thread Steven Sacks
You shouldn't be using capture phase until you've got a really good 
handle on bubbling phase first.


You shouldn't have bubbling turned on for your button unless you are 
planning on catching this event above this clip, as well.


Event Bubbling means that the TextField is dispatching a bubbling event 
automatically and you are catching it because you're listening to the 
clip that contains the TextField for the CLICK event.  You're going to 
receive the TextField CLICK even though you want just the MovieClip 
CLICK.  You set mouseChildren = false so you don't receive events from 
anything but the MovieClip.


Take off the true flag for bubbling and set mouseChildren = true.  This 
should solve your issue.




Allandt Bik-Elliott (Receptacle) wrote:
okay i've tried everything i can find in the book re: this problem and 
it doesn't seem to be having any affect


i've tried the mouseChildren option (commented out) and useCapture 
tomfoolery (seems to be firing in the CAPTURING_PHASE as that's the 
only one i can get any result from) and i've also tried separating the 
graphic elements from the container displayobject to get rid of any 
code wierdness. I've even tried putting the solid block on top of the 
text and applying the event to that but none of it has worked.


here is my code (with eventphase extra bits in place):

private function createPeriodBar(dateStart:int, dateEnd:int, 
pbTitle:String, pbDate:String, pbList:Array = null):void

{
var pixelStart:int = yearsToPixels(dateStart);
var pixelEnd:int   = yearsToPixels(dateEnd);
   
var pbX:int = pixelStart;

var pbWidth:int = pixelEnd - pixelStart;
   
var pbYStart:int = taTitleBarHeight + pbSpace;
var pbY:int = pbYStart + pbGetY(dateStart, dateEnd) * 
(pbHeight+pbSpace);
   
var pbcontainer:MovieClip = new MovieClip();

var pb:Shape = new Shape();

if (uint(dateEnd-dateStart) > 1)
{
pb.graphics.beginFill(0xFF,.3);// white 50% alpha
pb.graphics.drawRoundRect(0,0,pbWidth,pbHeight,pbHeight);
pb.graphics.endFill();
pbcontainer.x = pbX;
pbcontainer.y = pbY;
   
var pbText:SimpleTextField = new 
SimpleTextField(0xFF, 14, headingFont, 4, -2, pbWidth-4, 25, 
pbTitle, false);

pbText.selectable = false;
pbText.text += " ";
pbText.text += pbDate;
var pbf:TextFormat = new TextFormat();
pbf.font= subheadingFont;
pbf.size= 10;
var pbCurrentLength= pbTitle.length+1;
var pbDateLength= pbText.length;
pbText.setTextFormat(pbf, pbCurrentLength, pbDateLength);
   
pbcontainer.addChild(pbText);

pbcontainer.addChild(pb);
//pb.mouseChildren = false; //
} else
{
pb.graphics.beginFill(0xFF,.5);// white 50% alpha
pb.graphics.drawCircle(0,0,pbHeight/2);
pb.graphics.endFill();
pbcontainer.x = pbX;
pbcontainer.y = pbY+(pbHeight/2);
   
pbcontainer.addChild(pb);

}
pbcontainer.rolloverText = pbTitle + "\n" + pbDate;
pbcontainer.addEventListener(MouseEvent.CLICK, 
pbMouseOverListener, true); // changed to click to make it easier to 
track
   
scrollableBase.addChild(pbcontainer);

}
   
private function pbMouseOverListener(e:MouseEvent):void

{
if (e.eventPhase == EventPhase.CAPTURING_PHASE)
{
mfTextField.text = e.target.rolloverText;
trace (e.target.rolloverText);
mouseFollower.visible = true;
}
}

really hope you can help because i'm stumped (and it's 12.15 am ;) )

a




On 31 Mar 2008, at 23:20, Allandt Bik-Elliott (Receptacle) wrote:

i have the moock book but i couldn't get my head round the bubbling 
phase and how it affected me - i need to look into it a bit more


i added mouseChildren=false but it made the entire event stop - even 
on the objects that were working before, and i didn't even get the error


is this because i've drawn directly in the sprite?

here's what i did:

private function createPeriodBar(dateStart:int, dateEnd:int, 
pbTitle:String, pbDate:String, pbList:Array = null):void

{
var pixelStart:int = yearsToPixels(dateStart);
var pixelEnd:int   = yearsToPixels(dateEnd);
   
var pbX:int = pixelStart;

var pbWidth:int = pixelEnd - pixelStart;
   
var pbYStart:int = taTitleBarHeight + pbSpace;
var pbY:int = pbYStart + pbGetY(date

Re: [Flashcoders] AS3 MouseEvent target?

2008-03-31 Thread Allandt Bik-Elliott (Receptacle)
okay i've tried everything i can find in the book re: this problem  
and it doesn't seem to be having any affect


i've tried the mouseChildren option (commented out) and useCapture  
tomfoolery (seems to be firing in the CAPTURING_PHASE as that's the  
only one i can get any result from) and i've also tried separating  
the graphic elements from the container displayobject to get rid of  
any code wierdness. I've even tried putting the solid block on top of  
the text and applying the event to that but none of it has worked.


here is my code (with eventphase extra bits in place):

		private function createPeriodBar(dateStart:int, dateEnd:int,  
pbTitle:String, pbDate:String, pbList:Array = null):void

{
var pixelStart:int = yearsToPixels(dateStart);
var pixelEnd:int   = yearsToPixels(dateEnd);

var pbX:int = pixelStart;
var pbWidth:int = pixelEnd - pixelStart;

var pbYStart:int = taTitleBarHeight + pbSpace;
			var pbY:int = pbYStart + pbGetY(dateStart, dateEnd) * (pbHeight 
+pbSpace);


var pbcontainer:MovieClip = new MovieClip();
var pb:Shape = new Shape();

if (uint(dateEnd-dateStart) > 1)
{
pb.graphics.beginFill(0xFF,.3);// white 50% 
alpha

pb.graphics.drawRoundRect(0,0,pbWidth,pbHeight,pbHeight);
pb.graphics.endFill();
pbcontainer.x = pbX;
pbcontainer.y = pbY;

var pbText:SimpleTextField = new SimpleTextField(0xFF, 14,  
headingFont, 4, -2, pbWidth-4, 25, pbTitle, false);

pbText.selectable = false;
pbText.text += " ";
pbText.text += pbDate;
var pbf:TextFormat = new TextFormat();
pbf.font= 
subheadingFont;
pbf.size= 10;
var pbCurrentLength = 
pbTitle.length+1;
var pbDateLength= pbText.length;
pbText.setTextFormat(pbf, pbCurrentLength, 
pbDateLength);

pbcontainer.addChild(pbText);
pbcontainer.addChild(pb);
//pb.mouseChildren = false; //
} else
{
pb.graphics.beginFill(0xFF,.5);// white 50% 
alpha
pb.graphics.drawCircle(0,0,pbHeight/2);
pb.graphics.endFill();
pbcontainer.x = pbX;
pbcontainer.y = pbY+(pbHeight/2);

pbcontainer.addChild(pb);
}
pbcontainer.rolloverText = pbTitle + "\n" + pbDate;
			pbcontainer.addEventListener(MouseEvent.CLICK,  
pbMouseOverListener, true); // changed to click to make it easier to  
track


scrollableBase.addChild(pbcontainer);
}

private function pbMouseOverListener(e:MouseEvent):void
{
if (e.eventPhase == EventPhase.CAPTURING_PHASE)
{
mfTextField.text = e.target.rolloverText;
trace (e.target.rolloverText);
mouseFollower.visible = true;
}
}

really hope you can help because i'm stumped (and it's 12.15 am ;) )

a




On 31 Mar 2008, at 23:20, Allandt Bik-Elliott (Receptacle) wrote:

i have the moock book but i couldn't get my head round the bubbling  
phase and how it affected me - i need to look into it a bit more


i added mouseChildren=false but it made the entire event stop -  
even on the objects that were working before, and i didn't even get  
the error


is this because i've drawn directly in the sprite?

here's what i did:

		private function createPeriodBar(dateStart:int, dateEnd:int,  
pbTitle:String, pbDate:String, pbList:Array = null):void

{
var pixelStart:int = yearsToPixels(dateStart);
var pixelEnd:int   = yearsToPixels(dateEnd);

var pbX:int = pixelStart;
var pbWidth:int = pixelEnd - pixelStart;
 

Re: [Flashcoders] AS3 MouseEvent target?

2008-03-31 Thread Allandt Bik-Elliott (Receptacle)
i have the moock book but i couldn't get my head round the bubbling  
phase and how it affected me - i need to look into it a bit more


i added mouseChildren=false but it made the entire event stop - even  
on the objects that were working before, and i didn't even get the error


is this because i've drawn directly in the sprite?

here's what i did:

		private function createPeriodBar(dateStart:int, dateEnd:int,  
pbTitle:String, pbDate:String, pbList:Array = null):void

{
var pixelStart:int = yearsToPixels(dateStart);
var pixelEnd:int   = yearsToPixels(dateEnd);

var pbX:int = pixelStart;
var pbWidth:int = pixelEnd - pixelStart;

var pbYStart:int = taTitleBarHeight + pbSpace;
			var pbY:int = pbYStart + pbGetY(dateStart, dateEnd) * (pbHeight 
+pbSpace);


var pb:MovieClip = new MovieClip();

if (uint(dateEnd-dateStart) > 1)
{
pb.graphics.beginFill(0xFF,.3);// white 50% 
alpha

pb.graphics.drawRoundRect(0,0,pbWidth,pbHeight,pbHeight);
pb.graphics.endFill();
pb.x = pbX;
pb.y = pbY;

var pbText:SimpleTextField = new SimpleTextField(0xFF, 14,  
headingFont, 4, -2, pbWidth-4, 25, pbTitle, false);

pbText.selectable = false;
pbText.text += " ";
pbText.text += pbDate;
var pbf:TextFormat = new TextFormat();
pbf.font= 
subheadingFont;
pbf.size= 10;
var pbCurrentLength = 
pbTitle.length+1;
var pbDateLength= pbText.length;
pbText.setTextFormat(pbf, pbCurrentLength, 
pbDateLength);

pb.addChild(pbText);
pb.mouseChildren =  
false; / 
<<- HERE

} else
{
pb.graphics.beginFill(0xFF,.5);// white 50% 
alpha
pb.graphics.drawCircle(0,0,pbHeight/2);
pb.graphics.endFill();
pb.x = pbX;
pb.y = pbY+(pbHeight/2);
}
pb.rolloverText = pbTitle + "\n" + pbDate;
			pb.addEventListener(MouseEvent.MOUSE_OVER, pbMouseOverListener,  
true);


scrollableBase.addChild(pb);
}

thanks for your input so far

a


On 31 Mar 2008, at 22:30, Steven Sacks wrote:

IMO, explaining Event Bubbling as the reason the TextField is the  
target is complicating the immediate solution he needs, which is  
mouseChildren = false.


Yes, it's Event Bubbling that's causing the target to be the  
TextField.  To understand Event Bubbling, read about it in the  
docs, or better yet, in a book (like Moock's).  But, then you MUST  
do it yourself to learn how it works.  If you don't play with it  
yourself, you will never "get it" no matter how much somebody  
explains it to you.  I'm fully convinced of that.  You gotta mess  
around with it to fully understand why it's so amazingly awesome.


___
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


Re: [Flashcoders] AS3 MouseEvent target?

2008-03-31 Thread Steven Sacks
IMO, explaining Event Bubbling as the reason the TextField is the target 
is complicating the immediate solution he needs, which is mouseChildren 
= false.


Yes, it's Event Bubbling that's causing the target to be the TextField.  
To understand Event Bubbling, read about it in the docs, or better yet, 
in a book (like Moock's).  But, then you MUST do it yourself to learn 
how it works.  If you don't play with it yourself, you will never "get 
it" no matter how much somebody explains it to you.  I'm fully convinced 
of that.  You gotta mess around with it to fully understand why it's so 
amazingly awesome.


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


Re: [Flashcoders] AS3 MouseEvent target?

2008-03-31 Thread jonathan howe
A perfect opportunity for someone more eloquent than I to explain event
bubbling.

On Mon, Mar 31, 2008 at 4:17 PM, Allandt Bik-Elliott (Receptacle) <
[EMAIL PROTECTED]> wrote:

> hi guys
>
> in actionscript 3, if i put a mouse event on a movieclip object
> containing a textfield, should the mouse event be on the movieclip or
> the textfield?
>
> here's my code (comments added to see where the problem is occurring)
> CODE
>private function createPeriodBar(dateStart:int,
> dateEnd:int,
> pbTitle:String, pbDate:String, pbList:Array = null):void
>{
>var pixelStart:int = yearsToPixels(dateStart);
>var pixelEnd:int   = yearsToPixels(dateEnd);
>
>var pbX:int = pixelStart;
>var pbWidth:int = pixelEnd - pixelStart;
>
>var pbYStart:int = taTitleBarHeight + pbSpace; //
> sets the
> starting point for all periodBars
>var pbY:int = pbYStart + pbGetY(dateStart, dateEnd)
> * (pbHeight
> +pbSpace); // pbGetY is a separate function that automatically stacks
> the periodBars where they will fit without overlapping
>
>var pb:MovieClip = new MovieClip(); // was a sprite
> but sprites
> cannot have strings attached to them, eg my rolloverText variable
>
>if (uint(dateEnd-dateStart) > 1) // if the
> difference between the
> start and end dates is more than 1
>{
>pb.graphics.beginFill(0xFF,.3);
>pb.graphics.drawRoundRect
> (0,0,pbWidth,pbHeight,pbHeight);
>pb.graphics.endFill();
>pb.x = pbX;
>pb.y = pbY;
>
>var pbText:SimpleTextField = new
> SimpleTextField(0xFF, 14,
> headingFont, 4, -2, pbWidth-4, 25, pbTitle, false);
>pbText.selectable = false; // tried making
> this non-selectable
> but it hasn't helped
>pbText.text += " ";
>pbText.text += pbDate;
>var pbf:TextFormat = new TextFormat();
>pbf.font=
> subheadingFont;
>pbf.size=
> 10;
>var pbCurrentLength =
> pbTitle.length+1;
>var pbDateLength=
> pbText.length;
>pbText.setTextFormat(pbf, pbCurrentLength,
> pbDateLength);
>
>pb.addChild(pbText);
>
>} else {
>// will create a dot instead of a box
> containing text if it will
> otherwise be too small to render a roundrect
>pb.graphics.beginFill(0xFF,.5);
>pb.graphics.drawCircle(0,0,pbHeight/2);
>pb.graphics.endFill();
>pb.x = pbX;
>pb.y = pbY+(pbHeight/2);
>}
>
>pb.rolloverText = pbTitle + "/n" + pbDate;
>pb.addEventListener(MouseEvent.MOUSE_OVER,
> pbMouseOverListener);
>
>scrollableBase.addChild(pb);
>}
>
>private function pbMouseOverListener(e:MouseEvent):void
>{
>mfTextField.text = e.target.rolloverText; //
> mfTextField is a
> textfield within a mousefollower
>trace (e.target); // traces simpleTextField if over
> a movieclip
> with a simpletextfield in otherwise traces movieclip
>trace (e.target.rolloverText); // gives error when
> over a
> simpletextfield but works properly when over a movieclip without, eg
> where the dates are too close and a dot is rendered instead
>mouseFollower.visible = true;
>}
>
> because the movieclip isn't always the target (even tho i've set the
> mouseevent on the movieclip), i can't consistently get a reading from
> rolloverText (because it's trying to find the variable rolloverText
> in the pbText SimpleTextField)
>
> can anyone explain why this is and what i can do to get around it
> please?
>
> thanks a lot
> a
>
> Allandt Bik-Elliott
> thefieldcomic.com
> e [EMAIL PROTECTED]
>
> ___
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>



-- 
-jonathan howe :: 404.434.2321 :: 180 High St Apt 26 Portland, ME 04101
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/fla

Re: [Flashcoders] AS3 MouseEvent target?

2008-03-31 Thread Kenneth Kawamoto

Try setting mouseChildren to false

Kenneth Kawamoto
http://www.materiaprima.co.uk/

Allandt Bik-Elliott (Receptacle) wrote:

hi guys

in actionscript 3, if i put a mouse event on a movieclip object 
containing a textfield, should the mouse event be on the movieclip or 
the textfield?


here's my code (comments added to see where the problem is occurring)
CODE
private function createPeriodBar(dateStart:int, dateEnd:int, 
pbTitle:String, pbDate:String, pbList:Array = null):void

{
var pixelStart:int = yearsToPixels(dateStart);
var pixelEnd:int   = yearsToPixels(dateEnd);
   
var pbX:int = pixelStart;

var pbWidth:int = pixelEnd - pixelStart;
   
var pbYStart:int = taTitleBarHeight + pbSpace; // sets the 
starting point for all periodBars
var pbY:int = pbYStart + pbGetY(dateStart, dateEnd) * 
(pbHeight+pbSpace); // pbGetY is a separate function that automatically 
stacks the periodBars where they will fit without overlapping
   
var pb:MovieClip = new MovieClip(); // was a sprite but 
sprites cannot have strings attached to them, eg my rolloverText variable
   
if (uint(dateEnd-dateStart) > 1) // if the difference 
between the start and end dates is more than 1

{
pb.graphics.beginFill(0xFF,.3);
pb.graphics.drawRoundRect(0,0,pbWidth,pbHeight,pbHeight);
pb.graphics.endFill();
pb.x = pbX;
pb.y = pbY;
   
var pbText:SimpleTextField = new 
SimpleTextField(0xFF, 14, headingFont, 4, -2, pbWidth-4, 25, 
pbTitle, false);
pbText.selectable = false; // tried making this 
non-selectable but it hasn't helped

pbText.text += " ";
pbText.text += pbDate;
var pbf:TextFormat = new TextFormat();
pbf.font= subheadingFont;
pbf.size= 10;
var pbCurrentLength= pbTitle.length+1;
var pbDateLength= pbText.length;
pbText.setTextFormat(pbf, pbCurrentLength, pbDateLength);
   
pb.addChild(pbText);


} else {
// will create a dot instead of a box containing text if 
it will otherwise be too small to render a roundrect

pb.graphics.beginFill(0xFF,.5);
pb.graphics.drawCircle(0,0,pbHeight/2);
pb.graphics.endFill();
pb.x = pbX;
pb.y = pbY+(pbHeight/2);
}

pb.rolloverText = pbTitle + "/n" + pbDate;
pb.addEventListener(MouseEvent.MOUSE_OVER, 
pbMouseOverListener);
   
scrollableBase.addChild(pb);

}
   
private function pbMouseOverListener(e:MouseEvent):void

{
mfTextField.text = e.target.rolloverText; // mfTextField is 
a textfield within a mousefollower
trace (e.target); // traces simpleTextField if over a 
movieclip with a simpletextfield in otherwise traces movieclip
trace (e.target.rolloverText); // gives error when over a 
simpletextfield but works properly when over a movieclip without, eg 
where the dates are too close and a dot is rendered instead

mouseFollower.visible = true;
}

because the movieclip isn't always the target (even tho i've set the 
mouseevent on the movieclip), i can't consistently get a reading from 
rolloverText (because it's trying to find the variable rolloverText in 
the pbText SimpleTextField)


can anyone explain why this is and what i can do to get around it please?

thanks a lot
a

Allandt Bik-Elliott
thefieldcomic.com
e [EMAIL PROTECTED]


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


Re: [Flashcoders] AS3 MouseEvent target?

2008-03-31 Thread Steven Sacks

mc.mouseChildren = false;

or

event.currentTarget

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


[Flashcoders] AS3 MouseEvent target?

2008-03-31 Thread Allandt Bik-Elliott (Receptacle)

hi guys

in actionscript 3, if i put a mouse event on a movieclip object  
containing a textfield, should the mouse event be on the movieclip or  
the textfield?


here's my code (comments added to see where the problem is occurring)
CODE
		private function createPeriodBar(dateStart:int, dateEnd:int,  
pbTitle:String, pbDate:String, pbList:Array = null):void

{
var pixelStart:int = yearsToPixels(dateStart);
var pixelEnd:int   = yearsToPixels(dateEnd);

var pbX:int = pixelStart;
var pbWidth:int = pixelEnd - pixelStart;

			var pbYStart:int = taTitleBarHeight + pbSpace; // sets the  
starting point for all periodBars
			var pbY:int = pbYStart + pbGetY(dateStart, dateEnd) * (pbHeight 
+pbSpace); // pbGetY is a separate function that automatically stacks  
the periodBars where they will fit without overlapping


			var pb:MovieClip = new MovieClip(); // was a sprite but sprites  
cannot have strings attached to them, eg my rolloverText variable


			if (uint(dateEnd-dateStart) > 1) // if the difference between the  
start and end dates is more than 1

{
pb.graphics.beginFill(0xFF,.3);

pb.graphics.drawRoundRect(0,0,pbWidth,pbHeight,pbHeight);
pb.graphics.endFill();
pb.x = pbX;
pb.y = pbY;

var pbText:SimpleTextField = new SimpleTextField(0xFF, 14,  
headingFont, 4, -2, pbWidth-4, 25, pbTitle, false);
pbText.selectable = false; // tried making this non-selectable  
but it hasn't helped

pbText.text += " ";
pbText.text += pbDate;
var pbf:TextFormat = new TextFormat();
pbf.font= 
subheadingFont;
pbf.size= 10;
var pbCurrentLength = 
pbTitle.length+1;
var pbDateLength= pbText.length;
pbText.setTextFormat(pbf, pbCurrentLength, 
pbDateLength);

pb.addChild(pbText);

} else {
// will create a dot instead of a box containing text if it will  
otherwise be too small to render a roundrect

pb.graphics.beginFill(0xFF,.5);
pb.graphics.drawCircle(0,0,pbHeight/2);
pb.graphics.endFill();
pb.x = pbX;
pb.y = pbY+(pbHeight/2);
}

pb.rolloverText = pbTitle + "/n" + pbDate;
pb.addEventListener(MouseEvent.MOUSE_OVER, 
pbMouseOverListener);

scrollableBase.addChild(pb);
}

private function pbMouseOverListener(e:MouseEvent):void
{
			mfTextField.text = e.target.rolloverText; // mfTextField is a  
textfield within a mousefollower
			trace (e.target); // traces simpleTextField if over a movieclip  
with a simpletextfield in otherwise traces movieclip
			trace (e.target.rolloverText); // gives error when over a  
simpletextfield but works properly when over a movieclip without, eg  
where the dates are too close and a dot is rendered instead

mouseFollower.visible = true;
}

because the movieclip isn't always the target (even tho i've set the  
mouseevent on the movieclip), i can't consistently get a reading from  
rolloverText (because it's trying to find the variable rolloverText  
in the pbText SimpleTextField)


can anyone explain why this is and what i can do to get around it  
please?


thanks a lot
a

Allandt Bik-Elliott
thefieldcomic.com
e [EMAIL PROTECTED]

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


[Flashcoders] AS3 MouseEvent target?

2008-03-31 Thread Allandt Bik-Elliott (Receptacle)

hi guys

in actionscript 3, if i put a mouse event on a movieclip object  
containing a textfield, should the mouse event be on the movieclip or  
the textfield?


here's my code (comments added to see where the problem is occurring)
CODE
		private function createPeriodBar(dateStart:int, dateEnd:int,  
pbTitle:String, pbDate:String, pbList:Array = null):void

{
var pixelStart:int = yearsToPixels(dateStart);
var pixelEnd:int   = yearsToPixels(dateEnd);

var pbX:int = pixelStart;
var pbWidth:int = pixelEnd - pixelStart;

			var pbYStart:int = taTitleBarHeight + pbSpace; // sets the  
starting point for all periodBars
			var pbY:int = pbYStart + pbGetY(dateStart, dateEnd) * (pbHeight 
+pbSpace); // pbGetY is a separate function that automatically stacks  
the periodBars where they will fit without overlapping


			var pb:MovieClip = new MovieClip(); // was a sprite but sprites  
cannot have strings attached to them, eg my rolloverText variable


			if (uint(dateEnd-dateStart) > 1) // if the difference between the  
start and end dates is more than 1

{
pb.graphics.beginFill(0xFF,.3);

pb.graphics.drawRoundRect(0,0,pbWidth,pbHeight,pbHeight);
pb.graphics.endFill();
pb.x = pbX;
pb.y = pbY;

var pbText:SimpleTextField = new SimpleTextField(0xFF, 14,  
headingFont, 4, -2, pbWidth-4, 25, pbTitle, false);
pbText.selectable = false; // tried making this non-selectable  
but it hasn't helped

pbText.text += " ";
pbText.text += pbDate;
var pbf:TextFormat = new TextFormat();
pbf.font= 
subheadingFont;
pbf.size= 10;
var pbCurrentLength = 
pbTitle.length+1;
var pbDateLength= pbText.length;
pbText.setTextFormat(pbf, pbCurrentLength, 
pbDateLength);

pb.addChild(pbText);

} else {
// will create a dot instead of a box containing text if it will  
otherwise be too small to render a roundrect

pb.graphics.beginFill(0xFF,.5);
pb.graphics.drawCircle(0,0,pbHeight/2);
pb.graphics.endFill();
pb.x = pbX;
pb.y = pbY+(pbHeight/2);
}

pb.rolloverText = pbTitle + "/n" + pbDate;
pb.addEventListener(MouseEvent.MOUSE_OVER, 
pbMouseOverListener);

scrollableBase.addChild(pb);
}

private function pbMouseOverListener(e:MouseEvent):void
{
			mfTextField.text = e.target.rolloverText; // mfTextField is a  
textfield within a mousefollower
			trace (e.target); // traces simpleTextField if over a movieclip  
with a simpletextfield in otherwise traces movieclip
			trace (e.target.rolloverText); // gives error when over a  
simpletextfield but works properly when over a movieclip without, eg  
where the dates are too close and a dot is rendered instead

mouseFollower.visible = true;
}

because the movieclip isn't always the target (even tho i've set the  
mouseevent on the movieclip), i can't consistently get a reading from  
rolloverText (because it's trying to find the variable rolloverText  
in the pbText SimpleTextField)


can anyone explain why this is and what i can do to get around it  
please?


thanks a lot
a

Allandt Bik-Elliott
thefieldcomic.com
e [EMAIL PROTECTED]

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