This content has been marked as final.
Show 9 replies
-
1. Re: Capture phase never happens for timer event
kglad Feb 22, 2008 11:37 PM (in response to sneakyimp)it makes no sense to talk about a child of a timer instance so how can a timer instance be triggered during anything other than the target phase? -
2. Re: Capture phase never happens for timer event
sneakyimp Feb 23, 2008 2:37 AM (in response to sneakyimp)To be honest, i'm not really sure that it makes sense for the MovieClip parent of a button to receive the CLICK event of that button. It's all well and good for someone who knows this stuff inside and out to say it makes no sense, but I'm trying to understand it and was hoping for more information.
Like:
* which Event types bubble and which don't? Does the documentation have some indication?
* What about if the Timer is a dynamic property of some MovieClip? Will it bubble then?
-
3. Re: Capture phase never happens for timer event
kglad Feb 23, 2008 7:47 AM (in response to sneakyimp)you don't think it makes sense for a parent to receive the events directed at a child??? have you ever made a hierarchal menu with as1/as2?
one of the significant advantages of as3 over as2/as1 IS that both parent objects can receive mouse events AND child objects can receive mouse events. adobe completely redid the event class to allow this.
just look at the as1/as2 forum. i think between 5% and 10% of the problems are caused by users failing to recognize that a mouse handler defined on a parent movieclip will intercept mouse events from being detected by child movieclips.
everyone that's ever made a hierarchal menu with as1/as2 has faced this issue and had to develop a work-around. not so with as3 because of event flow. -
4. Re: Capture phase never happens for timer event
sneakyimp Feb 24, 2008 4:26 PM (in response to sneakyimp)I understand a little better now the rationale behind event bubbling, however my original questions are still not answered:
1) Does this mean timer events don't bubble? What if the timer is a property of something in the display list?
2) Is there some good rule of thumb for which events bubble and which do not?
3) If there's no rule of thumb, is there some list or reference in the on-line flash docs?
Please don't think I'm not reading about this constantly. I have "Actionscript 3 Cookbook by Lott/Schall/Peters" and am still confused. For instance the root class for a flash movie doesn't respond to the MouseOver Event. I have no idea why. As far as I can tell there is little rhyme or reason to which events bubble and which do not and, as usual, available actionscript documentation does little to clear things up.
-
5. Re: Capture phase never happens for timer event
kglad Feb 24, 2008 4:47 PM (in response to sneakyimp)1. correct, it doesn't bubble: there's no display list for the event to bubble through. and the timer can't be added to the display list because it's not a displayobject and doesn't inherit from the displayobject.
2&3. you can use the bubbles property of any event to determine if the event can bubble. -
6. Re: Capture phase never happens for timer event
sneakyimp Feb 26, 2008 6:31 PM (in response to sneakyimp)Thanks for the response. This is a bit much to wrap my head around. I've realized a couple of things:
* It wouldn't make any sense to add an event listener to a MovieClip object to listen for the event of type TimerEvent.TIMER because a MovieClip will never ever dipatch that type of event. (right?)
* The documentation for the various event types (like here http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/events/TimerEvent.html#TIM ER) has a table that describes whether an event bubbles or not. I haven't yet studied them enough to determine any patterns, but I suspect I'll be able to determine whether a given event bubbles or not by checking the docs for Events.
-
7. Re: Capture phase never happens for timer event
kglad Feb 26, 2008 9:44 PM (in response to sneakyimp)check the docs or use the bubbles property of any event in the authoring environment to see if it can bubble. -
8. Re: Capture phase never happens for timer event
sneakyimp Feb 26, 2008 11:02 PM (in response to sneakyimp)Well the docs are a bit confusing. Check out the docs on the TimerEvent class. Apparently the constructor lets you create a TimerEvent with bubbles = true (see the 2nd parameter?).
On the other hand, both types of timer event have bubbles=false
Also, it kind of sucks to have to create a test sample to determine the value of some attribute of an object. -
9. Capture phase never happens for timer event
Mike Close Mar 11, 2008 7:29 PM (in response to sneakyimp)Looking at Adobe's fl.controls.BaseButton class shows the pattern you need. Find the file by searching for a file called "BaseButton.as" on your computer, and if you find more than one, it's the one inside the "controls" folder inside the "fl" folder. It shows a good pattern to use when you want a Timer event to bubble. In the BaseButton class, repeating BUTTON_DOWN events are broadcast when anything that extends BaseButton is pressed and held by the user.
Basic flow:
1. The class listens for all MouseEvent events with the same handler: mouseEventHandler()
2. If mouseEventHandler(event:MouseEvent) gets an event of type MouseEvent.MOUSE_DOWN, it calls startPress.
3. The startPress() method starts the pressTimer instance of Timer
4. The Timer is calling buttonDown() every millisecond. (really?)
5. The buttonDown() method dispatches the BUTTON_DOWN component event with bubbling set to true.
Hope this helps.
-Mike



