Flash FMS AS2 Turn AS3 connection error

Source: Internet
Author: User

AS2:

1. client_nc.showmsg = function (msg) {
2. Txtchat.text + msg;
3.};

Copy Code
AS3:

1. Private function receives object (content): void {
2.//trace ("Onreply received value:" + result);
3. textlbl.text+= content;
4.}

Copy Code
But then, the server says it can't find the receiver, what's going on? The following is the completion of the code, master advice.

Client:

1. Package {
2. Import Flash.display.MovieClip;
3. Import Flash.net.Responder;
4. Import Flash.net.NetConnection;
5. Import Flash.events.MouseEvent;
6. Import Flash.events.NetStatusEvent;
7. Import flash.text.*;
8. Public class HelloWorld extends MovieClip {
9. private var nc:netconnection=new netconnection ();
private Var myresponder:responder=new responder (receiving object);
Public Function HelloWorld () {
textlbl.text= "123";
Connectbtn.label= "Connect";
Connectbtn.addeventlistener (Mouseevent.click,connecthandler);
Nc.addeventlistener (Netstatusevent.net_status,onstatus_fun);
Btn.addeventlistener (Mouseevent.mouse_down, send content);
17.}
Public Function send content (me:mouseevent): void {
Nc.call ("Serverhellomsg", Myresponder, "World", Txt.text);
//TEXTLBL.VERTICALSCROLLPOSITION=TEXTLBL.TEXTFIELD.MAXSCROLLV
21.}
Public Function Onstatus_fun (e:netstatusevent): void {
var info=e.info;
Trace (Info.code);
Switch (info.code) {
Case "NetConnection.Connect.Success":
Trace ("Successful connection" +info.level);
break;
Case "NetConnection.Connect.Closed":
Trace ("has left" +info.level);
break;
Case "NetConnection.Connect.Failed":
Trace ("Connection failed" +info.level);
break;
35.}
Trace ("info.code=" +info.code);
Panax Notoginseng Trace ("info.level=" +info.level);
38.}
Public Function Connecthandler (event:mouseevent): void {
if (Connectbtn.label = = "Connect") {
Trace ("Connecting ...");
Nc.connect ("RTMP://TANKAI1260.GICP.NET/8");
Nc.call ("Serverhellomsg", Myresponder, "World", 123);
Connectbtn.label= "Disconnect";
.} else {
("Disconnecting ...");
Nc.close ();
Connectbtn.label= "Connect";
Textlbl.text= "";
50.}
51.}
The private function receives the object (content): void {
//trace ("Onreply received value:" + result);
textlbl.text+= content;
55.}
56.}
57.}

Copy Code
Server side:

1. Application.onconnect = function (client) {
2. client.serverhellomsg = function (hellostr,mm) {
3. Trace (HELLOSTR)
4. Trace (mm)
5.//Return "Hello," + hellostr +mm+ "!";
6. mesg=hellostr+mm
7. Application.broadcastmsg ("Receive object", mm)
8.}
9. Application.acceptconnection (client);
10.}

Workaround:

Nc.client = this;

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.