I had a quick try with Remote SO in
Flex Beta 2 and while I can trace out a [object SharedObject]
I am not seeing
the object being created in the FMS
console. I also don't get an onsync
event.
No SharedObject folder is being created either.
Here's my code, based on Brian Lesser's smaple app. Could this be a bug?
<?xml version="1.0"
encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns="*" layout="vertical" applicationComplete="init()">
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns="*" layout="vertical" applicationComplete="init()">
<mx:TextArea width="622"
height="291" id="traceArea" wordWrap="true"/>
<mx:Form width="622">
<mx:FormItem horizontalAlign="right" width="560">
<mx:Button label="Connect" id="connectButton" click="connect();" width="100"/>
</mx:FormItem>
</mx:Form>
<mx:Script>
<![CDATA[
import flash.net;
import flash.events;
import flash.util;
<mx:Form width="622">
<mx:FormItem horizontalAlign="right" width="560">
<mx:Button label="Connect" id="connectButton" click="connect();" width="100"/>
</mx:FormItem>
</mx:Form>
<mx:Script>
<![CDATA[
import flash.net;
import flash.events;
import flash.util;
NetConnection.defaultObjectEncoding = flash.net.ObjectEncoding.AMF0;
SharedObject.defaultObjectEncoding = flash.net.ObjectEncoding.AMF0;
// NetConnection to be used throughout this script:
private var nc:NetConnection;
private var so:SharedObject;
// echoResponder is used when nc.call("echo", echoResponder ...) is called.
private var echoResponder:Responder = new Responder(echoResult, echoStatus);
private function
init():void{
writeln("Initializing application... in player: " + flash.system.Capabilities.version + "\n");
// Create the NetConnection and listen for NetStatusEvent and
nc = new NetConnection();
nc.addEventListener(NetStatusEvent.NET_STATUS, netStatus);
nc.addEventListener(SecurityErrorEvent.SECURITY_ERROR, netSecurityError);
}
private function soSync(event:SyncEvent):void
{
writeln("SOSYNC");
}
writeln("Initializing application... in player: " + flash.system.Capabilities.version + "\n");
// Create the NetConnection and listen for NetStatusEvent and
nc = new NetConnection();
nc.addEventListener(NetStatusEvent.NET_STATUS, netStatus);
nc.addEventListener(SecurityErrorEvent.SECURITY_ERROR, netSecurityError);
}
private function soSync(event:SyncEvent):void
{
writeln("SOSYNC");
}
private function netStatus(event:NetStatusEvent):void
{
// Write out information about connection events:
writeln("netStatus: " + event);
var info:Object = event.info;
for(var p:String in info) {
writeln(p + " : " + info[p]);
}
writeln("");
// Change the application state if we connect or disconnect.
switch(info.code){
case "NetConnection.Connect.Success":
so = SharedObject.getRemote("remoteso", nc.uri, true);
writeln("so: " + so);
so.addEventListener(SyncEvent.SYNC, soSync);
// Write out information about connection events:
writeln("netStatus: " + event);
var info:Object = event.info;
for(var p:String in info) {
writeln(p + " : " + info[p]);
}
writeln("");
// Change the application state if we connect or disconnect.
switch(info.code){
case "NetConnection.Connect.Success":
so = SharedObject.getRemote("remoteso", nc.uri, true);
writeln("so: " + so);
so.addEventListener(SyncEvent.SYNC, soSync);
// Adjust
Buttons
connectButton.label = "Disconnect";
connectButton.enabled = true;
break;
case "NetConnection.Connect.Closed":
connectButton.label = "Connect";
connectButton.enabled = true;
break;
}
}
connectButton.label = "Disconnect";
connectButton.enabled = true;
break;
case "NetConnection.Connect.Closed":
connectButton.label = "Connect";
connectButton.enabled = true;
break;
}
}
private function netSecurityError(event:SecurityErrorEvent):void {
writeln("netSecurityError: " + event);
}
/**
* connect is called whenever the connectButton is pressed
* and decides what to do based on the current label of the button.
* NOTE: the rtmp address is in this function. Change it if you need to.
*/
private function connect():void
{
switch(connectButton.label){
case "Connect":
connectButton.label = "Wait";
connectButton.enabled = false;
nc.connect("rtmp:/flex2FMS");
break;
case "Disconnect":
connectButton.label = "Connect";
connectButton.enabled = true;
nc.close();
break;
}
}
/** echoResult is called when the echoResponder gets a result from the nc.call("echoMessage"..) */
private function echoResult(msg:String):void
{
writeln("echoResult: " + msg + "\n");
}
/** echoResult is called when the echoResponder gets a error after a nc.call("echoMessage"..) */
private function echoStatus(event:Event):void
{
writeln("echoStatus: " + event);
}
public function writeln(msg:String):void{
traceArea.text += msg + "\n";
traceArea.validateNow();
//traceArea.vPosition = traceArea.maxVPosition;
}
]]>
</mx:Script>
</mx:Application>
--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
YAHOO! GROUPS LINKS
- Visit your group "flexcoders" on the web.
- To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
- Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.

