PDA

View Full Version : problem with NetStatusEvent



test1
September 11th, 2007, 05:37 PM
I'm using amfphp for remoting and I've created a class that extends NetConnection to help out with this. I want to be able to track when connections are made and other events so I can play a cursor animation when things are loading. I've created an event listener for NetStatusEvent inside the class but it doesn't seem to ever get triggered even though the code obviously makes a connection and works. Anyone else had a problem with this or am I doing something wrong?



package
{
import flash.net.NetConnection;
import flash.net.ObjectEncoding;
import flash.events.NetStatusEvent

public class RemotingConnection extends NetConnection
{
public function RemotingConnection()
{
addEventListener(NetStatusEvent.NET_STATUS, netStatus_Handler);
objectEncoding = ObjectEncoding.AMF0;
connect("/flashservices/gateway.php");
}
public function netStatus_Handler(e:NetStatusEvent)
{
trace(e.info.code);
}
}
}

ella_romanos
October 8th, 2007, 06:27 PM
i get an error pointing to the line

private function netStatus(event:NetStatusEvent):Void {

where it says that 'class or interfact NetStatusEvent could not be found'

did you ever get a solution to this?
Thanks


I'm using amfphp for remoting and I've created a class that extends NetConnection to help out with this. I want to be able to track when connections are made and other events so I can play a cursor animation when things are loading. I've created an event listener for NetStatusEvent inside the class but it doesn't seem to ever get triggered even though the code obviously makes a connection and works. Anyone else had a problem with this or am I doing something wrong?



package
{
import flash.net.NetConnection;
import flash.net.ObjectEncoding;
import flash.events.NetStatusEvent

public class RemotingConnection extends NetConnection
{
public function RemotingConnection()
{
addEventListener(NetStatusEvent.NET_STATUS, netStatus_Handler);
objectEncoding = ObjectEncoding.AMF0;
connect("/flashservices/gateway.php");
}
public function netStatus_Handler(e:NetStatusEvent)
{
trace(e.info.code);
}
}
}

test1
October 9th, 2007, 11:27 AM
No, I still haven't solved this issue yet. I was hoping someone could explain why this is happening but so far I haven't heard anything.

test1
October 17th, 2007, 12:18 PM
Can anyone explain this????

juan.mendez
July 22nd, 2008, 03:35 PM
i always wondered how to use flash remoting in AS 3.0

here is a brief explanation..

http://com-juancho.blogspot.com/2008/06/flash-remoting.html

gregbown
August 16th, 2008, 11:06 AM
I've created a class that extends NetConnection to help out with this. Am I doing something wrong?



package
{
import flash.net.NetConnection;
import flash.net.ObjectEncoding;
import flash.events.NetStatusEvent

public class RemotingConnection extends NetConnection
{
public function RemotingConnection()
{
addEventListener(NetStatusEvent.NET_STATUS, netStatus_Handler);
objectEncoding = ObjectEncoding.AMF0;
connect("/flashservices/gateway.php");
}
public function netStatus_Handler(e:NetStatusEvent)
{
trace(e.info.code);
}
}
}


I dont see where you instanciated the object that the event listener is added to?
A NetConnection, NetStream, or SharedObject object dispatches NetStatusEvent objects when a it reports its status. See this link and the examples (http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/events/NetStatusEvent.html).

dail
August 17th, 2008, 01:47 AM
I normally connect something like this


private function setUpNetConnection():void {
nc=new NetConnection();
nc.client = this;
nc.objectEncoding=ObjectEncoding.DEFAULT;

nc.addEventListener(NetStatusEvent.NET_STATUS,netS tatusHandler);
nc.addEventListener(SecurityErrorEvent.SECURITY_ER ROR,securityErrorHandler);
nc.connect(ncUrl,false);

}

private function netStatusHandler(event:NetStatusEvent):void {
//blah
}