Without looking at your code or knowing specifically where the references 
stored in currentGroup originated ... I would nevertheless suspect that you are 
working with Flex 1.5 and having an issue with the "this is not this this"  
scoping problem. You might want to read these:

http://www.macromedia.com/devnet/flash/articles/eventproxy.html
http://www.erikbianchi.com/archives/flash_platform/


Essentially, when you are adding your event listeners, add a delegate to ensure 
that on callback the listener will be using the correct scope when 
dereferencing the event parameters.

Where you might have code like this:

  controller.addEventListener("changeGroup", function(event) {
    // warning: grp may be in wrong scope...
    var grp = event.group;
    // do something...
  });

Change it to this:

  controller.addEventListener("changeGroup",
              mx.utils.Delegate.create(this, function(event) {

    var grp = event.group;
    // do something...
  }));
  


Or if your code looked like this:



  controller.addEventListener("changeGroup", callbackFunc);

  
Change it to this:

  var callbackDelegate;
  ...

  callbackDelegate = mx.utils.Delegate.create(this, callbackFunc);

  controller.addEventListener("changeGroup", callbackDelegate);
  ...

  Controller.removeEventListener("changeGroup", callbackDelegate);



Good luck.

-Tony


tony pujals| senior engineer | Yahoo! SiteBuilder Express
p. 408.349.6284 | e. tonyp * yahoo-inc . com | y!id tonypujals

________________________________________
From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Sauro, 
Nick
Sent: Thursday, February 16, 2006 10:57 AM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Actionscripting and dispatching Events

Hey coders, I am running into a problem with dispatching events in AS.

I have an EventDispatcher as part of a Controller object I created.  This 
EventDispatcher has 3 filter objects registered as listeners for a certain 
event.  Now, when I fire that event, I fire it like so:

eventDispatcher.dispatchEvent({type:"changeGroup", group:currentGroup});

Now currentGroup is another object of type Group, and has an associative array 
of arrays in it of different pieces of data used by the different filters.  

Now,through tracing, when before I dispatch this event, the object is 
intact(all its fields are there with no undefines), but when I dispatch the 
event, and trace its properties on the filter side, I'm getting undefined.  
I've tried this via casting to Group object, as well as just leaving it in its 
Object state.   In particular, an array inside the array is coming up as 
undefined.
The weird part of it is, on the filter side, when I trace the array's length, 
its there, but when I attempt to do anything else to it after that initial 
trace call, its all undefined. 

Am I doing anything blatantly wrong?

Many Thanks

Nick


--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 


SPONSORED LINKS 
Web site design development 
Computer software development 
Software design and development 
Macromedia flex 
Software development best practice 


________________________________________
YAHOO! GROUPS LINKS 

*  Visit your group "flexcoders" on the web.
  
*  To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
  
*  Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service. 

________________________________________



--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/flexcoders/

<*> 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/
 


Reply via email to