CinkoNaap Posted March 5, 2014 Share Posted March 5, 2014 Hey,I wonder is there a solution to listen to an event being dispatched from nested object. In my case it looks like this:SomeScreen is an object extending from PIXI.DisplayObjectContainerSomeComponent which is nested inside SomeScreen, also extends from PIXI.DisplayObjectContainerSomeScreenMediator, having reference to SomeScreen instancenow in SomeComponent i want to dispatch an event, for example:this.dispatchEvent( { type: 'worldIndexChanged', data: { index: this._currentIndex } } );and in best scenario I could listen to this event from my mediator by listening to SomeScreen like this:this.someScreen.addEventListener( 'worldIndexChanged', function(e){ console.log('hey'); } );and not like this:this.someScreen.someComponent.addEventListener( 'worldIndexChanged', function(e){ console.log('hey'); } );I know that this is what event-bubbling is all about, but I wonder is there any way to achive this using PIXI.EventTarget 'class'.Regards,Marcin Quote Link to comment Share on other sites More sharing options...
xerver Posted March 5, 2014 Share Posted March 5, 2014 We do not have event bubbling (yet). We are investigating the best ways to implement it. Quote Link to comment Share on other sites More sharing options...
CinkoNaap Posted March 5, 2014 Author Share Posted March 5, 2014 So for now the best solution would be direct listen to the target object? Quote Link to comment Share on other sites More sharing options...
xerver Posted March 5, 2014 Share Posted March 5, 2014 Events will only dispatch directly from the object the emits them, so the only solution is to listen directly on an object. Quote Link to comment Share on other sites More sharing options...
CinkoNaap Posted March 5, 2014 Author Share Posted March 5, 2014 thanks for quick response ( as always :> ) Quote Link to comment Share on other sites More sharing options...
codebelt Posted May 25, 2016 Share Posted May 25, 2016 I too would like to see event bubbling in Pixi.js. I am a former ActionScript developer and created my own JavaScript library that has many ActionScript conventions. Take a look at my EventDispatcher class (docs) for idea's on how to implement event bubbling. Event Bubbling Demo. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.