flash on 2010-11-9
http://www40.atwiki.jp/spellbound/pages/310.html
/**
* Copyright aruerula ( http://wonderfl.net/user/aruerula )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/7ouU
*/
package
{
//http://www40.atwiki.jp/spellbound/pages/310.html
import flash.display.Loader;
import flash.display.Sprite;
import flash.events.Event;
import flash.net.URLRequest;
import flash.system.LoaderContext;
import flash.system.Security;
public class Main extends Sprite
{
private var count:int = 0; // 読み込んだ画像数
private var images:Array; // 読み込んだ画像
private const IMAGE_URL:Array =
[
"http://farm3.static.flickr.com/2205/2532926223_6b2745185b.jpg",
"http://farm4.static.flickr.com/3372/3212206475_ec333b5c51.jpg",
"http://farm1.static.flickr.com/24/53973269_1947656f3b.jpg"
];
public function Main()
{
images = new Array(IMAGE_URL.length);
// crossdomain.xmlを読み込む
Security.loadPolicyFile("http://farm3.static.flickr.com/crossdomain.xml");
for (var i:int = 0; i < IMAGE_URL.length; i++)
{
var loader:Loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.INIT, initHandler);
loader.load(new URLRequest(IMAGE_URL[i]), new LoaderContext(true));
loader.name = i.toString();
}
}
private function initHandler(event:Event):void
{
images[event.currentTarget.loader.name] = event.currentTarget.loader;
if (++count == IMAGE_URL.length) completeHandler();
}
private function completeHandler():void
{
for (var i:int = 0; i < images.length; i++)
{
images[i].x = 465 / images.length * i;
addChild(images[i]);
}
}
}
}