Your TweetCommEvent's clone method returns a PreferencePaneEvent rather than
the TweetCommEvent I'd expect, at least in the code you wrote below.
It's not that, is it?
public class TweetCommEvent extends Event
{
................
override public function clone():Event {
return new PreferencePaneEvent(type, bubbles, cancelable);
}
..............
}
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf
Of valkyrie77
Sent: 08 March 2009 17:52
To: [email protected]
Subject: [flexcoders] Debugging Event Bubbling
Hi Folks,
I'm currently working on a twitter AIR client using the twitterscript AS3
library and having some issues with bubbling custom events that are created by
nested "classses" back to the main application.
I've architected so that the main application (A) spawns a new timeline window
(B) for every twitter account a user may have. I have a Comm class (C) i use as
a DAO layer to decouple the twitterscript custom events from my framework (in
case i switch to a different as3 API library)
My custom event class looks like this
package com.kubeworks.events
{
import flash.events.Event;
public class TweetCommEvent extends Event
{
public static const TIMELINE_BACK:String = "timelineBack";
public static const STATUS_BACK:String = "statusBack";
public static const USER_INFO_BACK:String = "userInfoBack";
public static const RATE_LIMIT_STATUS:String = "rateLimitBack";
public var data : Object = new Object ();
public function TweetCommEvent(type:String, bubbles:Boolean=true,
cancelable:Boolean=false)
{
super(type, bubbles, cancelable);
}
override public function clone():Event {
return new PreferencePaneEvent(type, bubbles, cancelable);
}
}
}
My Comm Class goes something like
package com.kubeworks.data
{
// Twitter API calls
import com.kubeworks.events.TweetCommEvent;
import flash.events.Event;
import flash.events.EventDispatcher;
import flash.utils.*;
import mx.utils.ObjectUtil;
import twitter.api.Twitter;
import twitter.api.events.TwitterEvent;
public class TweetComm extends EventDispatcher
{
private var username:String;
private var password:String;
private var _twitterClient:Twitter;
// Constructor
public function TweetComm(usern:String, pass:String)
{
// Initialize Twitter Event Listeners
_twitterClient = new Twitter();
_twitterClient.addEventListener(Event.ACTIVATE, twitterClientActivateHandler);
_twitterClient.addEventListener(Event.DEACTIVATE, twitterClientDeactivate);
_twitterClient.addEventListener(TwitterEvent.ON_FRIENDS_TIMELINE_RESULT,
twitterTimelineBack);
_twitterClient.addEventListener(TwitterEvent.ON_SET_STATUS, twitterStatusBack);
_twitterClient.addEventListener(TwitterEvent.ON_SHOW_INFO, twitterUserBack);
_twitterClient.addEventListener(TwitterEvent.ON_RATE_LIMIT_STATUS,
twitterRateLimitBackHandler);
// Do stuff
setLogin(usern, pass);
setAuth();
}
and within that class i'm re-dispatching like:
private function twitterRateLimitBackHandler(event:TwitterEvent):void {
var eventObj:TweetCommEvent = new
TweetCommEvent(TweetCommEvent.RATE_LIMIT_STATUS, true);
eventObj.data = event.data;
dispatchEvent(eventObj);
trace(">>twitterRateLimitBackHandler");
trace(ObjectUtil.toString(event));
trace("<<twitterRateLimitBackHandler");
trace(ObjectUtil.toString(eventObj));
}
I've set the bubbling to true. However in my main application this
EventListener never fires
systemManager.addEventListener(TweetCommEvent.RATE_LIMIT_STATUS,
onRateLimitHandler);
Any help would be greatly appreciated as i am out ideas and have exausted
google and my flex friends.
Thanks,
Sean
______________________________________________________________________
This communication is from Primal Pictures Ltd., a company registered in
England and Wales with registration No. 02622298 and registered office: 4th
Floor, Tennyson House, 159-165 Great Portland Street, London, W1W 5PA, UK. VAT
registration No. 648874577.
This e-mail is confidential and may be privileged. It may be read, copied and
used only by the intended recipient. If you have received it in error, please
contact the sender immediately by return e-mail or by telephoning +44(0)20 7637
1010. Please then delete the e-mail and do not disclose its contents to any
person.
This email has been scanned for Primal Pictures by the MessageLabs Email
Security System.
______________________________________________________________________