Ultrashock Forums > Flash > ActionScript
AS3 - LocalConnection across domains

You are currently viewing our website as a guest which gives you limited access to forums, files and other resources.

Click here to join now for free, and start interacting with our members, download files and much more!

Click here if you are looking for our Flash files and other professional assets.
 
Post Reply | View first unread | Rate Thread Search this Thread | Thread Tools | Display Modes

#1
Bookmark and Share!
AS3 - LocalConnection across domains
Old 2008-07-26

Hello,

I am building (what will eventually be...) an AIR app that is supposed to receive events from a SWF loaded on any domain. The tool is meant to be an external debugger so it must work between the user's local machine and any website local or not. When both files are on my local machine it works fine, but I am unable to get it to work between my local machine and other websites.

My receiving file's code looks like this:
Code:
var lc:LocalConnection = new LocalConnection();
var lc_title:String = "com.hapticdata.utils.HDDebug";
lc.connect(lc_title);
Security.allowDomain("*");
lc.allowDomain('*');
lc.client = this;
function getFeed(str:*):void {
	outputArea.htmlText += str;
}
function clearFeed():void {
	outputArea.htmlText="";
}
The connection part of the debugger looks like this:
Code:
//this is called to initiate tracing to the external window
public static function enterLocalConnectionMode():void {
	if(turnedOn) mode = LOCALCONNECTION_MODE;
	Security.allowDomain("*");
	lc.allowDomain("*");
lc.addEventListener(StatusEvent.STATUS,localConnectionStatusEventHandler);
}

//this is the method that sends to the local connection, the important code is under "case LOCALCONNECTION_MODE:"
private static function submitLine(message:*):void {
	switch(mode) {
		case TEXTFIELD_MODE:
	        textField.htmlText += message + "\n";
		textField.scrollV = textField.maxScrollV;
		break;
		case LOCALCONNECTION_MODE:
		try {
			if(!connected){ 
                           lc.send(lc_title,"clearFeed"); 
                           trace("clearFeed"); 
                        }
			connected=true;
			lc.send(lc_title,"getFeed",message);
		}
		catch(error:Error) {
			mode = TRACE_MODE;
			trace("COULD NOT FIND LOCALCONNECTION");
			trace("------------------------------");
			trace(message);
		}
		break;
		case TRACE_MODE:
			trace(message);
	}
}
If anyone knows how to get past my domain error's I would be very grateful. Thanks!
-Kyle
postbit arrow 2 comments | 1080 views postbit arrow Reply: with Quote   
Registered User
haptic is offline
seperator
Posts: 38
2004-10-08
seperator

Ultrashock Member Comments:
Nutrox's Avatar Nutrox Nutrox is offline Super Moderator Nutrox lives in United Kingdom 17 Creative Assets 2008-07-26 #2 Old  
Try prefixing the connection names with an underscore, i.e. "_com.hapticdata.utils.HDDebug"
Reply With Quote  
haptic haptic is offline 2008-07-27 #3 Old  
thanks for the input, the underscore did turn out to be necessary. It still wasn't working from doing just that, but once I made it into an official AIR application it began working. It must've been a SecurityError.
Thanks, I'm glad to get this project back into action.
Reply With Quote  
Thread Tools
Display Modes Rate This Thread
Rate This Thread: