ActionScript 1/2 :: Pass The Event Onwards Through The Event Bubbling Flow?
Apr 18, 2010I have:
Class my_class
{ public function my_class( an_mc )
{
[code]....
I have:
Class my_class
{ public function my_class( an_mc )
{
[code]....
I know the difference between the two, but I never felt the need to use the bubbling feature. If I want to listen to an event from a deeply nested children, I always use the capture phase. Could someone explain to me why I should rather use bubbling, its advantages, and maybe show me a situation in which bubbling would be the only solution?
View 5 RepliesWhat is the use of event bubbling and event capturing?
View 3 RepliesWhat is event bubbling in Flex?
View 1 RepliesActually I wanted to know what is bubbling event and how to make use of it. Also, what is the concept of capturing, targeting and bubbling too?
View 2 RepliesI have a movie clip (cover) which covers another movie clip (stuff).I have set up Mouse Over on the Cover movie clip so that when you mouse over it, it tweens off of the Stuff movie clip.Then i have Mouse out set up on the Stuff movie clip so when you mouse out of it, the Cover clip tweens back in..
Now when I mouse over a MC that is inside the Stuff movie clip..it triggers the mouse out for the Stuff movie clip. this is undesired.I need my mouse to be active inside the Stuff movie, so mouseChildren = false doesn't work,because i then can not click on things inside the stuff movie clip.Right now i have managed to work around this by running a loop for each child inside the stuff, adding an event listener and telling the tween to stop on those events,but this won't work for children of those children without looping again.. and the children of those children's children would need looped as well... The question is.. How do I make a child movie clip not trigger the mouse out for it's parent(s)?
I have a content clip that gets replaced by a movieClip from the library every time a button is clicked. Some of the content sections contain video. Within the video is a custom event firing that bubbles up through its parent clips all the way until it gets to the clip that was added to the stage on user click. It never goes beyond the content clip to the stage, where I need the listener. Isn't an event supposed to bubble all the way up to the stage? Why would it ever stop?The code is in 10 different places in 10 different files or else I'd post it.
View 3 RepliesI can't figure out why the event listener callback function isn't being fired when a child object is being clicked. Since the "SelectionPoint" object is a child of this class, shouldn't the listener get notified of the MouseEvent.CLICK event during the capture phase?
Code:
package {
import flash.display.*;
[code]....
In IE, if flash has focus, and receives a keydown event, it does not appear to bubble the event up through the DOM (I can't capture the event by listening on document, however the same listener can capture key events from html siblings, so I know my listener is working).
However, some other plugins on the page (I am looking at you windows media player) still respond to key events that initiate in flash (and I need to prevent that from happening)! It seems that the key event initiated in flash takes the bubble express highway straight to the top (where the top is whatever is above document in the DOM hierarchy). I have tried terminating the events in as3, and tried different wmodes... neither approach works.
I have a MovieClip which contains 4 Buttons:When the user mouses out of the container, it shoulddisappear:this.resolutions.addEventListener(MouseEvent.MOUSE_OUT,this.resolutionsClose);When the user mouses out of any of the 4 Buttons, the event bubbles up to the container. This is not the expected behavior. How do I stop this propagation when none of the 4 Buttons have mouse out handlers?
View 3 RepliesWhat is the difference between event.bubbles to false for any event, And Setting event.stopPropagaion() or stopImmidiatePropagation() while handling event? I am using flex4 with as3.
View 3 Replies"allows child clips to receive events despite the fact that a parent might make use of them as well, something not possible with the normal convention of handling button events where no child movie clip ever receives button events if a parent has any button event handlers defined for it." how to attach an event to an mc called "child_next" within "parent1".
Code:
import com.senocular.events.*
function handleEventMethod(eventObject:ButtonEvent):Void {
// trace event
if (eventObject.type != "onMouseWithin") trace(eventObject.type +"("+this+")");
[code]....
I'm wanting to bubble events between a few custom classes, however, they are not Display Objects.Is there any quick and easy way to do event bubbling, without needing a display list?Or perhaps another way than needing to manually listen for each event that is attached and "relay" it every time it is dispatched?
View 1 RepliesI am having trouble with event bubbling when using the flash video player I've tried several methods to stop the player,before submitting here - but nothing I've tried seems to work The scenraio is: The site loads great - the buttons function correctly When the fourth button is click - it loads a frame with an embeded FLV player (the default vid player Flash uses when importing video into the swf) When the fourth button is click (Cheetah Coloring System)The video starts to play When any other button is clicked The video continues to play The embeded vid clip is named movie1 and i've tried using move1.stop(); but that stops the entire swf how to stop the movie - when another button is clicked?
COde used for the buttons::::
btn1_mc.addEventListener(MouseEvent.MOUSE_DOWN, bhp1DownHandler);function bhp1DownHandler(event:MouseEvent):void {gotoAndStop(15);}
btn2_mc.addEventListener(MouseEvent.MOUSE_DOWN, bhp2DownHandler);function bhp2DownHandler(event:MouseEvent):void {gotoAndStop(16);}
btn3_mc.addEventListener(MouseEvent.MOUSE_DOWN, bhp3DownHandler);function bhp3DownHandler(event:MouseEvent):void {gotoAndStop(17);}
btn4_mc.addEventListener(MouseEvent.MOUSE_DOWN, bhp4DownHandler);function bhp4DownHandler(event:MouseEvent):void {gotoAndStop(18);}
Environment:
Windows 7,
Internet Explorer 8,
Flash ActiveX 10.1.53.64,
wmode=transparent
Just wrote a small test page that you can load in IE and Firefox or any other Browser.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
[Code].....
So clicking any colored shape should produce an alert (except for the green one in IE, not sure why but I hope that's off topic and not related to my issue).
Clicking the Flash container in Firefox will work Perfectly fine. You should get alert boxes in this order containing: span, div and body. Flash bubbles the event to the HTML. But this is not happening in IE.
So why is Flash in IE not bubbling events to HTML?
Edit: As mentioned by Andy E this behavior can also bee seen in Google Chrome which to my knowledge is not using ActiveX to embed the flash movie into the page.
In IE, if flash has focus, and receives a keydown event, it does not appear to bubble the event up through the DOM (I can't capture the event by listening on document, however the same listener can capture key events from html siblings, so I know my listener is working).However, some other plugins on the page (I am looking at you windows media player) still respond to key events that initiate in flash (and I need to prevent that from happening)! It seems that the key event initiated in flash takes the bubble express highway straight to the top (where the top is whatever is above document in the DOM hierarchy).I have tried terminating the events in as3, and tried different wmodes... neither approach worls. Is there something I might have missed?
View 0 RepliesI have a utility class that I use to load images that never gets added to the stage and is extending EventDispatcher, it simply loads the data and spits it back out on request.
I want to add a custom event to track loading progress from outside the class. The events are firing but not (i think) bubbling because they aren't in the display list.
Is there a good way around this? I was thinking: Can I have a non display list object tell a display object to send the custom event for it?
I'm stepping through my code to figure out why a certain function takes more time to run the first time it gets called than on successive calls. The code flow for each function call is the same up to when a dispatchEvent gets called. I'm pretty sure it's different afterwards, as that call takes a lot more time the first time around. Unfortunately, I have no idea which other parts of the code chew on this specific event and thus cannot step through the handling of such event.
The question: is there a way to either figure out who handles such events or magically step through the handling code without explicitly setting breakpoints there?
I have searched on the Internet and didn't find any clue on how to do so, any idea ? I don't want flex only flash (my objects are not visual components).
View 3 RepliesI want to dispatch a MouseEvent.CLICK to a DisplayObject manually and make it bubble through all of it's children. The event is handled in the object that I dispatch it to, but does not seem to bubble (even though I specify that it should). Is it not possible to do this?
Code:
_targetObject.dispatchEvent(new MouseEvent(MouseEvent.CLICK, true));
Code:
private function handleClick(event:MouseEvent):void
{
This method is executed, but no children will receive this event.
}
There's a lot of talk of how the new Event Flow makes for easier communication between classes.This sounds swell,but nowhere is it properly explained. Every example I find concerns dispatching events within the same class or looped through a customEvent, but I need a way to tap into this Event Flow for backward communication.I have a mainGUI document class that distributes my application subclasses.How do I set up a listener within mainGUI that gathers certain events from any of its children or grand-children? And how can I use this line to post object properties?
View 1 RepliesMy goal is to shoot a bullet everytime I click on ship. What happens, in fact, is that If I click on it once, the bullet is shot, but if I click on it twice before the first bullet is off the screen, the first bullet literally stops(it does not disappear, only stops) and the second bullet is shot.
public var ship:Ship = new Ship();
public var bullet:Bullet = new Bullet();
stage.addChild(ship);[code]...
What is the proper OOP method of communicating between classes that are not on the display list?
For example: The Document class instantiates a new class just for loading in different XML files. This XmlLoading class should let the document class know when the xml has been loaded and parsed so that the interface can be built out.
From my understanding, events can only be listened to and dispatched through the display list, but since there is nothing visual with this xml loader, it doesn't make sense to me to make this class extend a sprite and add it as a child of the document class.
I have a MouseEvent.MOUSE_WHEEL eventlistener setup for a custom scrollbar component that allows the wheel to control the scrolling up or down.Inside the Flash dev environment when I test the flash app it works fine. However, when I test the app inside a web browser ( which has its own vertical scrollbar ) the mouse wheel controls both the scrollbar in my flash app and the scrollbar in the browser.Is there a way to setup the eventlistener on my scrollbar that it prevents the MOUSE_WHEEL event from bubbling up to the browser?
View 3 RepliesI m building a little application, im design the graphic in Flash and im using Flash Builder for the Programming Side. I have 5 MovieClip inside a Sprite (the container), and i want to listen for MOUSE.CLICK. I add the event listener to the Sprite, instead of one for MovieClip, and its working good like this.
What if inside the Sprite (the container) i have also a TextField and exclude it from the event flow?
Is there a way to make event flow occur synchronously?
Basically this is my scenario. I have a single method call that gets triggered by a server request. I want to be able to notifiy subscribers that the method has/is executing so that they may return a result. By modifying an attribute of the actual event object, the method can return that result to the server dynamically. Eg:
Code:
//method invoked by server
public function whatever(...parameters):* {
var event:MyEvent = new MyEvent(MyEvent.TYPE);
[Code]....
This code works around 70% of the time, but sometimes I see things are really happening asynchronously in Flash Player's event flow. Is there anything I can do to regulate this and make sure it happens synchronously?
Is there a point of creating custom event class if i dont need to pass custom property with that event?
View 3 RepliesForgive me for this stupid noob question but I want to call a function (loadList) that originally gets triggered after a mouseevent from another function (addToXML) that does not have an event.
The loadList function takes info from a XML var, sticks it into an array which then gets loaded into a tile list and that is working fine.
The addToXML function when called adds elements to the XML var after which I want to call the first function with the event parameter so it refreshes the items in the tile list.
I know it can do this by creating a new array and loading that into the tile list in the addToXML function, but it be much simpler to just recall the function.
I have tried things like
Code:
addToXML.addEventListener(Event.COMPLETE, loadList);
but all the event constants I have tried give me error messges like "1061: Call to a possibly undefined method addEventListener through a reference with static type Function."
I have editable grids which are 2-way binded to my model. What I want is to validate my data when user edits any cell before it get updated in model. I have applied my validation at ItemEditEnd handler, but, I want to apply validation in between itemEditBegin and itemEditEnd events.
View 1 RepliesI hava a custom component and it contains a child icon. If I add a mouse-click event listener to both component(click-listener1) and icon(click-listener2), the event dispatched sequence is click-listener2, then click-listener1. I can understand it. But if I add a custom event to component (listener1), and mouse-click event to icon(listener2), when icon is clicked, the component will dispatch the custom event. In my test, the event dispatched sequence is listener1, then listener2. It doesn't match with event-bubbles rule.
In my opinion The custom event is dispatched in listener2, which triggers listener1. Why event flow sequence is not listener2, listener1?
In component.
icon.addEventListener(MouseEvent.CLICK, iconClickHandler);
private function iconClickHandler(event:MouseEvent):void
{
[Code].....