Created
October 21, 2011 01:33
-
-
Save itoz/1302888 to your computer and use it in GitHub Desktop.
[AIR] ディレクトリ内ファイル一覧を取得
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
*============================================================ | |
* copyright(c) 2011 | |
* @author itoz | |
* 2011/10/21 | |
*============================================================ | |
*/ | |
package | |
{ | |
import qnx.ui.buttons.LabelButton; | |
import qnx.ui.core.Container; | |
import qnx.ui.core.ContainerAlign; | |
import qnx.ui.core.ContainerFlow; | |
import qnx.ui.core.SizeMode; | |
import qnx.ui.core.SizeUnit; | |
import flash.display.StageAlign; | |
import flash.display.StageScaleMode; | |
import flash.events.Event; | |
import flash.events.MouseEvent; | |
import flash.filesystem.File; | |
import flash.text.TextField; | |
import flash.text.TextFieldAutoSize; | |
/** | |
* AIR ディレクトリ内ファイル一覧を取得 | |
* ※[要]qnxコンポーネント | |
*/ | |
public class GetListInDirectory extends Container | |
{ | |
private var _btn : LabelButton; | |
private var _browsFile : File; | |
private var _pathTf : TextField; | |
public function GetListInDirectory() | |
{ | |
stage.scaleMode = StageScaleMode.NO_SCALE; | |
stage.align = StageAlign.TOP_LEFT; | |
flow = ContainerFlow.VERTICAL; | |
align = ContainerAlign.NEAR; | |
sizeMode = SizeMode.BOTH; | |
sizeUnit = SizeUnit.PIXELS; | |
_btn = new LabelButton(); | |
_btn.label = "select directory"; | |
_btn.addEventListener(MouseEvent.CLICK, onOpenDialog); | |
addChild(btn); | |
_pathTf = addChild(new TextField()) as TextField; | |
_pathTf.autoSize = TextFieldAutoSize.LEFT; | |
_pathTf.text = ""; | |
stage.addEventListener(Event.RESIZE, onResize); | |
onResize(null) | |
} | |
private function onResize(e : Event) : void | |
{ | |
setSize(stage.stageWidth, stage.stageHeight); | |
} | |
private function onOpenDialog(event : MouseEvent) : void | |
{ | |
_browsFile = new File(); | |
_browsFile.addEventListener(Event.SELECT, onSaveDirecotrySelected); | |
_browsFile.browseForDirectory("select directory"); | |
} | |
private function onSaveDirecotrySelected(event : Event) : void | |
{ | |
_pathTf.text = _browsFile.nativePath; | |
onResize(null); | |
// | |
getFileList(_browsFile); | |
} | |
private function getFileList(browsFile : File) : void | |
{ | |
var arr : Array = _browsFile.getDirectoryListing(); | |
for (var i : int = 0; i < arr.length; i++) { | |
var obj : Object = (arr[i]) | |
trace(arr[i].name) | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment