HelloWorld Help Needed
Hi Adobe Community,
I'm writing because I need some assistance with the HelloWorld example in the FMS 4 documentation.
My setup is as follows all on a local network:
Server
---------
Flash Media Server 4
Apache 2.2 (used FMS installer to set this up)
CentOS 5.3
Firewall Disabled (for simplicity at the moment)
Dev Machine
--------
Windows 7 Home Premium
Flash CS5
I installed FMS 4 just fine. I can reach the Administrator console, view the index.html, play the videos etc.
I created a folder called HelloWorld under the installpath/applications directory. I placed my HelloWorld.asc file as built and instructed by the documentation.
On the developement machine I have my HelloWorld.fla + HelloWorld.as script in the same directory.
I set the connection line HelloWorld.as to... :
nc.connect("rtmp://192.168.1.4/HelloWorld");
This way it would point out to the FMS server and I get the following from trace() after testing (aka building the swf):
Connecting...
Error #2044: Unhandled NetStatusEvent:. level=error, code=NetConnection.Connect.Failed
at HelloWorld/connectHandler()
I found on here searching around that the following line needed to be added to HelloWorld.as:
import flash.events.NetStatusEvent;
Can an expert please assist me? Any responses are better than no response ![]()
Best,
AmarettoSlim
-----
Here is HelloWorld.as
/*
* (C) Copyright 2010 Adobe Systems Incorporated. All Rights Reserved.
*
* NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the
* terms of the Adobe license agreement accompanying it. If you have received this file from a
* source other than Adobe, then your use, modification, or distribution of it requires the prior
* written permission of Adobe.
* THIS CODE AND INFORMATION IS PROVIDED "AS-IS" WITHOUT WARRANTY OF
* ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
* PARTICULAR PURPOSE.
*
* THIS CODE IS NOT SUPPORTED BY Adobe Systems Incorporated.
*
*/
package {
import flash.display.MovieClip;
import flash.net.Responder;
import flash.net.NetConnection;
import flash.events.NetStatusEvent;
import flash.events.MouseEvent;
public class HelloWorld extends MovieClip {
// Represents a network connection.
private var nc:NetConnection;
// Responder for call to server's serverHelloMsg -- see onReply() below.
private var myResponder:Responder = new Responder(onReply);
// Constructor.
public function HelloWorld() {
// Set display values.
textLbl.text = "";
connectBtn.label = "Connect";
// Register a listener for mouse clicks on the button.
connectBtn.addEventListener(MouseEvent.CLICK, connectHandler);
}
// When button is pressed, connect to or disconnect from the server.
public function connectHandler(event:MouseEvent):void {
if (connectBtn.label == "Connect") {
trace("Connecting...");
nc = new NetConnection();
// Connect to the server.
nc.connect("rtmp://192.168.1.4/HelloWorld");
// Call the server's client function serverHelloMsg, in HelloWorld.asc.
nc.call("serverHelloMsg", myResponder, "World");
connectBtn.label = "Disconnect";
} else {
trace("Disconnecting...");
// Close the connection.
nc.close();
connectBtn.label = "Connect";
textLbl.text = "";
}
}
// Responder function for nc.call() in connectHandler().
private function onReply(result:Object):void {
trace("onReply received value: " + result);
textLbl.text = String(result);
}
}
}
