open file automatically
_global.getName = function() {
var spot = _root._url.split("/");
Name = spot[spot.length-1];
dotR = Name.indexOf(".");
R = Name.slice(0, dotR);
return R;
};
_global.getPath = function() {
var spot = _root._url.split("/");
spot.pop();
P = spot.join("/")+"/";
return P;
};
getName()은 현재 실행되는 swf파일의 확장자를 제외한 파일명을 반환한다. getPath는 현재 실행되는 파일이 위치한 url을 반환한다. 단 여기서 현재 실행되는 파일의 이름은 제거한다.
예를 들어 http://domain.com/path/ex.swf 파일에서 위의 두 함수를 실행하면 getPath()의 경우 문자열 http://domain.com/path/를 반환하며, getName()은 ex라는 파일이름 두 글자를 문자열 형태로 반환한다.
tray = new LoadVars();
tray.onLoad = function(done) {
if (done) {
_root.pass = true;
_root.sbj = String(_root.tray.sbj);
nextScene();
} else {
_root.pass = false;
}
};
tray.load(getPath()+getName()+".minfo");
따라서, tray.load(getPath()+ getName()+”.minfo”); 라는 구문을 이용해 어떠한 위치에 swf파일이 위치하던지 동일한 디렉토리에 있는 데이터 파일, filename.minfo을 불러오는 것이 가능하다.
위의 두 함수와 Flash MX 2004에 내장된 Media Component를 이용하면 간단한 재생기를 만들 수 있다. 이 재생기는 한 번만 name.swf로 컴파일 하면 name.swf의 파일명과 동일한 name.flv를 로딩하여 재생하며, name.minfo라는 텍스트 파일을 동시에 로딩하여 name.swf의 메인타임라인에 동영상 제목을 동적으로 출력하는 것이 가능하다.
예는 Bert라는 애니메이션을 소개한 엔트리에서 확인 가능하다.
About this entry
You’re currently reading “open file automatically,” an entry on multiplicité
- Published:
- Wednesday, September 15th, 2004 at 3:06 am
- This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 2.0 Korea.
- Author:
- vizualizer
- Category:
- techne
No comments
Jump to comment form | comments rss