I'm getting this error intermittently when attempting to call functions in a localconnection.
Error #2044: Unhandled StatusEvent:. level=error, code=
The "handled" output:
LocalConnection.send() failed [StatusEvent type="status" bubbles=false cancelable=false eventPhase=2 code=null level="error"]
Here is the code that sends the info:
package facebook
{
import flash.events.StatusEvent;
import flash.net.LocalConnection;
public class Leaderboard
{
private var sendLC:LocalConnection = new LocalConnection();
public var leaderboardScores:Object;
public static var LB:Leaderboard;
public function Leaderboard()
{
LB = this;
sendLC.addEventListener(StatusEvent.STATUS, statusError);
}
public function showAbilities():void
{
var abilityArray:Array = [];
for each (var o:Object in leaderboardScores)
{
var player:Array = [o[0], o[1], o[2], o[3].value];
abilityArray.push(player);
}
abilityArray.sortOn([3], Array.NUMERIC);
sendLC.send("_myConnection", "showAbilities", abilityArray);
showDeaths();
}
public function showDeaths():void
{
var deathArray:Array = [];
for each (var o:Object in leaderboardScores)
{
var player:Array = [o[0], o[1], o[2], o[4].value];
deathArray.push(player);
}
deathArray.sortOn([3], Array.NUMERIC);
sendLC.send("_myConnection", "showDeaths", deathArray);
showChallenges();
}
public function showChallenges():void
{
var challengeArray:Array = [];
for each (var o:Object in leaderboardScores)
{
var player:Array = [o[0], o[1], o[2], o[5].value];
challengeArray.push(player);
}
challengeArray.sortOn([3], Array.NUMERIC);
sendLC.send("_myConnection", "showChallenges", challengeArray);
showMoney();
}
public function showMoney():void
{
var moneyArray:Array = [];
for each (var o:Object in leaderboardScores)
{
var player:Array = [o[0], o[1], o[2], o[6].value];
moneyArray.push(player);
}
moneyArray.sortOn([3], Array.NUMERIC);
trace("! ! ! ! ! !SENDING MONEY ! ! ! ! ! !");
sendLC.send("_myConnection", "showMoney", moneyArray);
showBuffs();
}
public function showBuffs():void
{
var buffArray:Array = [];
for each (var o:Object in leaderboardScores)
{
var player:Array = [o[0], o[1], o[2], o[7].value];
buffArray.push(player);
}
buffArray.sortOn([3], Array.NUMERIC);
sendLC.send("_myConnection", "showBuffs", buffArray);
showKills();
}
public function showKills():void
{
var killArray:Array = [];
for each (var o:Object in leaderboardScores)
{
var player:Array = [o[0], o[1], o[2], o[8].value];
killArray.push(player);
}
killArray.sortOn([3], Array.NUMERIC);
sendLC.send("_myConnection", "showKills", killArray);
}
private function statusError(e:StatusEvent):void
{
switch (e.level) {
case "status":
trace( "LocalConnection.send() succeeded");
break;
case "error":
trace( "LocalConnection.send() failed " +e);
break;
}
}
}
}
And here is the recieving code:
package
{
import flash.display.Bitmap;
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.net.LocalConnection;
import flash.events.Event;
public class Main extends Sprite
{
[Embed(source='../assets/leaderboardOutline.png')]
private var outlineClass:Class;
private var receiverLC:LocalConnection = new LocalConnection()
private var background:Bitmap = new outlineClass;
public function Main():void
{
receiverLC.client = this;
if (stage) init();
else addEventListener(Event.ADDED_TO_STAGE, init);
}
private function init(e:Event = null):void
{
removeEventListener(Event.ADDED_TO_STAGE, init);
try
{
this.receiverLC.allowDomain('*')
this.receiverLC.connect("_myConnection");
trace('!~~~~~LocalConnection SUCCEEDED');
}
catch (error:ArgumentError)
{
trace('!~~~~~~LocalConnection FAILURE');
}
addChild(background);
}
public function showAbilities(scores:Array):void
{
trace("ABILITIES\n");
try{
for each (var a:Array in scores)
trace("NAME: " + a[1] + " SCORE: " + a[3]);
}
catch (e:Error)
{
trace("Error " + e);
}
}
public function showDeaths(scores:Array):void
{
trace("DEATHS\n");
try{
for each (var a:Array in scores)
trace("NAME: " + a[1] + " SCORE: " + a[3]);
}
catch (e:Error)
{
trace("Error " + e);
}
}
public function showChallenges(scores:Array):void
{
trace("CHALLENGES\n");
try{
for each (var a:Array in scores)
trace("NAME: " + a[1] + " SCORE: " + a[3]);
}
catch (e:Error)
{
trace("Error " + e);
}
}
public function showMoney(scores:Array):void
{
trace("MONEY\n");
try{
for each (var a:Array in scores)
trace("NAME: " + a[1] + " SCORE: " + a[3]);
}
catch (e:Error)
{
trace("Error " + e);
}
}
public function showBuffs(scores:Array):void
{
trace("BUFFS\n");
try{
for each (var a:Array in scores)
trace("NAME: " + a[1] + " SCORE: " + a[3]);
}
catch (e:Error)
{
trace("Error " + e);
}
}
public function showKills(scores:Array):void
{
trace("KILLS\n");
try{
for each (var a:Array in scores)
trace("NAME: " + a[1] + " SCORE: " + a[3]);
}
catch (e:Error)
{
trace("Error " + e);
}
}
}
}
The searching I've done on the error seems to be of little value. Most people say that declaring the localconnection outside of the function fixed it for them. Can anyone see anything that could cause this error?
Too much information is being passed to the local swf. If you need to change the data quickly create separate LocalConnections for each of the functions.