Re: [flexcoders] custom event not added
ah. Little slow on this end. I will see if I can get it to work d On 24-May-08, at 6:59 PM, Josh McDonald wrote: As in, I've got no idea what's going on :) Application.application should always point to the running instance of your mx:Application On Sun, May 25, 2008 at 2:19 AM, dnk [EMAIL PROTECTED] wrote: fire? As in scrap and rewrite? dnk On 23-May-08, at 10:25 PM, Josh McDonald wrote: If you're getting a runtime error accessing Application.application you'll need fire to clean this up, methinks. -J On Sat, May 24, 2008 at 3:02 PM, dnk [EMAIL PROTECTED] wrote: That added an error: Access of undefined property Application researching that now... d On 23-May-08, at 9:35 PM, Josh McDonald wrote: The only thing i can think of after looking at that is that your controller (whatever that is) is not part of the display tree? Try replacing dispatchEvent() with Application.application.dispatchEvent() and see if it works then. -J On Sat, May 24, 2008 at 2:28 PM, dnk [EMAIL PROTECTED] wrote: It is dispatched like this (in function in my controller): dispatchEvent(new GetNewsEvent(GetNewsEvent.GET_NEWS_EVENT, null, false, false)); the null is used for an object (if I need to pass data with my event). In this particular case I did not. My actual event class looks like: package Flexb.events { import flash.events.Event; public class GetNewsEvent extends Event { protected var _data:Object; public static const GET_NEWS_EVENT:String=GetNewsEventType; public function GetNewsEvent( type:String, data:Object = null, bubbles:Boolean=true, cancelable:Boolean=false ):void { _data = data; super(GET_NEWS_EVENT,true,false); } public function get data():Object { return _data; } } } dnk On 23-May-08, at 6:16 PM, Josh McDonald wrote: What's the event dispatch code look like? On Sat, May 24, 2008 at 11:01 AM, dnk [EMAIL PROTECTED] wrote: ok, well that explains that part, however either my event is not added, or my event handler is never called. My trace statements never show up So I guess I still am wondering if anyone has any ideas dnk On 23-May-08, at 4:56 AM, Paul Andrews wrote: addEventListener() does not return a value.. - Original Message - From: dnk [EMAIL PROTECTED] To: flexcoders@yahoogroups.com Sent: Friday, May 23, 2008 12:47 PM Subject: [flexcoders] custom event not added Hi there, I have a controller that is adding my custom event listeners, but for some reason my event handler was not being fired. My original code was (snippet): (in controler) //constructor public function FlexbController() { //turn the key, start it up addEventListener( FlexEvent.CREATION_COMPLETE, onInit ); } private function onInit( event:Event ):void { //setup event listeners /*systemManager is where event listener hangs out defines the relationship between event and handler*/ systemManager.addEventListener( GetNewsEvent.GET_NEWS_EVENT, handler_GetNewsEvent ); systemManager.addEventListener( AddNewsEvent.ADD_NEWS_EVENT, handler_AddNewsEvent ); systemManager .addEventListener( NewsDataLoadedEvent.NEWS_LOADED_EVENT, handler_NewsLoadedEvent ); getNewsData(); } And I had trace statements in all of my handlers... this is how i noticed things were not working as they should. SO I added a simple check like (in my FlexbController constructor): if (systemManager.addEventListener( GetNewsEvent.GET_NEWS_EVENT, handler_GetNewsEvent )) { trace(true); } else { trace(false); } And I obviously am getting false. Ideas? dnk -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo! Groups Links -- Therefore, send not to know For whom the bell tolls. It tolls for thee. :: Josh 'G-Funk' McDonald :: 0437 221 380 :: [EMAIL PROTECTED] -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo ! Groups Links -- Therefore, send not to know For whom the bell tolls. It tolls for thee. :: Josh 'G-Funk' McDonald :: 0437 221 380 :: [EMAIL PROTECTED] -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail
Re: [flexcoders] custom event not added
ok, this is how my app is setup :: app.mxml :: has a: xmlns:controller=Flexb.controller.* controller:FlexbController/ That is how my controller is instantiated. :: FlexbController.as :: public class FlexbController extends UIComponent in my constructor I have: addEventListener( FlexEvent.CREATION_COMPLETE, onInit ); then in my onInit function I have: systemManager.addEventListener( GetNewsEvent.GET_NEWS_EVENT, handler_GetNewsEvent ); along with a call to another function: getNewsData(); (this one is called without issue). In that function I dispatch the custom event in question: dispatchEvent(new GetNewsEvent(GetNewsEvent.GET_NEWS_EVENT, null, false, false)); So when dispatch it should go to a handler function called handler_GetNewsEvent. And it is that event handler that never seems to be processed. I had a trace statement that never seems to show. And in that function there are some remoting calls that I never see happening in service capture. And that is where my app seems to fail. dnk On 24-May-08, at 9:09 PM, Alex Harui wrote: Who’s dispatching and how? When does the control get instantiated? Could it be after creationComplete? If the controller is not a UIComponent, it will not get a creationComplete. From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of dnk Sent: Friday, May 23, 2008 4:48 AM To: flexcoders@yahoogroups.com Subject: [flexcoders] custom event not added Hi there, I have a controller that is adding my custom event listeners, but for some reason my event handler was not being fired. My original code was (snippet): (in controler) //constructor public function FlexbController() { //turn the key, start it up addEventListener( FlexEvent.CREATION_COMPLETE, onInit ); } private function onInit( event:Event ):void { //setup event listeners /*systemManager is where event listener hangs out defines the relationship between event and handler*/ systemManager.addEventListener( GetNewsEvent.GET_NEWS_EVENT, handler_GetNewsEvent ); systemManager.addEventListener( AddNewsEvent.ADD_NEWS_EVENT, handler_AddNewsEvent ); systemManager.addEventListener( NewsDataLoadedEvent.NEWS_LOADED_EVENT, handler_NewsLoadedEvent ); getNewsData(); } And I had trace statements in all of my handlers... this is how i noticed things were not working as they should. SO I added a simple check like (in my FlexbController constructor): if (systemManager.addEventListener( GetNewsEvent.GET_NEWS_EVENT, handler_GetNewsEvent )) { trace(true); } else { trace(false); } And I obviously am getting false. Ideas? dnk -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo! Groups Links * To visit your group on the web, go to: http://groups.yahoo.com/group/flexcoders/ * Your email settings: Individual Email | Traditional * To change settings online go to: http://groups.yahoo.com/group/flexcoders/join (Yahoo! ID required) * To change settings via email: mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] * To unsubscribe from this group, send an email to: [EMAIL PROTECTED] * Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/
Re: [flexcoders] custom event not added
Josh, FYI, I got around the error, I had to use: mx.core.Application.application.dispatchEvent(new GetNewsEvent(GetNewsEvent.GET_NEWS_EVENT, null, false, false)); But event when targeting in this way as you suggested, it still did not help dispatch the event.. dnk On 23-May-08, at 10:25 PM, Josh McDonald wrote: If you're getting a runtime error accessing Application.application you'll need fire to clean this up, methinks. -J On Sat, May 24, 2008 at 3:02 PM, dnk [EMAIL PROTECTED] wrote: That added an error: Access of undefined property Application researching that now... d On 23-May-08, at 9:35 PM, Josh McDonald wrote: The only thing i can think of after looking at that is that your controller (whatever that is) is not part of the display tree? Try replacing dispatchEvent() with Application.application.dispatchEvent() and see if it works then. -J On Sat, May 24, 2008 at 2:28 PM, dnk [EMAIL PROTECTED] wrote: It is dispatched like this (in function in my controller): dispatchEvent(new GetNewsEvent(GetNewsEvent.GET_NEWS_EVENT, null, false, false)); the null is used for an object (if I need to pass data with my event). In this particular case I did not. My actual event class looks like: package Flexb.events { import flash.events.Event; public class GetNewsEvent extends Event { protected var _data:Object; public static const GET_NEWS_EVENT:String=GetNewsEventType; public function GetNewsEvent( type:String, data:Object = null, bubbles:Boolean=true, cancelable:Boolean=false ):void { _data = data; super(GET_NEWS_EVENT,true,false); } public function get data():Object { return _data; } } } dnk On 23-May-08, at 6:16 PM, Josh McDonald wrote: What's the event dispatch code look like? On Sat, May 24, 2008 at 11:01 AM, dnk [EMAIL PROTECTED] wrote: ok, well that explains that part, however either my event is not added, or my event handler is never called. My trace statements never show up So I guess I still am wondering if anyone has any ideas dnk On 23-May-08, at 4:56 AM, Paul Andrews wrote: addEventListener() does not return a value.. - Original Message - From: dnk [EMAIL PROTECTED] To: flexcoders@yahoogroups.com Sent: Friday, May 23, 2008 12:47 PM Subject: [flexcoders] custom event not added Hi there, I have a controller that is adding my custom event listeners, but for some reason my event handler was not being fired. My original code was (snippet): (in controler) //constructor public function FlexbController() { //turn the key, start it up addEventListener( FlexEvent.CREATION_COMPLETE, onInit ); } private function onInit( event:Event ):void { //setup event listeners /*systemManager is where event listener hangs out defines the relationship between event and handler*/ systemManager.addEventListener( GetNewsEvent.GET_NEWS_EVENT, handler_GetNewsEvent ); systemManager.addEventListener( AddNewsEvent.ADD_NEWS_EVENT, handler_AddNewsEvent ); systemManager .addEventListener( NewsDataLoadedEvent.NEWS_LOADED_EVENT, handler_NewsLoadedEvent ); getNewsData(); } And I had trace statements in all of my handlers... this is how i noticed things were not working as they should. SO I added a simple check like (in my FlexbController constructor): if (systemManager.addEventListener( GetNewsEvent.GET_NEWS_EVENT, handler_GetNewsEvent )) { trace(true); } else { trace(false); } And I obviously am getting false. Ideas? dnk -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo! Groups Links -- Therefore, send not to know For whom the bell tolls. It tolls for thee. :: Josh 'G-Funk' McDonald :: 0437 221 380 :: [EMAIL PROTECTED] -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/ flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo ! Groups Links -- Therefore, send not to know For whom the bell tolls. It tolls for thee. :: Josh 'G-Funk' McDonald :: 0437 221 380 :: [EMAIL PROTECTED] -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo ! Groups Links -- Therefore, send
Re: [flexcoders] custom event not added - almost solved.
Ok, I might be onto something here I added trace statements in all handlers and contructors, etc And the order my traces come back are: Controller getNewsData onInit The order my traces SHOULD come back are: Controller onInit getNewsData Since my event listeners are setup in my onInit, and if they are being added after my initial dispatchEvent is sent... well obviously they will not be called. So as a test I changed my onInt from: private function onInit( event:Event ):void { //setup event listeners /*systemManager is where event listener hangs out defines the relationship between event and handler*/ systemManager.addEventListener( GetNewsEvent.GET_NEWS_EVENT, handler_GetNewsEvent ); systemManager.addEventListener( AddNewsEvent.ADD_NEWS_EVENT, handler_AddNewsEvent ); systemManager.addEventListener( NewsDataLoadedEvent.NEWS_LOADED_EVENT, handler_NewsLoadedEvent ); getNewsData(); trace(onInit); } To: private function onInit( event:Event ):void { //setup event listeners /*systemManager is where event listener hangs out defines the relationship between event and handler*/ systemManager.addEventListener( GetNewsEvent.GET_NEWS_EVENT, handler_GetNewsEvent ); systemManager.addEventListener( AddNewsEvent.ADD_NEWS_EVENT, handler_AddNewsEvent ); systemManager.addEventListener( NewsDataLoadedEvent.NEWS_LOADED_EVENT, handler_NewsLoadedEvent ); //getNewsData(); //dispatchEvent(new GetNewsEvent(GetNewsEvent.GET_NEWS_EVENT)); // Set a timer since the below function does not seem to get fired. var myTimer:Timer = new Timer(1, 1); myTimer.addEventListener(timer, getNewsData); myTimer.start(); trace(onInit); } So I essentially setup a timer object to fire once like a second later, and it works. So now this does in fact work as expected, but the method does not seem proper to me. How would others get around this? Just do it the way I did? Or is there a more proper and elegant solution for this? DNK On 24-May-08, at 9:09 PM, Alex Harui wrote: Who’s dispatching and how? When does the control get instantiated? Could it be after creationComplete? If the controller is not a UIComponent, it will not get a creationComplete. From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of dnk Sent: Friday, May 23, 2008 4:48 AM To: flexcoders@yahoogroups.com Subject: [flexcoders] custom event not added Hi there, I have a controller that is adding my custom event listeners, but for some reason my event handler was not being fired. My original code was (snippet): (in controler) //constructor public function FlexbController() { //turn the key, start it up addEventListener( FlexEvent.CREATION_COMPLETE, onInit ); } private function onInit( event:Event ):void { //setup event listeners /*systemManager is where event listener hangs out defines the relationship between event and handler*/ systemManager.addEventListener( GetNewsEvent.GET_NEWS_EVENT, handler_GetNewsEvent ); systemManager.addEventListener( AddNewsEvent.ADD_NEWS_EVENT, handler_AddNewsEvent ); systemManager.addEventListener( NewsDataLoadedEvent.NEWS_LOADED_EVENT, handler_NewsLoadedEvent ); getNewsData(); } And I had trace statements in all of my handlers... this is how i noticed things were not working as they should. SO I added a simple check like (in my FlexbController constructor): if (systemManager.addEventListener( GetNewsEvent.GET_NEWS_EVENT, handler_GetNewsEvent )) { trace(true); } else { trace(false); } And I obviously am getting false. Ideas? dnk -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo! Groups Links * To visit your group on the web, go to: http://groups.yahoo.com/group/flexcoders/ * Your email settings: Individual Email | Traditional * To change settings online go to: http://groups.yahoo.com/group/flexcoders/join (Yahoo! ID required) * To change settings via email: mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] * To unsubscribe from this group, send an email to: [EMAIL PROTECTED] * Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/
RE: [flexcoders] custom event not added - almost solved.
Timers are normally not necessary. You need to have a clear understanding of the application lifecycle and its events. I don't know when your onInit is getting called, but if it is after a request for data has been sent, that's too late, you need to do it before the request. -Original Message- From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of dnk Sent: Sunday, May 25, 2008 11:40 AM To: flexcoders@yahoogroups.com Subject: Re: [flexcoders] custom event not added - almost solved. Ok, I might be onto something here I added trace statements in all handlers and contructors, etc And the order my traces come back are: Controller getNewsData onInit The order my traces SHOULD come back are: Controller onInit getNewsData Since my event listeners are setup in my onInit, and if they are being added after my initial dispatchEvent is sent... well obviously they will not be called. So as a test I changed my onInt from: private function onInit( event:Event ):void { //setup event listeners /*systemManager is where event listener hangs out defines the relationship between event and handler*/ systemManager.addEventListener( GetNewsEvent.GET_NEWS_EVENT, handler_GetNewsEvent ); systemManager.addEventListener( AddNewsEvent.ADD_NEWS_EVENT, handler_AddNewsEvent ); systemManager.addEventListener( NewsDataLoadedEvent.NEWS_LOADED_EVENT, handler_NewsLoadedEvent ); getNewsData(); trace(onInit); } To: private function onInit( event:Event ):void { //setup event listeners /*systemManager is where event listener hangs out defines the relationship between event and handler*/ systemManager.addEventListener( GetNewsEvent.GET_NEWS_EVENT, handler_GetNewsEvent ); systemManager.addEventListener( AddNewsEvent.ADD_NEWS_EVENT, handler_AddNewsEvent ); systemManager.addEventListener( NewsDataLoadedEvent.NEWS_LOADED_EVENT, handler_NewsLoadedEvent ); //getNewsData(); //dispatchEvent(new GetNewsEvent(GetNewsEvent.GET_NEWS_EVENT)); // Set a timer since the below function does not seem to get fired. var myTimer:Timer = new Timer(1, 1); myTimer.addEventListener(timer, getNewsData); myTimer.start(); trace(onInit); } So I essentially setup a timer object to fire once like a second later, and it works. So now this does in fact work as expected, but the method does not seem proper to me. How would others get around this? Just do it the way I did? Or is there a more proper and elegant solution for this? DNK On 24-May-08, at 9:09 PM, Alex Harui wrote: Who's dispatching and how? When does the control get instantiated? Could it be after creationComplete? If the controller is not a UIComponent, it will not get a creationComplete. From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of dnk Sent: Friday, May 23, 2008 4:48 AM To: flexcoders@yahoogroups.com Subject: [flexcoders] custom event not added Hi there, I have a controller that is adding my custom event listeners, but for some reason my event handler was not being fired. My original code was (snippet): (in controler) //constructor public function FlexbController() { //turn the key, start it up addEventListener( FlexEvent.CREATION_COMPLETE, onInit ); } private function onInit( event:Event ):void { //setup event listeners /*systemManager is where event listener hangs out defines the relationship between event and handler*/ systemManager.addEventListener( GetNewsEvent.GET_NEWS_EVENT, handler_GetNewsEvent ); systemManager.addEventListener( AddNewsEvent.ADD_NEWS_EVENT, handler_AddNewsEvent ); systemManager.addEventListener( NewsDataLoadedEvent.NEWS_LOADED_EVENT, handler_NewsLoadedEvent ); getNewsData(); } And I had trace statements in all of my handlers... this is how i noticed things were not working as they should. SO I added a simple check like (in my FlexbController constructor): if (systemManager.addEventListener( GetNewsEvent.GET_NEWS_EVENT, handler_GetNewsEvent )) { trace(true); } else { trace(false); } And I obviously am getting false. Ideas? dnk -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo! Groups
Re: [flexcoders] custom event not added - almost solved.
Yeah that is what I thought. my onInit is called in my constructor with: addEventListener( FlexEvent.CREATION_COMPLETE, onInit ); The requests for data are usually called after other adding of the events, but within the same function (onInit). I think I will just ad my addEventListener calls direct in my constructor and see what happens there. dnk On 25-May-08, at 2:08 PM, Alex Harui wrote: Timers are normally not necessary. You need to have a clear understanding of the application lifecycle and its events. I don't know when your onInit is getting called, but if it is after a request for data has been sent, that's too late, you need to do it before the request. -Original Message- From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of dnk Sent: Sunday, May 25, 2008 11:40 AM To: flexcoders@yahoogroups.com Subject: Re: [flexcoders] custom event not added - almost solved. Ok, I might be onto something here I added trace statements in all handlers and contructors, etc And the order my traces come back are: Controller getNewsData onInit The order my traces SHOULD come back are: Controller onInit getNewsData Since my event listeners are setup in my onInit, and if they are being added after my initial dispatchEvent is sent... well obviously they will not be called. So as a test I changed my onInt from: private function onInit( event:Event ):void { //setup event listeners /*systemManager is where event listener hangs out defines the relationship between event and handler*/ systemManager.addEventListener( GetNewsEvent.GET_NEWS_EVENT, handler_GetNewsEvent ); systemManager.addEventListener( AddNewsEvent.ADD_NEWS_EVENT, handler_AddNewsEvent ); systemManager.addEventListener( NewsDataLoadedEvent.NEWS_LOADED_EVENT, handler_NewsLoadedEvent ); getNewsData(); trace(onInit); } To: private function onInit( event:Event ):void { //setup event listeners /*systemManager is where event listener hangs out defines the relationship between event and handler*/ systemManager.addEventListener( GetNewsEvent.GET_NEWS_EVENT, handler_GetNewsEvent ); systemManager.addEventListener( AddNewsEvent.ADD_NEWS_EVENT, handler_AddNewsEvent ); systemManager.addEventListener( NewsDataLoadedEvent.NEWS_LOADED_EVENT, handler_NewsLoadedEvent ); //getNewsData(); //dispatchEvent(new GetNewsEvent(GetNewsEvent.GET_NEWS_EVENT)); // Set a timer since the below function does not seem to get fired. var myTimer:Timer = new Timer(1, 1); myTimer.addEventListener(timer, getNewsData); myTimer.start(); trace(onInit); } So I essentially setup a timer object to fire once like a second later, and it works. So now this does in fact work as expected, but the method does not seem proper to me. How would others get around this? Just do it the way I did? Or is there a more proper and elegant solution for this? DNK On 24-May-08, at 9:09 PM, Alex Harui wrote: Who's dispatching and how? When does the control get instantiated? Could it be after creationComplete? If the controller is not a UIComponent, it will not get a creationComplete. From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of dnk Sent: Friday, May 23, 2008 4:48 AM To: flexcoders@yahoogroups.com Subject: [flexcoders] custom event not added Hi there, I have a controller that is adding my custom event listeners, but for some reason my event handler was not being fired. My original code was (snippet): (in controler) //constructor public function FlexbController() { //turn the key, start it up addEventListener( FlexEvent.CREATION_COMPLETE, onInit ); } private function onInit( event:Event ):void { //setup event listeners /*systemManager is where event listener hangs out defines the relationship between event and handler*/ systemManager.addEventListener( GetNewsEvent.GET_NEWS_EVENT, handler_GetNewsEvent ); systemManager.addEventListener( AddNewsEvent.ADD_NEWS_EVENT, handler_AddNewsEvent ); systemManager.addEventListener( NewsDataLoadedEvent.NEWS_LOADED_EVENT, handler_NewsLoadedEvent ); getNewsData(); } And I had trace statements in all of my handlers... this is how i noticed things were not working as they should. SO I added a simple check like (in my FlexbController constructor): if (systemManager.addEventListener( GetNewsEvent.GET_NEWS_EVENT, handler_GetNewsEvent )) { trace(true); } else { trace(false); } And I obviously am getting false. Ideas? dnk -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo! Groups Links -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group
Re: [flexcoders] custom event not added - almost solved.
In this code: private function onInit( event:Event ):void { systemManager.addEventListener( GetNewsEvent.GET_NEWS_EVENT, handler_GetNewsEvent ); systemManager.addEventListener( AddNewsEvent.ADD_NEWS_EVENT, handler_AddNewsEvent ); systemManager.addEventListener( NewsDataLoadedEvent.NEWS_LOADED_EVENT, handler_NewsLoadedEvent ); getNewsData(); trace(onInit); } You're calling getNewsData before you do the trace from your init() method, so you're getting the order you want but it looks otherwise. Whenever I've using this sort of trace statement to debug a process execution, I make it the first line of the method, and I suggest it's a good habit to have :) When you call addEventListener, it has an immediate effect. But when you call dispatchEvent, it sits in a queue until all other processing for this frame is completed. Alex can tell you whether it's run in the last part of this frame, or the first part of the next, but it's neither here nor there. If you're adding a handler, and then calling the code that dispatches that event, you should still be receiving the event in your handler, leaving me to believe that something else is the cause of your woes. How big is your project? If it's a reasonable size (and doesn't contain any business secrets or anything), zip it up and upload it somewhere, and I'll download the whole thing and have a look- I'm sure I'll be able to figure out what you're doing wrong. -J On Mon, May 26, 2008 at 1:35 PM, dnk [EMAIL PROTECTED] wrote: Yeah that is what I thought. my onInit is called in my constructor with: addEventListener( FlexEvent.CREATION_COMPLETE, onInit ); The requests for data are usually called after other adding of the events, but within the same function (onInit). I think I will just ad my addEventListener calls direct in my constructor and see what happens there. dnk On 25-May-08, at 2:08 PM, Alex Harui wrote: Timers are normally not necessary. You need to have a clear understanding of the application lifecycle and its events. I don't know when your onInit is getting called, but if it is after a request for data has been sent, that's too late, you need to do it before the request. -Original Message- From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of dnk Sent: Sunday, May 25, 2008 11:40 AM To: flexcoders@yahoogroups.com Subject: Re: [flexcoders] custom event not added - almost solved. Ok, I might be onto something here I added trace statements in all handlers and contructors, etc And the order my traces come back are: Controller getNewsData onInit The order my traces SHOULD come back are: Controller onInit getNewsData Since my event listeners are setup in my onInit, and if they are being added after my initial dispatchEvent is sent... well obviously they will not be called. So as a test I changed my onInt from: private function onInit( event:Event ):void { //setup event listeners /*systemManager is where event listener hangs out defines the relationship between event and handler*/ systemManager.addEventListener( GetNewsEvent.GET_NEWS_EVENT, handler_GetNewsEvent ); systemManager.addEventListener( AddNewsEvent.ADD_NEWS_EVENT, handler_AddNewsEvent ); systemManager.addEventListener( NewsDataLoadedEvent.NEWS_LOADED_EVENT, handler_NewsLoadedEvent ); getNewsData(); trace(onInit); } To: private function onInit( event:Event ):void { //setup event listeners /*systemManager is where event listener hangs out defines the relationship between event and handler*/ systemManager.addEventListener( GetNewsEvent.GET_NEWS_EVENT, handler_GetNewsEvent ); systemManager.addEventListener( AddNewsEvent.ADD_NEWS_EVENT, handler_AddNewsEvent ); systemManager.addEventListener( NewsDataLoadedEvent.NEWS_LOADED_EVENT, handler_NewsLoadedEvent ); //getNewsData(); //dispatchEvent(new GetNewsEvent(GetNewsEvent.GET_NEWS_EVENT)); // Set a timer since the below function does not seem to get fired. var myTimer:Timer = new Timer(1, 1); myTimer.addEventListener(timer, getNewsData); myTimer.start(); trace(onInit); } So I essentially setup a timer object to fire once like a second later, and it works. So now this does in fact work as expected, but the method does not seem proper to me. How would others get around this? Just do it the way I did? Or is there a more proper and elegant solution for this? DNK On 24-May-08, at 9:09 PM, Alex Harui wrote: Who's dispatching and how? When does the control get instantiated? Could it be after creationComplete? If the controller is not a UIComponent, it will not get a creationComplete. From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of dnk Sent
Re: [flexcoders] custom event not added - almost solved.
Ok mate, here's the problem: public function FlexbController() { //turn the key, start it up addEventListener( FlexEvent.CREATION_COMPLETE, onInit ); trace(Controller); } What you need, is this: public function FlexbController() { //turn the key, start it up Application.application.addEventListener( FlexEvent.CREATION_COMPLETE, onInit ); trace(Controller); } The reason for this, is the way CREATION_COMPLETE is dispatched - which is from the bottom of your display tree upward. It has to be this way, because it's dispatched only after all the children of a component have already had CREATION_COMPLETE dispatched. So first it is dispatched on all instantiated UIComponents that don't have any children. Then (probably on the next frame, but ask Alex) it's dispatched on their container components, and so on and so forth until finally (as far as we care) it's dispatched on your root Application. It might be then dispatched on a few containers up to the systemManager, but again Alex would know better than me. Now what happens in your case, CREATION_COMPLETE is dispatched on your FlexbController, and then you're dispatching the GET_NEWS_EVENT immediately. But, the current instance of FlexbController is not yet part of the displayTree, because it hasn't been completely added to the Application's children yet. So the event has nowhere to bubble to - and never reaches the Application, or the SystemManager. But, if you defer onInit() until CREATION_COMPLETE is dispatched on the Application itself, you know that the display tree is complete (in its initial layout at least), and you can safely dispatch the event and have it bubble all the way to the top of the tree at SystemManager. -J On Mon, May 26, 2008 at 1:35 PM, dnk [EMAIL PROTECTED] wrote: Yeah that is what I thought. my onInit is called in my constructor with: addEventListener( FlexEvent.CREATION_COMPLETE, onInit ); The requests for data are usually called after other adding of the events, but within the same function (onInit). I think I will just ad my addEventListener calls direct in my constructor and see what happens there. dnk On 25-May-08, at 2:08 PM, Alex Harui wrote: Timers are normally not necessary. You need to have a clear understanding of the application lifecycle and its events. I don't know when your onInit is getting called, but if it is after a request for data has been sent, that's too late, you need to do it before the request. -Original Message- From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of dnk Sent: Sunday, May 25, 2008 11:40 AM To: flexcoders@yahoogroups.com Subject: Re: [flexcoders] custom event not added - almost solved. Ok, I might be onto something here I added trace statements in all handlers and contructors, etc And the order my traces come back are: Controller getNewsData onInit The order my traces SHOULD come back are: Controller onInit getNewsData Since my event listeners are setup in my onInit, and if they are being added after my initial dispatchEvent is sent... well obviously they will not be called. So as a test I changed my onInt from: private function onInit( event:Event ):void { //setup event listeners /*systemManager is where event listener hangs out defines the relationship between event and handler*/ systemManager.addEventListener( GetNewsEvent.GET_NEWS_EVENT, handler_GetNewsEvent ); systemManager.addEventListener( AddNewsEvent.ADD_NEWS_EVENT, handler_AddNewsEvent ); systemManager.addEventListener( NewsDataLoadedEvent.NEWS_LOADED_EVENT, handler_NewsLoadedEvent ); getNewsData(); trace(onInit); } To: private function onInit( event:Event ):void { //setup event listeners /*systemManager is where event listener hangs out defines the relationship between event and handler*/ systemManager.addEventListener( GetNewsEvent.GET_NEWS_EVENT, handler_GetNewsEvent ); systemManager.addEventListener( AddNewsEvent.ADD_NEWS_EVENT, handler_AddNewsEvent ); systemManager.addEventListener( NewsDataLoadedEvent.NEWS_LOADED_EVENT, handler_NewsLoadedEvent ); //getNewsData(); //dispatchEvent(new GetNewsEvent(GetNewsEvent.GET_NEWS_EVENT)); // Set a timer since the below function does not seem to get fired. var myTimer:Timer = new Timer(1, 1); myTimer.addEventListener(timer, getNewsData); myTimer.start(); trace(onInit); } So I essentially setup a timer object to fire once like a second later, and it works. So now this does in fact work as expected, but the method does not seem proper to me. How would others get around this? Just do it the way I did? Or is there a more proper and elegant solution for this? DNK On 24-May-08, at 9:09 PM, Alex Harui wrote: Who's
Re: [flexcoders] custom event not added - almost solved.
And don't forget to add: import mx.core.Application; Up the top :) On Mon, May 26, 2008 at 2:11 PM, Josh McDonald [EMAIL PROTECTED] wrote: Ok mate, here's the problem: public function FlexbController() { //turn the key, start it up addEventListener( FlexEvent.CREATION_COMPLETE, onInit ); trace(Controller); } What you need, is this: public function FlexbController() { //turn the key, start it up Application.application.addEventListener( FlexEvent.CREATION_COMPLETE, onInit ); trace(Controller); } The reason for this, is the way CREATION_COMPLETE is dispatched - which is from the bottom of your display tree upward. It has to be this way, because it's dispatched only after all the children of a component have already had CREATION_COMPLETE dispatched. So first it is dispatched on all instantiated UIComponents that don't have any children. Then (probably on the next frame, but ask Alex) it's dispatched on their container components, and so on and so forth until finally (as far as we care) it's dispatched on your root Application. It might be then dispatched on a few containers up to the systemManager, but again Alex would know better than me. Now what happens in your case, CREATION_COMPLETE is dispatched on your FlexbController, and then you're dispatching the GET_NEWS_EVENT immediately. But, the current instance of FlexbController is not yet part of the displayTree, because it hasn't been completely added to the Application's children yet. So the event has nowhere to bubble to - and never reaches the Application, or the SystemManager. But, if you defer onInit() until CREATION_COMPLETE is dispatched on the Application itself, you know that the display tree is complete (in its initial layout at least), and you can safely dispatch the event and have it bubble all the way to the top of the tree at SystemManager. -J On Mon, May 26, 2008 at 1:35 PM, dnk [EMAIL PROTECTED] wrote: Yeah that is what I thought. my onInit is called in my constructor with: addEventListener( FlexEvent.CREATION_COMPLETE, onInit ); The requests for data are usually called after other adding of the events, but within the same function (onInit). I think I will just ad my addEventListener calls direct in my constructor and see what happens there. dnk On 25-May-08, at 2:08 PM, Alex Harui wrote: Timers are normally not necessary. You need to have a clear understanding of the application lifecycle and its events. I don't know when your onInit is getting called, but if it is after a request for data has been sent, that's too late, you need to do it before the request. -Original Message- From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of dnk Sent: Sunday, May 25, 2008 11:40 AM To: flexcoders@yahoogroups.com Subject: Re: [flexcoders] custom event not added - almost solved. Ok, I might be onto something here I added trace statements in all handlers and contructors, etc And the order my traces come back are: Controller getNewsData onInit The order my traces SHOULD come back are: Controller onInit getNewsData Since my event listeners are setup in my onInit, and if they are being added after my initial dispatchEvent is sent... well obviously they will not be called. So as a test I changed my onInt from: private function onInit( event:Event ):void { //setup event listeners /*systemManager is where event listener hangs out defines the relationship between event and handler*/ systemManager.addEventListener( GetNewsEvent.GET_NEWS_EVENT, handler_GetNewsEvent ); systemManager.addEventListener( AddNewsEvent.ADD_NEWS_EVENT, handler_AddNewsEvent ); systemManager.addEventListener( NewsDataLoadedEvent.NEWS_LOADED_EVENT, handler_NewsLoadedEvent ); getNewsData(); trace(onInit); } To: private function onInit( event:Event ):void { //setup event listeners /*systemManager is where event listener hangs out defines the relationship between event and handler*/ systemManager.addEventListener( GetNewsEvent.GET_NEWS_EVENT, handler_GetNewsEvent ); systemManager.addEventListener( AddNewsEvent.ADD_NEWS_EVENT, handler_AddNewsEvent ); systemManager.addEventListener( NewsDataLoadedEvent.NEWS_LOADED_EVENT, handler_NewsLoadedEvent ); //getNewsData(); //dispatchEvent(new GetNewsEvent(GetNewsEvent.GET_NEWS_EVENT)); // Set a timer since the below function does not seem to get fired. var myTimer:Timer = new Timer(1, 1); myTimer.addEventListener(timer, getNewsData); myTimer.start(); trace(onInit); } So I essentially setup a timer object to fire once like a second later, and it works. So now this does in fact work as expected, but the method does not seem proper to me. How would
Re: [flexcoders] custom event not added - almost solved.
Dude, you rule! Thanks s much! Dnk On 25-May-08, at 9:12 PM, Josh McDonald wrote: And don't forget to add: import mx.core.Application; Up the top :) On Mon, May 26, 2008 at 2:11 PM, Josh McDonald [EMAIL PROTECTED] wrote: Ok mate, here's the problem: public function FlexbController() { //turn the key, start it up addEventListener( FlexEvent.CREATION_COMPLETE, onInit ); trace(Controller); } What you need, is this: public function FlexbController() { //turn the key, start it up Application .application.addEventListener( FlexEvent.CREATION_COMPLETE, onInit ); trace(Controller); } The reason for this, is the way CREATION_COMPLETE is dispatched - which is from the bottom of your display tree upward. It has to be this way, because it's dispatched only after all the children of a component have already had CREATION_COMPLETE dispatched. So first it is dispatched on all instantiated UIComponents that don't have any children. Then (probably on the next frame, but ask Alex) it's dispatched on their container components, and so on and so forth until finally (as far as we care) it's dispatched on your root Application. It might be then dispatched on a few containers up to the systemManager, but again Alex would know better than me. Now what happens in your case, CREATION_COMPLETE is dispatched on your FlexbController, and then you're dispatching the GET_NEWS_EVENT immediately. But, the current instance of FlexbController is not yet part of the displayTree, because it hasn't been completely added to the Application's children yet. So the event has nowhere to bubble to - and never reaches the Application, or the SystemManager. But, if you defer onInit() until CREATION_COMPLETE is dispatched on the Application itself, you know that the display tree is complete (in its initial layout at least), and you can safely dispatch the event and have it bubble all the way to the top of the tree at SystemManager. -J On Mon, May 26, 2008 at 1:35 PM, dnk [EMAIL PROTECTED] wrote: Yeah that is what I thought. my onInit is called in my constructor with: addEventListener( FlexEvent.CREATION_COMPLETE, onInit ); The requests for data are usually called after other adding of the events, but within the same function (onInit). I think I will just ad my addEventListener calls direct in my constructor and see what happens there. dnk On 25-May-08, at 2:08 PM, Alex Harui wrote: Timers are normally not necessary. You need to have a clear understanding of the application lifecycle and its events. I don't know when your onInit is getting called, but if it is after a request for data has been sent, that's too late, you need to do it before the request. -Original Message- From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of dnk Sent: Sunday, May 25, 2008 11:40 AM To: flexcoders@yahoogroups.com Subject: Re: [flexcoders] custom event not added - almost solved. Ok, I might be onto something here I added trace statements in all handlers and contructors, etc And the order my traces come back are: Controller getNewsData onInit The order my traces SHOULD come back are: Controller onInit getNewsData Since my event listeners are setup in my onInit, and if they are being added after my initial dispatchEvent is sent... well obviously they will not be called. So as a test I changed my onInt from: private function onInit( event:Event ):void { //setup event listeners /*systemManager is where event listener hangs out defines the relationship between event and handler*/ systemManager.addEventListener( GetNewsEvent.GET_NEWS_EVENT, handler_GetNewsEvent ); systemManager.addEventListener( AddNewsEvent.ADD_NEWS_EVENT, handler_AddNewsEvent ); systemManager.addEventListener( NewsDataLoadedEvent.NEWS_LOADED_EVENT, handler_NewsLoadedEvent ); getNewsData(); trace(onInit); } To: private function onInit( event:Event ):void { //setup event listeners /*systemManager is where event listener hangs out defines the relationship between event and handler*/ systemManager.addEventListener( GetNewsEvent.GET_NEWS_EVENT, handler_GetNewsEvent ); systemManager.addEventListener( AddNewsEvent.ADD_NEWS_EVENT, handler_AddNewsEvent ); systemManager.addEventListener( NewsDataLoadedEvent.NEWS_LOADED_EVENT, handler_NewsLoadedEvent ); //getNewsData(); //dispatchEvent(new GetNewsEvent(GetNewsEvent.GET_NEWS_EVENT)); // Set a timer since the below function does not seem to get fired. var myTimer:Timer = new Timer(1, 1); myTimer.addEventListener(timer, getNewsData); myTimer.start(); trace(onInit); } So I essentially setup a timer object to fire once like a second later, and it works. So now this does in fact work as expected, but the method does not seem proper to me
Re: [flexcoders] custom event not added - almost solved.
No probs mate, it was pissing me off not know what the problem was, too :) -J On Mon, May 26, 2008 at 2:22 PM, dnk [EMAIL PROTECTED] wrote: Dude, you rule! Thanks s much! Dnk On 25-May-08, at 9:12 PM, Josh McDonald wrote: And don't forget to add: import mx.core.Application; Up the top :) On Mon, May 26, 2008 at 2:11 PM, Josh McDonald [EMAIL PROTECTED] wrote: Ok mate, here's the problem: public function FlexbController() { //turn the key, start it up addEventListener( FlexEvent.CREATION_COMPLETE, onInit ); trace(Controller); } What you need, is this: public function FlexbController() { //turn the key, start it up Application.application.addEventListener( FlexEvent.CREATION_COMPLETE, onInit ); trace(Controller); } The reason for this, is the way CREATION_COMPLETE is dispatched - which is from the bottom of your display tree upward. It has to be this way, because it's dispatched only after all the children of a component have already had CREATION_COMPLETE dispatched. So first it is dispatched on all instantiated UIComponents that don't have any children. Then (probably on the next frame, but ask Alex) it's dispatched on their container components, and so on and so forth until finally (as far as we care) it's dispatched on your root Application. It might be then dispatched on a few containers up to the systemManager, but again Alex would know better than me. Now what happens in your case, CREATION_COMPLETE is dispatched on your FlexbController, and then you're dispatching the GET_NEWS_EVENT immediately. But, the current instance of FlexbController is not yet part of the displayTree, because it hasn't been completely added to the Application's children yet. So the event has nowhere to bubble to - and never reaches the Application, or the SystemManager. But, if you defer onInit() until CREATION_COMPLETE is dispatched on the Application itself, you know that the display tree is complete (in its initial layout at least), and you can safely dispatch the event and have it bubble all the way to the top of the tree at SystemManager. -J On Mon, May 26, 2008 at 1:35 PM, dnk [EMAIL PROTECTED] wrote: Yeah that is what I thought. my onInit is called in my constructor with: addEventListener( FlexEvent.CREATION_COMPLETE, onInit ); The requests for data are usually called after other adding of the events, but within the same function (onInit). I think I will just ad my addEventListener calls direct in my constructor and see what happens there. dnk On 25-May-08, at 2:08 PM, Alex Harui wrote: Timers are normally not necessary. You need to have a clear understanding of the application lifecycle and its events. I don't know when your onInit is getting called, but if it is after a request for data has been sent, that's too late, you need to do it before the request. -Original Message- From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of dnk Sent: Sunday, May 25, 2008 11:40 AM To: flexcoders@yahoogroups.com Subject: Re: [flexcoders] custom event not added - almost solved. Ok, I might be onto something here I added trace statements in all handlers and contructors, etc And the order my traces come back are: Controller getNewsData onInit The order my traces SHOULD come back are: Controller onInit getNewsData Since my event listeners are setup in my onInit, and if they are being added after my initial dispatchEvent is sent... well obviously they will not be called. So as a test I changed my onInt from: private function onInit( event:Event ):void { //setup event listeners /*systemManager is where event listener hangs out defines the relationship between event and handler*/ systemManager.addEventListener( GetNewsEvent.GET_NEWS_EVENT, handler_GetNewsEvent ); systemManager.addEventListener( AddNewsEvent.ADD_NEWS_EVENT, handler_AddNewsEvent ); systemManager.addEventListener( NewsDataLoadedEvent.NEWS_LOADED_EVENT, handler_NewsLoadedEvent ); getNewsData(); trace(onInit); } To: private function onInit( event:Event ):void { //setup event listeners /*systemManager is where event listener hangs out defines the relationship between event and handler*/ systemManager.addEventListener( GetNewsEvent.GET_NEWS_EVENT, handler_GetNewsEvent ); systemManager.addEventListener( AddNewsEvent.ADD_NEWS_EVENT, handler_AddNewsEvent ); systemManager.addEventListener( NewsDataLoadedEvent.NEWS_LOADED_EVENT, handler_NewsLoadedEvent ); //getNewsData(); //dispatchEvent(new GetNewsEvent(GetNewsEvent.GET_NEWS_EVENT)); // Set a timer since the below function does not seem to get fired. var myTimer:Timer = new Timer(1, 1); myTimer.addEventListener(timer, getNewsData
Re: [flexcoders] custom event not added - almost solved.
Yeah this one was a bit of a mind [EMAIL PROTECTED]@!#. Much appreciated. DNK On 25-May-08, at 9:26 PM, Josh McDonald wrote: No probs mate, it was pissing me off not know what the problem was, too :) -J On Mon, May 26, 2008 at 2:22 PM, dnk [EMAIL PROTECTED] wrote: Dude, you rule! Thanks s much! Dnk On 25-May-08, at 9:12 PM, Josh McDonald wrote: And don't forget to add: import mx.core.Application; Up the top :) On Mon, May 26, 2008 at 2:11 PM, Josh McDonald [EMAIL PROTECTED] wrote: Ok mate, here's the problem: public function FlexbController() { //turn the key, start it up addEventListener( FlexEvent.CREATION_COMPLETE, onInit ); trace(Controller); } What you need, is this: public function FlexbController() { //turn the key, start it up Application .application.addEventListener( FlexEvent.CREATION_COMPLETE, onInit ); trace(Controller); } The reason for this, is the way CREATION_COMPLETE is dispatched - which is from the bottom of your display tree upward. It has to be this way, because it's dispatched only after all the children of a component have already had CREATION_COMPLETE dispatched. So first it is dispatched on all instantiated UIComponents that don't have any children. Then (probably on the next frame, but ask Alex) it's dispatched on their container components, and so on and so forth until finally (as far as we care) it's dispatched on your root Application. It might be then dispatched on a few containers up to the systemManager, but again Alex would know better than me. Now what happens in your case, CREATION_COMPLETE is dispatched on your FlexbController, and then you're dispatching the GET_NEWS_EVENT immediately. But, the current instance of FlexbController is not yet part of the displayTree, because it hasn't been completely added to the Application's children yet. So the event has nowhere to bubble to - and never reaches the Application, or the SystemManager. But, if you defer onInit() until CREATION_COMPLETE is dispatched on the Application itself, you know that the display tree is complete (in its initial layout at least), and you can safely dispatch the event and have it bubble all the way to the top of the tree at SystemManager. -J On Mon, May 26, 2008 at 1:35 PM, dnk [EMAIL PROTECTED] wrote: Yeah that is what I thought. my onInit is called in my constructor with: addEventListener( FlexEvent.CREATION_COMPLETE, onInit ); The requests for data are usually called after other adding of the events, but within the same function (onInit). I think I will just ad my addEventListener calls direct in my constructor and see what happens there. dnk On 25-May-08, at 2:08 PM, Alex Harui wrote: Timers are normally not necessary. You need to have a clear understanding of the application lifecycle and its events. I don't know when your onInit is getting called, but if it is after a request for data has been sent, that's too late, you need to do it before the request. -Original Message- From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of dnk Sent: Sunday, May 25, 2008 11:40 AM To: flexcoders@yahoogroups.com Subject: Re: [flexcoders] custom event not added - almost solved. Ok, I might be onto something here I added trace statements in all handlers and contructors, etc And the order my traces come back are: Controller getNewsData onInit The order my traces SHOULD come back are: Controller onInit getNewsData Since my event listeners are setup in my onInit, and if they are being added after my initial dispatchEvent is sent... well obviously they will not be called. So as a test I changed my onInt from: private function onInit( event:Event ):void { //setup event listeners /*systemManager is where event listener hangs out defines the relationship between event and handler*/ systemManager.addEventListener( GetNewsEvent.GET_NEWS_EVENT, handler_GetNewsEvent ); systemManager.addEventListener( AddNewsEvent.ADD_NEWS_EVENT, handler_AddNewsEvent ); systemManager .addEventListener( NewsDataLoadedEvent.NEWS_LOADED_EVENT, handler_NewsLoadedEvent ); getNewsData(); trace(onInit); } To: private function onInit( event:Event ):void { //setup event listeners /*systemManager is where event listener hangs out defines the relationship between event and handler*/ systemManager.addEventListener( GetNewsEvent.GET_NEWS_EVENT, handler_GetNewsEvent ); systemManager.addEventListener( AddNewsEvent.ADD_NEWS_EVENT, handler_AddNewsEvent ); systemManager .addEventListener( NewsDataLoadedEvent.NEWS_LOADED_EVENT, handler_NewsLoadedEvent ); //getNewsData(); //dispatchEvent(new GetNewsEvent(GetNewsEvent.GET_NEWS_EVENT)); // Set a timer since the below function does not seem to get fired. var
Re: [flexcoders] custom event not added
fire? As in scrap and rewrite? dnk On 23-May-08, at 10:25 PM, Josh McDonald wrote: If you're getting a runtime error accessing Application.application you'll need fire to clean this up, methinks. -J On Sat, May 24, 2008 at 3:02 PM, dnk [EMAIL PROTECTED] wrote: That added an error: Access of undefined property Application researching that now... d On 23-May-08, at 9:35 PM, Josh McDonald wrote: The only thing i can think of after looking at that is that your controller (whatever that is) is not part of the display tree? Try replacing dispatchEvent() with Application.application.dispatchEvent() and see if it works then. -J On Sat, May 24, 2008 at 2:28 PM, dnk [EMAIL PROTECTED] wrote: It is dispatched like this (in function in my controller): dispatchEvent(new GetNewsEvent(GetNewsEvent.GET_NEWS_EVENT, null, false, false)); the null is used for an object (if I need to pass data with my event). In this particular case I did not. My actual event class looks like: package Flexb.events { import flash.events.Event; public class GetNewsEvent extends Event { protected var _data:Object; public static const GET_NEWS_EVENT:String=GetNewsEventType; public function GetNewsEvent( type:String, data:Object = null, bubbles:Boolean=true, cancelable:Boolean=false ):void { _data = data; super(GET_NEWS_EVENT,true,false); } public function get data():Object { return _data; } } } dnk On 23-May-08, at 6:16 PM, Josh McDonald wrote: What's the event dispatch code look like? On Sat, May 24, 2008 at 11:01 AM, dnk [EMAIL PROTECTED] wrote: ok, well that explains that part, however either my event is not added, or my event handler is never called. My trace statements never show up So I guess I still am wondering if anyone has any ideas dnk On 23-May-08, at 4:56 AM, Paul Andrews wrote: addEventListener() does not return a value.. - Original Message - From: dnk [EMAIL PROTECTED] To: flexcoders@yahoogroups.com Sent: Friday, May 23, 2008 12:47 PM Subject: [flexcoders] custom event not added Hi there, I have a controller that is adding my custom event listeners, but for some reason my event handler was not being fired. My original code was (snippet): (in controler) //constructor public function FlexbController() { //turn the key, start it up addEventListener( FlexEvent.CREATION_COMPLETE, onInit ); } private function onInit( event:Event ):void { //setup event listeners /*systemManager is where event listener hangs out defines the relationship between event and handler*/ systemManager.addEventListener( GetNewsEvent.GET_NEWS_EVENT, handler_GetNewsEvent ); systemManager.addEventListener( AddNewsEvent.ADD_NEWS_EVENT, handler_AddNewsEvent ); systemManager .addEventListener( NewsDataLoadedEvent.NEWS_LOADED_EVENT, handler_NewsLoadedEvent ); getNewsData(); } And I had trace statements in all of my handlers... this is how i noticed things were not working as they should. SO I added a simple check like (in my FlexbController constructor): if (systemManager.addEventListener( GetNewsEvent.GET_NEWS_EVENT, handler_GetNewsEvent )) { trace(true); } else { trace(false); } And I obviously am getting false. Ideas? dnk -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo! Groups Links -- Therefore, send not to know For whom the bell tolls. It tolls for thee. :: Josh 'G-Funk' McDonald :: 0437 221 380 :: [EMAIL PROTECTED] -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/ flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo ! Groups Links -- Therefore, send not to know For whom the bell tolls. It tolls for thee. :: Josh 'G-Funk' McDonald :: 0437 221 380 :: [EMAIL PROTECTED] -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo ! Groups Links -- Therefore, send not to know For whom the bell tolls. It tolls for thee. :: Josh 'G-Funk' McDonald :: 0437 221 380 :: [EMAIL PROTECTED]
Re: [flexcoders] custom event not added
As in, I've got no idea what's going on :) Application.application should always point to the running instance of your mx:Application On Sun, May 25, 2008 at 2:19 AM, dnk [EMAIL PROTECTED] wrote: fire? As in scrap and rewrite? dnk On 23-May-08, at 10:25 PM, Josh McDonald wrote: If you're getting a runtime error accessing Application.application you'll need fire to clean this up, methinks. -J On Sat, May 24, 2008 at 3:02 PM, dnk [EMAIL PROTECTED] wrote: That added an error: Access of undefined property Application researching that now... d On 23-May-08, at 9:35 PM, Josh McDonald wrote: The only thing i can think of after looking at that is that your controller (whatever that is) is not part of the display tree? Try replacing dispatchEvent() with Application.application.dispatchEvent() and see if it works then. -J On Sat, May 24, 2008 at 2:28 PM, dnk [EMAIL PROTECTED] wrote: It is dispatched like this (in function in my controller): dispatchEvent(new GetNewsEvent(GetNewsEvent.GET_NEWS_EVENT, null, false, false)); the null is used for an object (if I need to pass data with my event). In this particular case I did not. My actual event class looks like: package Flexb.events { import flash.events.Event; public class GetNewsEvent extends Event { protected var _data:Object; public static const GET_NEWS_EVENT:String=GetNewsEventType; public function GetNewsEvent( type:String, data:Object = null, bubbles:Boolean=true, cancelable:Boolean=false ):void { _data = data; super(GET_NEWS_EVENT,true,false); } public function get data():Object { return _data; } } } dnk On 23-May-08, at 6:16 PM, Josh McDonald wrote: What's the event dispatch code look like? On Sat, May 24, 2008 at 11:01 AM, dnk [EMAIL PROTECTED] wrote: ok, well that explains that part, however either my event is not added, or my event handler is never called. My trace statements never show up So I guess I still am wondering if anyone has any ideas dnk On 23-May-08, at 4:56 AM, Paul Andrews wrote: addEventListener() does not return a value.. - Original Message - From: dnk [EMAIL PROTECTED] To: flexcoders@yahoogroups.com Sent: Friday, May 23, 2008 12:47 PM Subject: [flexcoders] custom event not added Hi there, I have a controller that is adding my custom event listeners, but for some reason my event handler was not being fired. My original code was (snippet): (in controler) //constructor public function FlexbController() { //turn the key, start it up addEventListener( FlexEvent.CREATION_COMPLETE, onInit ); } private function onInit( event:Event ):void { //setup event listeners /*systemManager is where event listener hangs out defines the relationship between event and handler*/ systemManager.addEventListener( GetNewsEvent.GET_NEWS_EVENT, handler_GetNewsEvent ); systemManager.addEventListener( AddNewsEvent.ADD_NEWS_EVENT, handler_AddNewsEvent ); systemManager .addEventListener( NewsDataLoadedEvent.NEWS_LOADED_EVENT, handler_NewsLoadedEvent ); getNewsData(); } And I had trace statements in all of my handlers... this is how i noticed things were not working as they should. SO I added a simple check like (in my FlexbController constructor): if (systemManager.addEventListener( GetNewsEvent.GET_NEWS_EVENT, handler_GetNewsEvent )) { trace(true); } else { trace(false); } And I obviously am getting false. Ideas? dnk -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo! Groups Links -- Therefore, send not to know For whom the bell tolls. It tolls for thee. :: Josh 'G-Funk' McDonald :: 0437 221 380 :: [EMAIL PROTECTED] -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo ! Groups Links -- Therefore, send not to know For whom the bell tolls. It tolls for thee. :: Josh 'G-Funk' McDonald :: 0437 221 380 :: [EMAIL PROTECTED] -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders
RE: [flexcoders] custom event not added
Who's dispatching and how? When does the control get instantiated? Could it be after creationComplete? If the controller is not a UIComponent, it will not get a creationComplete. From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of dnk Sent: Friday, May 23, 2008 4:48 AM To: flexcoders@yahoogroups.com Subject: [flexcoders] custom event not added Hi there, I have a controller that is adding my custom event listeners, but for some reason my event handler was not being fired. My original code was (snippet): (in controler) //constructor public function FlexbController() { //turn the key, start it up addEventListener( FlexEvent.CREATION_COMPLETE, onInit ); } private function onInit( event:Event ):void { //setup event listeners /*systemManager is where event listener hangs out defines the relationship between event and handler*/ systemManager.addEventListener( GetNewsEvent.GET_NEWS_EVENT, handler_GetNewsEvent ); systemManager.addEventListener( AddNewsEvent.ADD_NEWS_EVENT, handler_AddNewsEvent ); systemManager.addEventListener( NewsDataLoadedEvent.NEWS_LOADED_EVENT, handler_NewsLoadedEvent ); getNewsData(); } And I had trace statements in all of my handlers... this is how i noticed things were not working as they should. SO I added a simple check like (in my FlexbController constructor): if (systemManager.addEventListener( GetNewsEvent.GET_NEWS_EVENT, handler_GetNewsEvent )) { trace(true); } else { trace(false); } And I obviously am getting false. Ideas? dnk
[flexcoders] custom event not added
Hi there, I have a controller that is adding my custom event listeners, but for some reason my event handler was not being fired. My original code was (snippet): (in controler) //constructor public function FlexbController() { //turn the key, start it up addEventListener( FlexEvent.CREATION_COMPLETE, onInit ); } private function onInit( event:Event ):void { //setup event listeners /*systemManager is where event listener hangs out defines the relationship between event and handler*/ systemManager.addEventListener( GetNewsEvent.GET_NEWS_EVENT, handler_GetNewsEvent ); systemManager.addEventListener( AddNewsEvent.ADD_NEWS_EVENT, handler_AddNewsEvent ); systemManager.addEventListener( NewsDataLoadedEvent.NEWS_LOADED_EVENT, handler_NewsLoadedEvent ); getNewsData(); } And I had trace statements in all of my handlers... this is how i noticed things were not working as they should. SO I added a simple check like (in my FlexbController constructor): if (systemManager.addEventListener( GetNewsEvent.GET_NEWS_EVENT, handler_GetNewsEvent )) { trace(true); } else { trace(false); } And I obviously am getting false. Ideas? dnk
Re: [flexcoders] custom event not added
addEventListener() does not return a value.. - Original Message - From: dnk [EMAIL PROTECTED] To: flexcoders@yahoogroups.com Sent: Friday, May 23, 2008 12:47 PM Subject: [flexcoders] custom event not added Hi there, I have a controller that is adding my custom event listeners, but for some reason my event handler was not being fired. My original code was (snippet): (in controler) //constructor public function FlexbController() { //turn the key, start it up addEventListener( FlexEvent.CREATION_COMPLETE, onInit ); } private function onInit( event:Event ):void { //setup event listeners /*systemManager is where event listener hangs out defines the relationship between event and handler*/ systemManager.addEventListener( GetNewsEvent.GET_NEWS_EVENT, handler_GetNewsEvent ); systemManager.addEventListener( AddNewsEvent.ADD_NEWS_EVENT, handler_AddNewsEvent ); systemManager.addEventListener( NewsDataLoadedEvent.NEWS_LOADED_EVENT, handler_NewsLoadedEvent ); getNewsData(); } And I had trace statements in all of my handlers... this is how i noticed things were not working as they should. SO I added a simple check like (in my FlexbController constructor): if (systemManager.addEventListener( GetNewsEvent.GET_NEWS_EVENT, handler_GetNewsEvent )) { trace(true); } else { trace(false); } And I obviously am getting false. Ideas? dnk -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo! Groups Links
Re: [flexcoders] custom event not added
ok, well that explains that part, however either my event is not added, or my event handler is never called. My trace statements never show up So I guess I still am wondering if anyone has any ideas dnk On 23-May-08, at 4:56 AM, Paul Andrews wrote: addEventListener() does not return a value.. - Original Message - From: dnk [EMAIL PROTECTED] To: flexcoders@yahoogroups.com Sent: Friday, May 23, 2008 12:47 PM Subject: [flexcoders] custom event not added Hi there, I have a controller that is adding my custom event listeners, but for some reason my event handler was not being fired. My original code was (snippet): (in controler) //constructor public function FlexbController() { //turn the key, start it up addEventListener( FlexEvent.CREATION_COMPLETE, onInit ); } private function onInit( event:Event ):void { //setup event listeners /*systemManager is where event listener hangs out defines the relationship between event and handler*/ systemManager.addEventListener( GetNewsEvent.GET_NEWS_EVENT, handler_GetNewsEvent ); systemManager.addEventListener( AddNewsEvent.ADD_NEWS_EVENT, handler_AddNewsEvent ); systemManager.addEventListener( NewsDataLoadedEvent.NEWS_LOADED_EVENT, handler_NewsLoadedEvent ); getNewsData(); } And I had trace statements in all of my handlers... this is how i noticed things were not working as they should. SO I added a simple check like (in my FlexbController constructor): if (systemManager.addEventListener( GetNewsEvent.GET_NEWS_EVENT, handler_GetNewsEvent )) { trace(true); } else { trace(false); } And I obviously am getting false. Ideas? dnk -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/ flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo! Groups Links
Re: [flexcoders] custom event not added
What's the event dispatch code look like? On Sat, May 24, 2008 at 11:01 AM, dnk [EMAIL PROTECTED] wrote: ok, well that explains that part, however either my event is not added, or my event handler is never called. My trace statements never show up So I guess I still am wondering if anyone has any ideas dnk On 23-May-08, at 4:56 AM, Paul Andrews wrote: addEventListener() does not return a value.. - Original Message - From: dnk [EMAIL PROTECTED] d.k.emaillists%40gmail.com To: flexcoders@yahoogroups.com flexcoders%40yahoogroups.com Sent: Friday, May 23, 2008 12:47 PM Subject: [flexcoders] custom event not added Hi there, I have a controller that is adding my custom event listeners, but for some reason my event handler was not being fired. My original code was (snippet): (in controler) //constructor public function FlexbController() { //turn the key, start it up addEventListener( FlexEvent.CREATION_COMPLETE, onInit ); } private function onInit( event:Event ):void { //setup event listeners /*systemManager is where event listener hangs out defines the relationship between event and handler*/ systemManager.addEventListener( GetNewsEvent.GET_NEWS_EVENT, handler_GetNewsEvent ); systemManager.addEventListener( AddNewsEvent.ADD_NEWS_EVENT, handler_AddNewsEvent ); systemManager.addEventListener( NewsDataLoadedEvent.NEWS_LOADED_EVENT, handler_NewsLoadedEvent ); getNewsData(); } And I had trace statements in all of my handlers... this is how i noticed things were not working as they should. SO I added a simple check like (in my FlexbController constructor): if (systemManager.addEventListener( GetNewsEvent.GET_NEWS_EVENT, handler_GetNewsEvent )) { trace(true); } else { trace(false); } And I obviously am getting false. Ideas? dnk -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo! Groups Links -- Therefore, send not to know For whom the bell tolls. It tolls for thee. :: Josh 'G-Funk' McDonald :: 0437 221 380 :: [EMAIL PROTECTED]
Re: [flexcoders] custom event not added
It is dispatched like this (in function in my controller): dispatchEvent(new GetNewsEvent(GetNewsEvent.GET_NEWS_EVENT, null, false, false)); the null is used for an object (if I need to pass data with my event). In this particular case I did not. My actual event class looks like: package Flexb.events { import flash.events.Event; public class GetNewsEvent extends Event { protected var _data:Object; public static const GET_NEWS_EVENT:String=GetNewsEventType; public function GetNewsEvent( type:String, data:Object = null, bubbles:Boolean=true, cancelable:Boolean=false ):void { _data = data; super(GET_NEWS_EVENT,true,false); } public function get data():Object { return _data; } } } dnk On 23-May-08, at 6:16 PM, Josh McDonald wrote: What's the event dispatch code look like? On Sat, May 24, 2008 at 11:01 AM, dnk [EMAIL PROTECTED] wrote: ok, well that explains that part, however either my event is not added, or my event handler is never called. My trace statements never show up So I guess I still am wondering if anyone has any ideas dnk On 23-May-08, at 4:56 AM, Paul Andrews wrote: addEventListener() does not return a value.. - Original Message - From: dnk [EMAIL PROTECTED] To: flexcoders@yahoogroups.com Sent: Friday, May 23, 2008 12:47 PM Subject: [flexcoders] custom event not added Hi there, I have a controller that is adding my custom event listeners, but for some reason my event handler was not being fired. My original code was (snippet): (in controler) //constructor public function FlexbController() { //turn the key, start it up addEventListener( FlexEvent.CREATION_COMPLETE, onInit ); } private function onInit( event:Event ):void { //setup event listeners /*systemManager is where event listener hangs out defines the relationship between event and handler*/ systemManager.addEventListener( GetNewsEvent.GET_NEWS_EVENT, handler_GetNewsEvent ); systemManager.addEventListener( AddNewsEvent.ADD_NEWS_EVENT, handler_AddNewsEvent ); systemManager .addEventListener( NewsDataLoadedEvent.NEWS_LOADED_EVENT, handler_NewsLoadedEvent ); getNewsData(); } And I had trace statements in all of my handlers... this is how i noticed things were not working as they should. SO I added a simple check like (in my FlexbController constructor): if (systemManager.addEventListener( GetNewsEvent.GET_NEWS_EVENT, handler_GetNewsEvent )) { trace(true); } else { trace(false); } And I obviously am getting false. Ideas? dnk -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo! Groups Links -- Therefore, send not to know For whom the bell tolls. It tolls for thee. :: Josh 'G-Funk' McDonald :: 0437 221 380 :: [EMAIL PROTECTED] -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo! Groups Links * To visit your group on the web, go to: http://groups.yahoo.com/group/flexcoders/ * Your email settings: Individual Email | Traditional * To change settings online go to: http://groups.yahoo.com/group/flexcoders/join (Yahoo! ID required) * To change settings via email: mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] * To unsubscribe from this group, send an email to: [EMAIL PROTECTED] * Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/
Re: [flexcoders] custom event not added
The only thing i can think of after looking at that is that your controller (whatever that is) is not part of the display tree? Try replacing dispatchEvent() with Application.application.dispatchEvent() and see if it works then. -J On Sat, May 24, 2008 at 2:28 PM, dnk [EMAIL PROTECTED] wrote: It is dispatched like this (in function in my controller): dispatchEvent(new GetNewsEvent(GetNewsEvent.GET_NEWS_EVENT, null, false, false)); the null is used for an object (if I need to pass data with my event). In this particular case I did not. My actual event class looks like: package Flexb.events { import flash.events.Event; public class GetNewsEvent extends Event { protected var _data:Object; public static const GET_NEWS_EVENT:String=GetNewsEventType; public function GetNewsEvent( type:String, data:Object = null, bubbles:Boolean=true, cancelable:Boolean=false ):void { _data = data; super(GET_NEWS_EVENT,true,false); } public function get data():Object { return _data; } } } dnk On 23-May-08, at 6:16 PM, Josh McDonald wrote: What's the event dispatch code look like? On Sat, May 24, 2008 at 11:01 AM, dnk [EMAIL PROTECTED] wrote: ok, well that explains that part, however either my event is not added, or my event handler is never called. My trace statements never show up So I guess I still am wondering if anyone has any ideas dnk On 23-May-08, at 4:56 AM, Paul Andrews wrote: addEventListener() does not return a value.. - Original Message - From: dnk [EMAIL PROTECTED] To: flexcoders@yahoogroups.com Sent: Friday, May 23, 2008 12:47 PM Subject: [flexcoders] custom event not added Hi there, I have a controller that is adding my custom event listeners, but for some reason my event handler was not being fired. My original code was (snippet): (in controler) //constructor public function FlexbController() { //turn the key, start it up addEventListener( FlexEvent.CREATION_COMPLETE, onInit ); } private function onInit( event:Event ):void { //setup event listeners /*systemManager is where event listener hangs out defines the relationship between event and handler*/ systemManager.addEventListener( GetNewsEvent.GET_NEWS_EVENT, handler_GetNewsEvent ); systemManager.addEventListener( AddNewsEvent.ADD_NEWS_EVENT, handler_AddNewsEvent ); systemManager .addEventListener( NewsDataLoadedEvent.NEWS_LOADED_EVENT, handler_NewsLoadedEvent ); getNewsData(); } And I had trace statements in all of my handlers... this is how i noticed things were not working as they should. SO I added a simple check like (in my FlexbController constructor): if (systemManager.addEventListener( GetNewsEvent.GET_NEWS_EVENT, handler_GetNewsEvent )) { trace(true); } else { trace(false); } And I obviously am getting false. Ideas? dnk -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo! Groups Links -- Therefore, send not to know For whom the bell tolls. It tolls for thee. :: Josh 'G-Funk' McDonald :: 0437 221 380 :: [EMAIL PROTECTED] -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo! Groups Links -- Therefore, send not to know For whom the bell tolls. It tolls for thee. :: Josh 'G-Funk' McDonald :: 0437 221 380 :: [EMAIL PROTECTED]
Re: [flexcoders] custom event not added
That added an error: Access of undefined property Application researching that now... d On 23-May-08, at 9:35 PM, Josh McDonald wrote: The only thing i can think of after looking at that is that your controller (whatever that is) is not part of the display tree? Try replacing dispatchEvent() with Application.application.dispatchEvent() and see if it works then. -J On Sat, May 24, 2008 at 2:28 PM, dnk [EMAIL PROTECTED] wrote: It is dispatched like this (in function in my controller): dispatchEvent(new GetNewsEvent(GetNewsEvent.GET_NEWS_EVENT, null, false, false)); the null is used for an object (if I need to pass data with my event). In this particular case I did not. My actual event class looks like: package Flexb.events { import flash.events.Event; public class GetNewsEvent extends Event { protected var _data:Object; public static const GET_NEWS_EVENT:String=GetNewsEventType; public function GetNewsEvent( type:String, data:Object = null, bubbles:Boolean=true, cancelable:Boolean=false ):void { _data = data; super(GET_NEWS_EVENT,true,false); } public function get data():Object { return _data; } } } dnk On 23-May-08, at 6:16 PM, Josh McDonald wrote: What's the event dispatch code look like? On Sat, May 24, 2008 at 11:01 AM, dnk [EMAIL PROTECTED] wrote: ok, well that explains that part, however either my event is not added, or my event handler is never called. My trace statements never show up So I guess I still am wondering if anyone has any ideas dnk On 23-May-08, at 4:56 AM, Paul Andrews wrote: addEventListener() does not return a value.. - Original Message - From: dnk [EMAIL PROTECTED] To: flexcoders@yahoogroups.com Sent: Friday, May 23, 2008 12:47 PM Subject: [flexcoders] custom event not added Hi there, I have a controller that is adding my custom event listeners, but for some reason my event handler was not being fired. My original code was (snippet): (in controler) //constructor public function FlexbController() { //turn the key, start it up addEventListener( FlexEvent.CREATION_COMPLETE, onInit ); } private function onInit( event:Event ):void { //setup event listeners /*systemManager is where event listener hangs out defines the relationship between event and handler*/ systemManager.addEventListener( GetNewsEvent.GET_NEWS_EVENT, handler_GetNewsEvent ); systemManager.addEventListener( AddNewsEvent.ADD_NEWS_EVENT, handler_AddNewsEvent ); systemManager .addEventListener( NewsDataLoadedEvent.NEWS_LOADED_EVENT, handler_NewsLoadedEvent ); getNewsData(); } And I had trace statements in all of my handlers... this is how i noticed things were not working as they should. SO I added a simple check like (in my FlexbController constructor): if (systemManager.addEventListener( GetNewsEvent.GET_NEWS_EVENT, handler_GetNewsEvent )) { trace(true); } else { trace(false); } And I obviously am getting false. Ideas? dnk -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo! Groups Links -- Therefore, send not to know For whom the bell tolls. It tolls for thee. :: Josh 'G-Funk' McDonald :: 0437 221 380 :: [EMAIL PROTECTED] -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo ! Groups Links -- Therefore, send not to know For whom the bell tolls. It tolls for thee. :: Josh 'G-Funk' McDonald :: 0437 221 380 :: [EMAIL PROTECTED] -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo! Groups Links * To visit your group on the web, go to: http://groups.yahoo.com/group/flexcoders/ * Your email settings: Individual Email | Traditional * To change settings online go to: http://groups.yahoo.com/group/flexcoders/join (Yahoo! ID required) * To change settings via email: mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] * To unsubscribe from this group, send an email to: [EMAIL PROTECTED] * Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/
Re: [flexcoders] custom event not added
If you're getting a runtime error accessing Application.application you'll need fire to clean this up, methinks. -J On Sat, May 24, 2008 at 3:02 PM, dnk [EMAIL PROTECTED] wrote: That added an error: Access of undefined property Application researching that now... d On 23-May-08, at 9:35 PM, Josh McDonald wrote: The only thing i can think of after looking at that is that your controller (whatever that is) is not part of the display tree? Try replacing dispatchEvent() with Application.application.dispatchEvent() and see if it works then. -J On Sat, May 24, 2008 at 2:28 PM, dnk [EMAIL PROTECTED] wrote: It is dispatched like this (in function in my controller): dispatchEvent(new GetNewsEvent(GetNewsEvent.GET_NEWS_EVENT, null, false, false)); the null is used for an object (if I need to pass data with my event). In this particular case I did not. My actual event class looks like: package Flexb.events { import flash.events.Event; public class GetNewsEvent extends Event { protected var _data:Object; public static const GET_NEWS_EVENT:String=GetNewsEventType; public function GetNewsEvent( type:String, data:Object = null, bubbles:Boolean=true, cancelable:Boolean=false ):void { _data = data; super(GET_NEWS_EVENT,true,false); } public function get data():Object { return _data; } } } dnk On 23-May-08, at 6:16 PM, Josh McDonald wrote: What's the event dispatch code look like? On Sat, May 24, 2008 at 11:01 AM, dnk [EMAIL PROTECTED] wrote: ok, well that explains that part, however either my event is not added, or my event handler is never called. My trace statements never show up So I guess I still am wondering if anyone has any ideas dnk On 23-May-08, at 4:56 AM, Paul Andrews wrote: addEventListener() does not return a value.. - Original Message - From: dnk [EMAIL PROTECTED] To: flexcoders@yahoogroups.com Sent: Friday, May 23, 2008 12:47 PM Subject: [flexcoders] custom event not added Hi there, I have a controller that is adding my custom event listeners, but for some reason my event handler was not being fired. My original code was (snippet): (in controler) //constructor public function FlexbController() { //turn the key, start it up addEventListener( FlexEvent.CREATION_COMPLETE, onInit ); } private function onInit( event:Event ):void { //setup event listeners /*systemManager is where event listener hangs out defines the relationship between event and handler*/ systemManager.addEventListener( GetNewsEvent.GET_NEWS_EVENT, handler_GetNewsEvent ); systemManager.addEventListener( AddNewsEvent.ADD_NEWS_EVENT, handler_AddNewsEvent ); systemManager .addEventListener( NewsDataLoadedEvent.NEWS_LOADED_EVENT, handler_NewsLoadedEvent ); getNewsData(); } And I had trace statements in all of my handlers... this is how i noticed things were not working as they should. SO I added a simple check like (in my FlexbController constructor): if (systemManager.addEventListener( GetNewsEvent.GET_NEWS_EVENT, handler_GetNewsEvent )) { trace(true); } else { trace(false); } And I obviously am getting false. Ideas? dnk -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo! Groups Links -- Therefore, send not to know For whom the bell tolls. It tolls for thee. :: Josh 'G-Funk' McDonald :: 0437 221 380 :: [EMAIL PROTECTED] -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo ! Groups Links -- Therefore, send not to know For whom the bell tolls. It tolls for thee. :: Josh 'G-Funk' McDonald :: 0437 221 380 :: [EMAIL PROTECTED] -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo! Groups Links -- Therefore, send not to know For whom the bell tolls. It tolls for thee. :: Josh 'G-Funk' McDonald :: 0437 221 380 :: [EMAIL PROTECTED]