package { import flash.display.Sprite; import flash.events.*; import flash.external.ExternalInterface; import flash.media.*; import flash.net.*; import flash.system.Security; import flash.system.SecurityPanel; import flash.text.*; import flash.utils.Timer; import mx.controls.Alert; public class iphone extends Sprite { public var sprite:Sprite = new Sprite; public var nc:NetConnection; public var ns:NetStream; public var microphone:Microphone; public var sname:String = new String(); public var fName:String = new String(); public var info1:TextField = new TextField(); public var on:Boolean=false; private var mySo:SharedObject; [Bindable] public var ev:TextEvent = new TextEvent("onSomeoneWalking",true); public var receivedMessage:TextEvent = new TextEvent("receivedMessage",true); private function receivedFromJavaScript(value:String):void { // output.appendText(mySo.data.savedValue); } public function netStatus1( event:NetStatusEvent ):void { if ( event.info.code == "NetConnection.Connect.Rejected" ) { info1.text ="Rejected"; } if (event.info.code == "NetStream.Play.Stop") { //nsrec.seek(0); info1.text ="Stop"; } if ( event.info.code == "NetConnection.Connect.Success") { info1.text ="Success"; //nc1.call("add",new Responder(onResult, onStatus),1,4); } } public function onResult(obj:Object):void { //list.text += "Сообщение доставлено: " + obj + "\n"; info1.text =obj.toString(); } public function onStatus(obj:Object):void { //printText("The status is " + obj); //info1.text =obj.toString(); info1.text ="onStatus"; } public function iphone() { // nc1.call("add", nc1, 1, 2); // ExternalInterface.addCallback("sendToActionScript", receivedFromJavaScript); // ExternalInterface.call("isReady"); NetConnection.prototype.onBWDone = function(p_bw) {}; sprite.graphics.beginFill(0xf0f0cb,1); sprite.graphics.lineStyle(1,0xf0f0cb,1); sprite.graphics.drawRect(0,0,this.width,this.height); sprite.graphics.endFill(); fName = this.root.loaderInfo.parameters["firstname"]; // mySo = SharedObject.getLocal("myphone"); // if(String(mySo.data.savedValue).length<2){mySo.data.savedValue=fName; // Security.showSettings(SecurityPanel.PRIVACY); // }else fName=mySo.data.savedValue; info1.type = TextFieldType.DYNAMIC; info1.text = "fire"; //info1.text = fName; info1.x =1;info1.y =1; info1.borderColor = 0xFAFAFA; info1.border = true; info1.multiline = true; info1.wordWrap = true; info1.scrollH = 5; info1.alpha = 0.5; info1.backgroundColor = 0xFAFAFA; addChild(info1); /* nc1 = new NetConnection(); nc1.objectEncoding = ObjectEncoding.AMF0; nc1.proxyType = "BEST"; nc1.addEventListener( NetStatusEvent. NET_STATUS , netStatus1 ); nc1.addEventListener(AsyncErrorEvent.ASYNC_ERROR, asyncError1); nc1.connect("rtmp://1.netvps.cu.cc:61371/myapp"); info1.text ="connect"; */ nc = new NetConnection(); nc.objectEncoding = ObjectEncoding.AMF0; nc.proxyType = "BEST"; nc.addEventListener( NetStatusEvent. NET_STATUS , netStatusRecord ); nc.addEventListener(AsyncErrorEvent.ASYNC_ERROR, asyncErrorHandler); nc.addEventListener("onSomeoneWalking", onSomeoneWalking); nc.connect( "rtmp://1.netvps.cu.cc:61371/myapp"); //oflaDemo // nc.connect( "rtmp://phone.hj.cx/oflaDemo" ); } private function onSync(event:SyncEvent) { //list.text=""; for (var k1 in event.changeList) for (var k2 in event.changeList[k1]) { var temp2:String = event.changeList[k1][k2]; info1.text = temp2; if (k2 == "name") { var temp:String = event.changeList[k1][k2]; if (temp == "messages") { var temp1:String = String(event.target.data[temp]); info1.text = temp1; dispatchEvent(ev); } else if (temp == "receivedMessage") { var temp1:String = String(event.target.data[temp]); if (temp1 != "undefined") { info1.text = temp1; dispatchEvent(receivedMessage); } } } } } private function onSomeoneWalking(event:TextEvent):void{ info1.text = "onSomeoneWalking"; } private function asyncError1(event:AsyncErrorEvent):void {info1.text ="AsyncErrorEvent";} private function asyncErrorHandler(event:AsyncErrorEvent):void {} private function nsStart (event:NetStatusEvent):void {} public function netStatusRecord( event:NetStatusEvent ):void { if ( event.info.code == "NetConnection.Connect.Rejected" ) { } if (event.info.code == "NetStream.Play.Stop") { //nsrec.seek(0); } if ( event.info.code == "NetConnection.Connect.Success") { // info1.text = "Connect.Success"; // nc.addEventListener(ev.text, onSomeoneWalking); //nc.call("add",new Responder(onResult, onStatus),2,4); //nc.call("whoami",new Responder(onResult, onStatus),"dddddddd"); /* mySo = SharedObject.getRemote("mySO", nc.uri, true); mySo.addEventListener(SyncEvent.SYNC, onSync); mySo.connect(nc); mySo.data.mybumber = new Number(1234567890); mySo.flush();*/ // video.clear(); // camera = Camera.getCamera(); microphone = Microphone.getMicrophone(); microphone.gain = 99; // microphone.rate(44); // info1.text = microphone.name; // camera.setMode(320,240,24); // if (camera != null) videoPreview.attachCamera(camera); // videoPreview.alpha =1 ; // video.alpha = 0 ; ns = new NetStream(nc); // ns.client = new CustomClient(); // var myTimer:Timer = new Timer(1000, 21111111); // myTimer.addEventListener("timer", timerHandler); // myTimer.start(); // if (camera != null) nsrec.attachCamera(camera); if (microphone != null) ns.attachAudio(microphone); ns.addEventListener( NetStatusEvent.NET_STATUS, nsStart); // nsrec.client = _clientrec; ns.publish(fName.valueOf(), "record"); // view.alpha = 0; // rec.alpha = 1; // myGIFPlayer.play(); // rec.play(); } } public function timerHandler(event:TimerEvent):void { //trace("timerHandler: " + event); //info1.text = ns.client.fName; } } }/* class CustomClient { public var fName:String = new String(); public var z1:Number=0; public function onMetaData(info:Object):void { fName=z1.toString();//info.framerate; z1++; trace("metadata: duration=" + info.duration + " width=" + info.width + " height=" + info.height + " framerate=" + info.framerate); } public function onCuePoint(info:Object):void { fName=z1.toString();//info.framerate; z1++; trace("cuepoint: time=" + info.time + " name=" + info.name + " type=" + info.type); } }*/