View Single Post

#1
Bookmark and Share!
Custom Event with multiple EventTypes and data
Old 2007-10-29

I'm really banging my head on this one.
For some reason I can't see how to do what I want. I have a custom Event Class

Code:
package {
	
	import flash.events.Event;
	import flash.events.EventDispatcher;
	import flash.events.EventPhase;
	
	public class RemotingEvent extends Event {
		// constants for the different event types
		public static const LOGIN_RESULT:String = "login_result";
		public static const IMAGE_UPLOAD:String = "image_upload";
		public static const USER_SIGNUP:String = "user_signup";
		
		public var dataObj:Object;
		public function RemotingEvent(type:String, data:Object, bubbles:Boolean=true, cancelable:Boolean=false) {
			
			// Pass constructor values to superClass constructor
			super(type, bubbles, cancelable);
			
			dataObj = data;
			
		}
		
		// override clone()
		public override function clone():Event {
			return new RemotingEvent(type, dataObj, bubbles, cancelable);
		}
		
		// override toString()
		public override function toString():String {
			return formatToString("RemotingEvent", "type", "dataObj", "bubbles", "cancelable", "eventPhase");
		}
		
	}
}
When I try to dispatch an event I get the error
Code:
1180: Call to a possibly undefined method dispatchEvent.
Here's the code for handling the dispatching of events. This is just one of the methods
from a large remoting class I have written. I have made sure all of my classes are imported.

Here's a list of classes:
import flash.net.NetConnection;
import flash.net.Responder;
import flash.events.*;
import RemotingEvent;

There are others but these are the relevant ones.

Code:
private static function handleLogin_Result(isValid:Array):void {
	// param @ isValid:Array -- Contains 2 items. [0]=="success or error", [1]=="The error string" 
			
	var responseObj:Object = {isAllowed:false, errMsg:""}; 			
	var errStr:String = isValid[0].toLowerCase();
			
	var evt:RemotingEvent;
			
	// check to see if the user has passed in a proper username and password
	if (errStr == "error") {
		// Error has occurred. 
		// Username / Password is incorrect.
		evt = new RemotingEvent(RemotingEvent.LOGIN_RESULT, {err:errStr});
				
				
	} else if (errStr == "success") {
		// Allow the user to login.
		evt = new RemotingEvent(RemotingEvent.LOGIN_RESULT, {err:errStr});
	}
	dispatchEvent(evt);
}
Can someone point out what exactly I'm doing wrong?
I just don't see it. Any help would be greatly appreciated.

Thanks.
postbit arrow 7 comments | 897 views postbit arrow Reply: with Quote   
neilm
Registered User
neilm is offline
seperator
Posts: 8
2001-11-04
seperator

Ultrashock Member Comments: