The fms4.0 client accesses the server script file main. ASC

Source: Internet
Author: User

Using the example on the offline network, a simple client accesses an application with the graffiti function on the server. Slightly modified.

1. Client

Package {import flash. display. sprite; import flash. events. mouseevent; import flash. events. netstatusevent; import flash. events. syncevent; import flash.net. netconnection; import flash.net. export dobject; import flash. text. textfield; import flash. text. textfieldautosize; import FL. events. colorpickerevent; import flash. events. event; import flash. geom. colortransform; import flash.net. URLRequest; import flash. display. l Oader; public class remotestore extends sprite {private var remotestore: Export dobject; private var con: netconnection; private var pos: array; private var isdrawing: Boolean = false; private var linecolor: uint; private var linethickness: Number = 1.0; private var points: array; private var isfirstsync: Boolean = true; private var sprite: SPRITE = new sprite (); Private var Username: string = "123"; Public Function remote Store () {mog_lb.text = "connecting to the server .... "; this. addchild (mog_lb); var picreq: URLRequest = new URLRequest ("ms.jpg"); var PIC: loader = new loader (); pic. load (picreq); bank. addchild (PIC); bank. addchild (sprite); con = new netconnection (); var clientobj: Object = new object (); // flash.net. netconnection cannot call the onbwdone callback. Clientobj. WB = WB; con. client = clientobj; con. connect ("rtmp: // localhost/remotestore"); con. addeventlistener (netstatusevent. net_status, onconnetstatu);} public function onconnetstatu (E: netstatusevent): void {If (e.info. code = "netconnection. connect. success ") {remotestore = export dobject. getremote ("drawdemo", Con. uri, false); remotestore. connect (CON); remotestore. FPS = 10; remotestore. data. pos = points; remotesto Re. client = This; remotestore. addeventlistener (syncevent. sync, onsynchandler); mog_lb.text = "successfully connected to the server... "; trace (" netconnection. connect. success ");} If (e.info. code = "netconnection. connect. failed ") {mog_lb.text =" failed to connect to the server .. ";}} public function onsynchandler (E: syncevent): void {If (isfirstsync) {This. bank. addeventlistener (mouseevent. mouse_move, onmousemove); this. bank. addeventlistener (mouseevent. mouse_down, on Mousedown); this. bank. addeventlistener (mouseevent. mouse_up, onmouseup); cleaner. addeventlistener (mouseevent. click, clicker); BTN. addeventlistener (mouseevent. click, clicker1);} If (isdrawing) {return;} If (remotestore. data. pos! = NULL) {This. sprite. graphics. linestyle (linethickness, linecolor); var pos: array = remotestore. data. pos as array; For (var I: Int = 0; I <POS. length; I ++) {if (I = 0) {This. sprite. graphics. moveTo (Pos [I]. x, POS [I]. y);} else {This. sprite. graphics. lineto (Pos [I]. x, POS [I]. y) ;}}} public function onmouseup (E: mouseevent): void {remotestore. setproperty ("POS", points); isdrawing = false; remotestore. send ("setlinestyle", linethickness, linecolor, colortran);} public function onmousedown (E: mouseevent): void {getcolor. addeventlistener (colorpickerevent. change, changehandler); getnum. addeventlistener (event. change, changenum); E. updateafterevent (); this. sprite. graphics. linestyle (linethickness, linecolor); points = new array (); this. sprite. graphics. moveTo (E. localx, E. localy); points. push ({X: E. localx, Y: E. localy});} public function onmousemove (E: mouseevent): void {If (E. buttondown) {This. sprite. graphics. lineto (E. localx, E. localy); var P: Object = {X: E. localx, Y: E. localy}; points. push (p); isdrawing = true; E. updateafterevent () ;}} public function setlinestyle (thickness: Number, CLR: uint, Col: uint): void {colortran = Col; linethickness = thickness; linecolor = CLR ;} public Function changehandler (E: colorpickerevent): void {linecolor = e.tar get. selectedcolor;} public function changenum (Event: Event): void {linethickness = event.tar get. value;} public function clicker (Event: mouseevent): void {This. sprite. graphics. clear (); con. call ("clearwb", null, username);} public function clicker1 (Event: mouseevent): void {This. sprite. graphics. clear (); con. call ("clearwb", null, username);} public function WB (username: Object): void {trace ("------ WB --------"); this. sprite. graphics. clear ();}}}

2. server side:

Application. onappstart = function () {trace ("onappstart") ;}; application. onconnect = function (client, uname) {trace ("onconnect =" + uname); client. username = uname; application. acceptconnection (client); // receives data from the client (corresponding to the client's client_nc.call) client. clearwb = function (AA) {trace (AA) application. broadcastmsg ("WB", AA) ;};}; application. onappstop = function () {trace ("onappstop ");};

3. Existing Problems

Problem: the FMS settings are complete and the port is opened. You can connect to the server but cannot access the main. ASC file.

A: Some examples on the Internet are based on fms3.0. When fms4.0 was used for trial, the access was unsuccessful. I thought that I had to reinstall fms3.0, and I accidentally found a solution on the theme board. After installing the FMS, you must open the host file in c: \ windows \ system32 \ drivers \ etc \ hosts, that is, use the Notepad program to open the file. In the last line, add: 127.0.0.1 activate.adobe.com. Restart the server!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.