2011-03-12 1 views
0

나는 HTML 상자가 있으며 프로젝트에서 로컬 HTML 파일을로드합니다. 이 HTML 파일에서 jquery를 사용하고 사용자 디렉토리에서 이미지를로드하려고합니다. 내 사용자 디렉토리에서 이미지를 볼 수 있지만 jquery가 작동하지 않습니다. 는이 오류 얻을 :로컬 HTML 파일 (응용 프로그램 작업 영역)에서 로컬 이미지 (응용 프로그램 작업 공간이 아닌)에 액세스하는 데 문제가 있습니다.

TypeError: Error #1009: Cannot access a property or method of a null object reference. 
    at crop/onLoaded()[/Flex Bundle/workspace/crop/src/crop.mxml:119] 
    at flash.events::EventDispatcher/dispatchEventFunction() 
    at flash.events::EventDispatcher/dispatchEvent() 
    at flash.html::HTMLLoader/onCompleteTimer() 
    at flash.utils::Timer/_timerDispatch() 
    at flash.utils::Timer/tick() 

을하지만 응용 프로그램 작업 영역에서 이미지를로드하는 경우, 모든 (I 이미지를 볼 JQuery와 작동) 잘 작동합니다.

정책상의 문제입니까? 오류는 "null 객체 참조"문제라고 말하지만 사실 일 수는 없습니다 ...

아이디어가 있으십니까? 다른 디렉토리에 이미지를 넣을 경우

데미안

답변

0

자체 정의 된 디렉토리에 응용 프로그램 디렉토리에서 파일을 복사하는 내 솔루션 :

바르 :

private var fileName:String = 'config.xml'; 
private var workingDirectory:String = 'MyNewAppDir'; 
  1. 짧고 간단 :
var f:File = File.applicationDirectory.resolvePath(this.fileName); 
f.copyTo(File.documentsDirectory.resolvePath(this.workingDirectory+"/"+this.fileName)); 

또는 2 길고 복잡한 :

/** 
* read content 
*/ 
var file:File = File.applicationDirectory.resolvePath(this.fileName); 
var read:FileStream = new FileStream(); 
read.open(file, FileMode.READ); 
var content:String = read.readMultiByte(read.bytesAvailable, "utf-8") ; 
read.close(); 

/** 
* save content 
*/ 
var write:FileStream = new FileStream(); 
write.open(File.documentsDirectory.resolvePath(this.workingDirectory + "/" + this.fileName), FileMode.WRITE); 
write.writeMultiByte(content, "utf-8"); 
write.close(); 
0

합니까 전혀 도움이 무엇입니까? 파일이 어디 있는지 디렉토리에 따라 권한 문제가있을 수

var original = air.File.documentsDirectory.resolvePath("myairapp/test.jpg"); 

:

당신은 나/홈/사용자/문서/myairapp 다음 그것을 열고 내 문서/myairapp에서 이미지 파일을 넣을 수 ?

+0

그래도 작동하지 않습니다. documentsDirectory에서 html 파일과 이미지를 엽니 다. 새로운 이미지를 같은 디렉토리에 저장합니다. 이것은 권한 문제없이 작동합니다. – Damian

관련 문제