Hello,
I have an .as Class file that have a few event handlers in it.... I'm using this class to upload files to my server... here is the code.
Code:
package as3
{
import flash.display.Sprite;
import flash.events.*;
import flash.net.FileReference;
import flash.net.URLRequest;
public class FileUpload extends Sprite {
private var uploadURL:URLRequest;
private var file:FileReference;
public function FileUpload() {
uploadURL = new URLRequest();
uploadURL.url = "http://www.mywebsite.com/upload.php";
file = new FileReference();
file.addEventListener(Event.SELECT, selectHandler);
file.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
file.addEventListener(ProgressEvent.PROGRESS, progressHandler);
file.addEventListener(Event.COMPLETE, completeHandler);
}
public function FileBrowse():void
{
file.browse();
}
private function selectHandler(event:Event):void {
var file:FileReference = FileReference(event.target);
file.upload(uploadURL);
}
private function ioErrorHandler(event:IOErrorEvent):void {
trace("ioErrorHandler: " + event);
}
private function progressHandler(event:ProgressEvent):void {
var file:FileReference = FileReference(event.target);
trace("progressHandler: name=" + file.name + " bytesLoaded=" + event.bytesLoaded + " bytesTotal=" + event.bytesTotal);
}
private function completeHandler(event:Event):void {
trace("completeHandler: " + event);
}
}
}
^^ How can I fire an event in my main application using one of those event handlers?
For example.. I'm trying to change the currentState of my appliction using the selectHandler above.
in my main application all I have to do is call "this.currentState="state"; and it works... but I don't know how to do this from within my class file.
Thank you.