FORUMS: list search recent posts

Event Listener actionscript 3.0

COW Forums : Adobe Flash

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Neha Gandhi
Event Listener actionscript 3.0
on Aug 28, 2010 at 2:18:07 am

Hi guys,

I have one as 3.0 class called WSManager class, which looks like below:

package
{

import flash.events.Event;
import mx.rpc.soap.*;
import mx.core.*;
import mx.rpc.events.*;
import flash.display.*;
import DeviceVO;

public class WSManager extends Sprite
{

private var _ws:WebService;
private var _data:Vector.<DeviceVO > ;

public function WSManager()
{
_ws = new WebService();
}

public function load(wsdl:String):void
{
_ws.wsdl = wsdl;
_ws.loadWSDL();
}

public function setOperation(oper:String, deviceName:String):void
{
var myOperation:Operation;
myOperation = Operation(_ws.getOperation(oper));
myOperation.addEventListener(FaultEvent.FAULT, wsFault);
myOperation.addEventListener(ResultEvent.RESULT, wsResult);
myOperation.send(deviceName);

}

private function wsResult(evt:ResultEvent)
{

// initialize vector
_data = new Vector.<DeviceVO>();

// declare variables
var vo:DeviceVO;
var device:Object;

// iterate results
for each (device in evt.result.Devices)
{

vo = new DeviceVO();
vo.parseData(device);
// this is the same as using _data.push()
// but this is more performant code
_data[_data.length] = vo;

}
// dispatch this event to let your .fla file know
// all the data has been loaded successfully.
trace("Dispatch event from WSManager class......");
dispatchEvent(new Event("dispatch"));
}

private function wsFault(evt:FaultEvent)
{
trace('something went wrong...');
}
public function get data():Vector.<DeviceVO>
{
return _data;
}
public function set data(data:Vector.<DeviceVO>):void
{
_data = data;
}
}
}


Then i have another GUI class called demo2_as3.fla which calls WSManager class to extract all the data from it. The code is below:


var _ws:WSManager=new WSManager();

_ws.load("http://192.168.11.19/amddevices/request.asmx?WSDL");

_ws.setOperation("GetDeviceInfo", "");

_ws.addEventListener("dispatch", dataReadyHandler);



The problem that i am stuck on is the WSManager class keeps on tdispatching event again and again, which keeps on refreshing the dataReadyHandler() in demo2_as3 class. I am stuck in a loop. I am unable to do anything.

Could anyone tell me, why WSManager keeps on dispatching events like every 8 sec. Can we stop it and restrict to only dispatch.

Thanks,
Neh


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 CreativeCOW.net All Rights Reserved
[TOP]