is this making sense? I created two dispatchEvent s
I created two dispatchEvent. I'm trying to have a double safety on data retrieval. i have a dispatchEvent in contentLoaded and the last dispatchEvent in loadedContent. If i had loadedContent by itself it will still work. It this unnecessary? does it make sense to listen for a complete event and then launch another? THanks.................
package com.class.php
{
import flash.events.*;
import flash.net.*;
public class Grabber extends EventDispatcher
{
public var phpFile:String;
public var remoteFile:String;
public var req:URLRequest;
private var vars:URLVariables = new URLVariables();
private var loader:URLLoader = new URLLoader();
public var data:String;
public function Grabber()
{
}
public function load(php:String, remote:String):void
{
phpFile = php;
remoteFile = remote;
req = new URLRequest(phpFile);
vars.fileName = remoteFile;
req.data = vars;
req.method = URLRequestMethod.POST;
loader.load(req);
loader.addEventListener(Event.COMPLETE, contentLoaded, false, 0, true);
addEventListener("checkEvent", loadedContent, false, 0, true);
}
//I guess i want to have a double safety to make sure I'm getting data
private function contentLoaded(event:Event):void
{
dispatchEvent(new Event("checkEvent"));
}
//data is passes to the fla file. it works fine
private function loadedContent(event:Event):void
{
data = loader.data;
dispatchEvent(new Event(Event.COMPLETE));
}
}//END CLASS GRABBER
}//END PACKAGE
|