I found this in the docs:

“To dispatch the change event, the property’s class must either extend EventDispatcher or implement the IEventDispatcher interface.

 

But this is just below it:

“If the class does not extend EventDispatcher or implement IEventDispatcher and one of your properties is marked [Bindable] or the class is marked [Bindable], the MXML compiler modifies the class to implement IEventDispatcher.”

 

If that is right and you have a [Bindable] property, it should just work, yes?

 

Tracy


From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of Jon Hirschi
Sent: Thursday, June 22, 2006 4:45 PM
To: [email protected]
Subject: [flexcoders] how do you dispatch event from a custom class?

 


I have a custom class that I want to be able to
dispatch an event. However, it's not entering the
event into the event stream, I don't even think the
event is getting out of the class. I have bubbles set
to true. does anyone know how to get the event
entered into the event stream... the docs aren't very
explicit on this subject....

ie

code to call my class...

private function
handleLBResponse(eventObj:ResultEvent):void {
var tempArray:Array;
var checkResult:WebServiceCheck = new
WebServiceCheck();
if
(checkResult.checkServiceReturnStatus(eventObj,true))
{
tempArray =
mx.utils.ArrayUtil.toArray(eventObj.result.lbvServerTos);
if (tempArray.length > 1) {
dpLBVServerData.source = tempArray;
} else {
dpLBVServerData.removeAll();
}
} else {
dpLBVServerData.removeAll();
}

}

------------------------------
code in the class

-----------------------------------

package comp.webconfig.services {

import flash.display.Sprite;
import mx.rpc.events.ResultEvent;
import mx.controls.Alert;
import flash.events.Event;
import flash.events.EventDispatcher;

public class WebServiceCheck extends Sprite {



public var isSuccess:Boolean;
public var statusType:String;
public var message:String;
public var rawMessage:String;

public function WebServiceCheck() {

}

public function
checkServiceReturnStatus(resultToCheck:ResultEvent,alertOnError:Boolean=false):Boolean
{
var myMessage:String;
var isSuccess:Boolean = true;
var myRawMessage:String;
var myRawStatus:String;
var dispatcher:EventDispatcher = new
EventDispatcher();
if (resultToCheck.result != null) {
if (resultToCheck.result.requestMessage != null)
{
myRawMessage =
resultToCheck.result.requestMessage;
}
if (resultToCheck.result.requestStatus) {
myRawStatus =
resultToCheck.result.requestStatus;
}
}
if (myRawStatus != null) {
switch (myRawStatus) {
case "Failed" :
// do something here like popup a message
myMessage = "Sorry, there was an error trying to
access the information you requested. \n\n"
myMessage += myRawMessage;
isSuccess = false;
break;
case "Unauthorized" :
// do something here... like popup a message
myMessage = "Sorry, you were not authorized to
access the information you requested. \n\n"
myMessage += myRawMessage;
isSuccess = false;
break;
case "AuthenticationFailed" :
dispatcher.dispatchEvent(new
Event("AuthenticationFailed",true,false));
myMessage = "Sorry, you are either not Logged
in, or you have been logged out. \n\n"
myMessage += myRawMessage;
isSuccess = false;
trace("this person is unauthorized");
break;
default :
// do nothing because they should be fine here.
// this should be a success
myMessage = "Results returned successfully";
break;
}
} else {
// do nothing here because we are guessing that
this was a successful addition
}
if (!isSuccess && alertOnError) {
showErrorMessage(myMessage);
}

this.isSuccess = isSuccess;
this.statusType = myRawStatus;
this.message = myMessage;
this.rawMessage = myRawMessage;

return isSuccess;
}

public function
showErrorMessage(message:String):void {
mx.controls.Alert.show(message,"Error Requesting
data from server");
}
}
}

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

__._,_.___

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




__,_._,___

Reply via email to