SaqooshaビンタHIGE びんたはbeinteractiveじゃないよ!
/**
* Copyright ll_koba_ll ( http://wonderfl.net/user/ll_koba_ll )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/t86H
*/
package
{
import flash.display.Sprite;
import flash.events.Event;
import flash.system.Security;
import org.libspark.thread.Thread;
import org.libspark.thread.EnterFrameThreadExecutor;
[SWF(frameRate=30, width=500, height=500, backgroundColor="#000000")]
public class Slideshow extends Sprite {
public function Slideshow() {
Thread.initialize(new EnterFrameThreadExecutor());
addEventListener(Event.ADDED_TO_STAGE, init);
}
private function init(e:Event):void {
stage.scaleMode = "noScale";
stage.align = "LT";
var context:Context = new Context();
context.root = this;
context.photoList = [];
context.stage = stage;
new MainThread(context).start();
}
}
}
import flash.display.DisplayObjectContainer;
import flash.display.DisplayObject;
import flash.display.Stage;
import flash.display.Bitmap;
import flash.net.URLRequest;
import flash.net.URLVariables;
import flash.net.URLLoader;
import org.libspark.thread.Thread;
import org.libspark.thread.threads.net.URLLoaderThread;
import org.libspark.thread.utils.SerialExecutor;
import org.libspark.thread.utils.ParallelExecutor;
import org.libspark.thread.threads.display.LoaderThread;
//import org.libspark.thread.threads.utils.FunctionThread;
//import org.libspark.thread.threads.utils.WaitThread;
import org.libspark.thread.threads.tweener.TweenerThread;
import com.adobe.serialization.json.JSON;
import flash.system.Security;
class Context {
public var photoList:Array;
public var root:DisplayObjectContainer;
public var stage:Stage;
}
class MainThread extends Thread {
private var _context:Context;
public function MainThread(context:Context) {
_context = context;
}
protected override function run():void {
var se:SerialExecutor = new SerialExecutor();
se.addThread(new LoadPhotoThread(_context));
se.addThread(new SlideshowThread(_context));
se.start();
}
}
class LoadPhotoThread extends Thread {
private var _context:Context;
private var _urlLoaderThread:URLLoaderThread;
private var _imageLoaders:ParallelExecutor;
public function LoadPhotoThread(context:Context) {
_context = context;
}
protected override function run():void {
Security.loadPolicyFile("http://lh3.ggpht.com/crossdomain.xml");
Security.loadPolicyFile("http://lh4.ggpht.com/crossdomain.xml");
Security.loadPolicyFile("http://lh5.ggpht.com/crossdomain.xml");
Security.loadPolicyFile("http://lh6.ggpht.com/crossdomain.xml");
var imgList:Array = [];
imgList.push("http://lh3.ggpht.com/_bg6-xQF6fY4/SuW84uNnA5I/AAAAAAAAEUM/kMPlz6QTRdA/s720/IMG_7696.JPG");
imgList.push("http://lh5.ggpht.com/_bg6-xQF6fY4/SuW85GZLFLI/AAAAAAAAEUU/ubxs__iov7E/s720/IMG_7697.JPG");
imgList.push("http://lh3.ggpht.com/_bg6-xQF6fY4/SuW85HL1TAI/AAAAAAAAEUY/W5qe1f53pAE/s720/IMG_7698.JPG");
imgList.push("http://lh6.ggpht.com/_bg6-xQF6fY4/SuW85YJbOLI/AAAAAAAAEUc/zhoeVgbZ0m4/s720/IMG_7699.JPG");
imgList.push("http://lh5.ggpht.com/_bg6-xQF6fY4/SuW85jpZrSI/AAAAAAAAEUg/Efcz-aZx9R0/s720/IMG_7700.JPG");
imgList.push("http://lh3.ggpht.com/_bg6-xQF6fY4/SuW85x-ux9I/AAAAAAAAEUk/v_phqH4GRcA/s720/IMG_7701.JPG");
imgList.push("http://lh6.ggpht.com/_bg6-xQF6fY4/SuW86KQghlI/AAAAAAAAEUo/AOwrhI4eLLY/s720/IMG_7702.JPG");
imgList.push("http://lh6.ggpht.com/_bg6-xQF6fY4/SuW86LMcvBI/AAAAAAAAEUs/5puU32JxOXk/s720/IMG_7703.JPG");
imgList.push("http://lh5.ggpht.com/_bg6-xQF6fY4/SuW86bLuboI/AAAAAAAAEUw/WvVqG1GuFQE/s720/IMG_7705.JPG");
imgList.push("http://lh6.ggpht.com/_bg6-xQF6fY4/SuW86qiKr1I/AAAAAAAAEU0/4IzR4CV1VSs/s720/IMG_7706.JPG");
imgList.push("http://lh4.ggpht.com/_bg6-xQF6fY4/SuW86vB8o_I/AAAAAAAAEU4/mMH53kLlCUI/s720/IMG_7707.JPG");
imgList.push("http://lh3.ggpht.com/_bg6-xQF6fY4/SuW869myhpI/AAAAAAAAEU8/r-fMG7SIPkA/s720/IMG_7708.JPG");
imgList.push("http://lh3.ggpht.com/_bg6-xQF6fY4/SuW87NB5yQI/AAAAAAAAEVA/7U458teqqHg/s720/IMG_7709.JPG");
imgList.push("http://lh3.ggpht.com/_bg6-xQF6fY4/SuW87Pdl4GI/AAAAAAAAEVE/arK1tZFAoJE/s720/IMG_7710.JPG");
imgList.push("http://lh4.ggpht.com/_bg6-xQF6fY4/SuW87W3dbXI/AAAAAAAAEVI/csXjN3VNAa8/s720/IMG_7711.JPG");
_imageLoaders = new ParallelExecutor();
for each(var url:String in imgList) {
_imageLoaders.addThread(new LoaderThread(new URLRequest(url)));
}
_imageLoaders.start();
_imageLoaders.join();
next(imageLoadCompete);
}
private function imageLoadCompete():void {
for (var i:int = 0; i < _imageLoaders.numThreads; i++) {
var l:LoaderThread = LoaderThread(_imageLoaders.getThreadAt(i));
Bitmap(l.loader.content).smoothing = true;
_context.photoList.push(l.loader);
}
}
}
class SlideshowThread extends Thread {
private var _context:Context;
private var _currentPhotoIndex:int = 0;
private var _prevPhoto:DisplayObject;
public function SlideshowThread(context:Context) {
_context = context;
}
protected override function run():void {
nextPhoto();
}
private function nextPhoto():void {
if (_prevPhoto != null)
{
_prevPhoto.scaleX = _prevPhoto.scaleY = 1;
_context.root.removeChild(_prevPhoto);
}
var p:DisplayObject = _context.photoList[_currentPhotoIndex]
_prevPhoto = p;
_context.root.addChild(p);
var scale:Number;
if (p.width > p.height) {
scale = _context.stage.stageWidth/p.width;
} else {
scale = _context.stage.stageHeight/p.height;
}
p.scaleX = scale;
p.scaleY = scale;
p.y = _context.stage.stageHeight/2 - p.height/2;
p.x = _context.stage.stageWidth/2 - p.width/2;
_currentPhotoIndex++;
if (_currentPhotoIndex > _context.photoList.length - 1) _currentPhotoIndex = 0;
wait(50);
next(nextPhoto);
}
}