PDA

View Full Version : Control A Sprite



Andreas_S
15 Nov 2011, 6:59 AM
Hi,

i have some problems with controlling a Ext.draw.Sprite via the controller.
At the moment i use the ".on" method to add eventlisteners to a sprite, but i'd like to control the sprite in my controller. Controlling the Ext.draw.Component is not a problem, it works fine.

this.control({
'draw': {
click: function(){console.log('it works');}
}
});
But when i use the same Code with sprite it doesn't work. I also tried using the ID of the sprite, but that doesn't work either.

this.control({
'sprite': {
click: function(){console.log('it doesnt work');}
}
});
I would be very happy if anyone could give me a hint for the solution of my problem.

best regards
Andreas

mitchellsimoens
16 Nov 2011, 1:06 PM
this.control uses ComponentQuery which allows putting listener on any subclass of Ext.Component. Ext.draw.Sprite extends Ext.Base so it isn't a subclass of Ext.Component.

Easy way to tell if you can use ComponentQuery is look at the API docs and see if Ext.Component is in the hierarchy...

29344
29345

See how Ext.draw.Component (the 2nd picture) is a subclass of Ext.Component and Ext.draw.Sprint is not?

Andreas_S
17 Nov 2011, 12:03 AM
Thanks for your helpful reply.

On the one hand it's bad that it doesn't work, but on the other hand it is good to know why it doesn't work.

best regards
Andreas