現在、URL から画像を読み込むことができますが、ハード ドライブ内のファイルから画像を読み込むためのスクリプトは何ですか?
ti.border = true
ti.addEventListener(TextEvent.TEXT_INPUT, onInput);
function onInput(event:TextEvent):void
{
if(ti.text.search('a')!=-1) load_image("http://i54.tinypic.com/anom5d.png", "ottefct");
else if(ti.text.search('b')!=-1) load_image("http://i53.tinypic.com/2dv7dao.png", "rnd");
else if(ti.text.search('c')!=-1) load_image("http://i51.tinypic.com/m8jp7m.png", "ssd");
}
var loaded_images:Dictionary = new Dictionary();
function load_image(url:String, id_name:String)
{
var loader:Loader = new Loader();
loader.name = id_name;
var url_req:URLRequest = new URLRequest(url);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoadingComplete);
loader.load(url_req);
}
function onLoadingComplete(evt:Event):void
{
var img_name:String = evt.currentTarget.loader.name
var spr_box:Sprite = new Sprite();
spr_box.addChild(evt.currentTarget.loader);
spr_box.mouseChildren = false;
spr_box.doubleClickEnabled = true;
spr_box.addEventListener(MouseEvent.MOUSE_DOWN, drag);
spr_box.addEventListener(MouseEvent.MOUSE_UP, drop);
spr_box.addEventListener(MouseEvent.MOUSE_WHEEL, rotate);
spr_box.addEventListener(MouseEvent.DOUBLE_CLICK , unrotate);
//Shouldn't really hard code this here
spr_box.width = 124;
spr_box.height = 180;
spr_box.x = 430;
spr_box.y = 425;
// - Since this isn't a class, I'd do this instead:
//spr_box.addEventListener(Event.ADDED_TO_STAGE, resize_img);
this.addChild(spr_box);
loaded_images[img_name] = spr_box;
}
//Because this event function lets you control individual image dimensions
/*
function resize_img(evt:Event):void
{
switch (evt.currentTarget.name)
{
case "ImageOne":
evt.currentTarget.width = 250;
evt.currentTarget.height = 250;
break;
default:
evt.currentTarget.width = 180;
evt.currentTarget.height = 124;
break;
}
}
*/
function drag(evt:MouseEvent):void
{
evt.currentTarget.startDrag()
}
function drop(evt:MouseEvent):void
{
evt.currentTarget.stopDrag()
}
function rotate(evt:MouseEvent):void
{
evt.currentTarget.rotation = 90
}
function unrotate(evt:MouseEvent):void
{
evt.currentTarget.rotation = 0
}