我有一个非常简单的代码片段;
loadingMc.visible = true;
trace("ok");
// send photo to server
loadingMc.visible = false;
发送照片需要 3-5 秒,但影片剪辑仅在过程的最后一秒可见。我可以在流程开始时在输出中看到“ok”消息。所以我认为问题不是重绘影片剪辑。是否有任何选项可以在流程开始之前强制重绘?
更新:发送到服务器部分;
upload.addEventListener(MouseEvent.CLICK, function(evt:MouseEvent):void{
loadingText.visible = true;
trace("ok");
var bmd:BitmapData = new BitmapData(1024,768,true,0);
bmd.draw(imageArea);
savePicToServer(bmd);
});
function savePicToServer(bmd:BitmapData):void
{
var jpgEncoder:JPGEncoder = new JPGEncoder(85);
var jpgStream:ByteArray = jpgEncoder.encode(bmd);
var loader:URLLoader = new URLLoader();
configureListeners(loader);
var header:URLRequestHeader = new URLRequestHeader("Content-type", "application/octet-stream");
var request:URLRequest = new URLRequest("http://localhost/test/upload.php?key=prvkey");
request.requestHeaders.push(header);
request.method = URLRequestMethod.POST;
request.data = jpgStream;
loader.load(request);
}
在 COMPLETE 事件中;
loadingText.visible = false;