我目前有一个工作线程成功加载外部swf文件。但是如何在加载的swf文件中调用函数?
这是位于外部swf文件中的类。
package
{
import flash.display.Bitmap;
import flash.display.Sprite;
import flash.utils.ByteArray;
public class BackgroundProcesses extends Sprite {
public function BackgroundProcesses()
{
super();
}
public function EncryptTheImage(_imageToEncrypte:Bitmap):ByteArray
{
// Encrypted the image here
var _imageInEncryptedBytes:ByteArray = new ByteArray();
return _imageInEncryptedBytes;
}
}
}
这是我的Flex Mobile mxml文件:
import mx.events.FlexEvent;
protected function LoadWorkerSwfFile(event:FlexEvent):void
{
var workerLoader:URLLoader = new URLLoader();
workerLoader.dataFormat = URLLoaderDataFormat.BINARY;
workerLoader.addEventListener(Event.COMPLETE, loadComplete);
workerLoader.load(new URLRequest("BackgroundProcesses.swf"));
}
private function loadComplete(event:Event):void
{
var workerBytes:ByteArray = event.target.data as ByteArray;
var bgWorker:Worker = WorkerDomain.current.createWorker(workerBytes);
bgWorker.addEventListener(Event.WORKER_STATE, WorkerIsRunning);
bgWorker.start();
}
private function WorkerIsRunning(event:flash.events.Event):void
{
}
感谢任何帮助!
答案 0 :(得分:2)
其他人可以纠正我,但我不认为你可以直接访问另一个工人的财产和方法,我认为你也不能设计出来。相反,您应该在它们之间来回传递消息和数据以进行通信并发送/获取工作结果。
这可能有所帮助:Communicating between workers