Hello to all! First of all, sorry for my poor English.
I have a strange problem with LocalConnection.
Situation: A sample e-shop. I have a parent .swf who load 3-4 external swf.
In a external swf (let’s name it “X”) u can order items u want.
Because i don’t want to lose the informations of the ‘shopping’ bag of customer when the parent swf unload the ‘X’ and load something another (for example “contact us”), i use localconnection with both duplex between parent swf and ‘X’.
Problem: In the swf “X” i have an array “Bag” which holds the id of items the customer clicked to buy. When change the external swf, i send via localconnection to the parent .swf this array (done, i tried with trace).
And when the parent loads again the external .swf “X” , it send again the same array via localconnection to “X”. The “X” receives it right (done, i verified it with trace).
The strange is… when the customer clicks another item, the array resets to zero!!! :o
What is this?
In the parent swf:
public var _connHome:LocalConnection; //Sending to "X"
public var _recMain:LocalConnection; //Receiving from "X"
public var _BagArr:Array = new Array();
_connHome = new localConnection();
_connHome.addEventListener(StatusEvent.STATUS, statusHandler);
_recMain = new LocalConnection();
_recMain.client = this;
try
{
_recMain.connect("for_main");
}
catch (error:ArgumentError)
{
trace("Can't connect...the connection name is already being used by another SWF");
}
public function ForMain(new_text:Array):void
{
_BagArr = new_text;
}
(.......)
(function when load the swf "X")
{
_connHome.send("my_bag", "GetKalathi", _BagArr);
}
In the external swf “X”
public var _recHome:LocalConnection;
public var _connMain:LocalConnection;
public var _BagArr:Array = new Array()
_recHome = new LocalConnection();
_recHome.client = this;
try
{
_recHome.connect("my_bag");
}
catch (error:ArgumentError)
{
trace("Can't connect...the connection name is already being used by another SWF");
}
(....)
_connMain = new LocalConnection();
_connMain.addEventListener(StatusEvent.STATUS, statusHandler);
(.....)
public function GetBag(new_text:Array):void //When load the "X"
{
_BagArr = new_text;
_recHome.close();
}
And when the customer clicks to buy one new item:
private function GoingBox(e:MouseEvent):void
{
_BagArr.push(e.currentTarget.parent.name); //name = id of item
_connMain.send("for_main", "ForMain", _BagArr);
}
I did debug, and i noticed that when it enter in the last function , the array BagArr reset to 0!! :o
I’m sorry for the big post, I hope somebody can help me.