無法獲取我的文件大小!我有一個變量加載文件,然後在我的fileCompleteLoad事件我想檢查該文件(.png)的大小。通過文件變量類型從加載的文件獲取大小ActionScript3
// clickButton event to load the file
public function onMouseClick(e:MouseEvent):void{
_fileRef = new File();
_fileRef.addEventListener(Event.SELECT, onFileSelected, false, 0, true);
_fileRef.addEventListener(Event.CANCEL, onCancel, false, 0, true);
_fileRef.addEventListener(IOErrorEvent.IO_ERROR, onIOError, false, 0, true);
_fileRef.addEventListener(SecurityErrorEvent.SECURITY_ERROR,
onSecurityError, false, 0, true);
_fileRef.browse([_imageFilter]);
}
// selected event
public function onFileSelected(evt:Event):void
{
_fileRef.addEventListener(ProgressEvent.PROGRESS, onProgress, false, 0, true);
_fileRef.addEventListener(Event.COMPLETE, onComplete, false, 0, true);
_fileRef.load();
}
// thats my eventComplete
public function onComplete(evt:Event):void
{
_msgSuccessErrorTextField.text = "File was successfully loaded.";
_pngInputTextField.text = String(_fileRef.nativePath);
_atfOutputTextField.text = _fileRef.nativePath.replace(".png",".atf");
_inputNativeProcess = _fileRef.nativePath;
_outputNativeProcess = _atfOutputTextField.text;
_flagLoadedFile = new Boolean(true);
var test:Bitmap = evt.target.data as Bitmap;
if(test){
trace(test.height);
}
_fileRef.removeEventListener(Event.SELECT, onFileSelected);
_fileRef.removeEventListener(ProgressEvent.PROGRESS, onProgress);
_fileRef.removeEventListener(Event.COMPLETE, onComplete);
_fileRef.removeEventListener(Event.CANCEL, onCancel);
現在,在這種情況下我想檢查我的文件大小......我試過很多東西,但沒有得到成功......有時我得到空從我_fileRef.data。
任何建議來解決這個問題?
THX
我做了你說的,但仍然沒有工作......它說我的測試:位圖正在接收NULL,而不是實際上文件。我用我的活動編輯我的問題。看看 – RafaelFelisbino 2013-03-14 15:32:38
「e.target」和「e.target.data」的類型是什麼? e.target.data'是否也是NULL? – 2013-03-14 15:38:55
'_browsePngTextFiledButton.addEventListener(MouseEvent.MOUSE_DOWN,onMouseClick,false,0,true);' – RafaelFelisbino 2013-03-14 15:42:59