I had a theory I wanted to test this morning : Can I transfer files from point 2 point using Central and some sort of proxy. 5 minutes of thought, 5 minutes of code, and the answer was yes. Basically I just read in a binary file, sent the binary data across the wire, wrote the binary on receive, and opened it up. Below is the echo code. NOTE: the flashcom app does nothing but accepts the connection.
import mx.central.Application;
import mx.central.Shell;
import mx.central.Central;
import mx.utils.Delegate;
import mx.controls.Button;
class TestCFT implements Application{
private static var __minW:Number = 500;
private static var __minH:Number = 500;
private static var __FCS_PATH:String =
"rtmp://localhost/filetransfer/";
private var __shell:Shell;
private var __mc:MovieClip;
private var __nc:NetConnection;
private var __outstream:NetStream;
private var __instream:NetStream;
public function TestCFT(oMc:MovieClip){
__mc = oMc;
Central.initApplication(__mc, this);
}
public function init():Void{
__nc = new NetConnection();
__nc.connect(TestCFT.__FCS_PATH);
__nc.onStatus = Delegate.create(this, onStatus);
draw();
}
public function draw():Void{
var depth:Number = 0;
var sendBtn:Button = Button(__mc.attachMovie
( "Button", "send_btn", depth++ ));
var img:MovieClip = __mc.createEmptyMovieClip
("image_mc", depth++);
sendBtn.label = "send file";
sendBtn.move(10, 10);
sendBtn.clickHandler = Delegate.create(this, sendFile);
img._x = 10;
img._y = sendBtn.y + sendBtn.height + 10;
}
public function renderFile(oFile:Object):Void{
var f:FileReference = new FileReference();
f.create(oFile.name);
f.writeBytes(oFile.bytes);
f.close();
__mc.image_mc.loadMovie(oFile.name);
}
public function sendFile():Void{
var f = new FileReference();
var fTransfer:Object = {};
if (f.browse()) {
fTransfer.name = f.name;
fTransfer.bytes = f.readBytes(f.size);
f.close();
}
__outstream.send("renderFile", fTransfer);
}
public function onStatus(oInfo:Object):Void{
if(oInfo.code == "NetConnection.Connect.Success"){
__outstream = new NetStream(__nc);
__instream = new NetStream(__nc);
__instream["renderFile"] = Delegate.create
(this, renderFile);
__outstream.publish("filetransfer");
__instream.play("filetransfer", -1);
}
}
public function getMinimumSize(Void):Object{
return {width:__minW, height:__minH};
}
public function onActivate(oShell:Shell, iAppID:Number,
iShellID:Number, iBaseTabIndex:Number, oInitData:Object):Void{
__shell = oShell;
init();
}
public function onResize(Void):Void{ }
public function onDeactivate(Void):Void{}
public function onNetworkChange(bIsConnected:Boolean):Void{}
public function onNoticeEvent(oEvent:Object,
oData:Object, oInitData:Object):Void{}
public function onPaymentResult(bResult:Boolean,
oTransactionID:Object):Void{}
public function onSelectedItem(aData:Array):Void{}
public function onUninstall(Void):Void{}
public function showPreferences(Void):Void{}
}



