In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

Dead Code Preservation :: Archived AS3 works from wonderfl.net

ぷち写真館

Get Adobe Flash player
by simultechnology 11 May 2010
    Embed
/**
 * Copyright simultechnology ( http://wonderfl.net/user/simultechnology )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/fFCK
 */

package
{
	import caurina.transitions.Tweener;
	
	import flash.display.Loader;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.events.TimerEvent;
	import flash.net.URLRequest;
	import flash.text.TextField;
	import flash.text.TextFormat;
	import flash.utils.Timer;
	
	import org.osmf.events.TimeEvent;
	
	[SWF(backgroundColor="0x000000")]
	public class Slide extends Sprite
	{		
		
		private var _loaderArray:Array = [];
		// 大きな画像が表示されているかどうか判断するフラグ
		private var _firstBigImage:Boolean = true;
		
		public function Slide()
		{
			
			var fileArray :Array = [
				"http://assets.wonderfl.net/images/related_images/e/e8/e80c/e80cb8272f7ca51955730f198dcd46bf72682eea",
				"http://assets.wonderfl.net/images/related_images/9/95/954f/954feb955326b6ab74c760d625a9cb20dd0b1db5",
				"http://assets.wonderfl.net/images/related_images/1/1b/1bcd/1bcdd1d7dc210c6cc05347729c162ce5fee5c587",
				"http://assets.wonderfl.net/images/related_images/1/15/1570/1570ca63ab3a18a888b62ae25364fbfed9d50773",
				"http://assets.wonderfl.net/images/related_images/1/15/15a8/15a8943d8da6fdbf2226448afa3316a07598bad9",
				"http://assets.wonderfl.net/images/related_images/7/78/78f9/78f9fb3188b9a8b2f25883578484c8de25b89b81",
				"http://assets.wonderfl.net/images/related_images/b/b0/b0da/b0da3c3a13a947110761a320204df79298b85971",
				"http://assets.wonderfl.net/images/related_images/7/70/70a0/70a04111f14b07855a96ef9acef998d64df0fb78",
				"http://assets.wonderfl.net/images/related_images/a/a6/a692/a692d615563f57d4df9e141706ead47f4c171552",
				"http://assets.wonderfl.net/images/related_images/9/90/9074/9074ba908dd758a5c8f50bc003fdcbc91b91a6f5",
				"http://assets.wonderfl.net/images/related_images/2/20/208d/208d155849b660677c4bdc4fa9b05a39c86929a8",
				"http://assets.wonderfl.net/images/related_images/2/27/2765/2765127fce9d98461580367b776effb6ece4a433",
				"http://assets.wonderfl.net/images/related_images/3/32/328d/328d86afc9eca9fe67e34e7a4a448133109a64e7",
				"http://assets.wonderfl.net/images/related_images/7/70/704e/704ec56b47464afb3fb57f7311b5a3bf15e941d8",
				"http://assets.wonderfl.net/images/related_images/c/c6/c620/c620fd8f701fba4d8afe8f8ed625df24fd4f452f",
				"http://assets.wonderfl.net/images/related_images/a/aa/aac2/aac2ecfa9549e38aaf43ad05a66b053fc8b5521b",
				"http://assets.wonderfl.net/images/related_images/4/4b/4b86/4b8697dee39fcf3028511ca43b68698f935e92a0",
				"http://assets.wonderfl.net/images/related_images/2/25/25ec/25ec137d49138e33f435b6b132c534342c8d9c0c",
				"http://assets.wonderfl.net/images/related_images/6/6f/6f6e/6f6ebf940e2d9fa831b630dd51d47232cca9c6cd",
				"http://assets.wonderfl.net/images/related_images/6/67/67f5/67f58563be342f1eca940b075eb4e4700715c6fa"
			];
			
			// 画像のwidthは1024
			var imageScale:Number = 465 / 10 / 1024;
			
			var n:int = fileArray.length;
			var sp:Image;
			for (var i:int = 0; i < n; i++) {
				if (i < 10) {
					// 画像1枚目~10枚目は下に表示
					sp = new Image(fileArray[i], i * 1024 * imageScale, 400, imageScale, imageScale, 0.4);
				}
				else {
					// 画像11枚目~20枚目は下に表示
					sp = new Image(fileArray[i], (i - 10) * 1024 * imageScale, 35, imageScale, imageScale, 0.4);
				}
				addChild(addAlphaListener(sp, 0.4));
				sp.addEventListener(MouseEvent.MOUSE_OVER, showBigImage);
			}
			
			// 文字列フォーマットの指定
			var tm:TextFormat = new TextFormat();
			tm.color = 0xFFFFFF;
			tm.size = 10;
			// 文字列の作成
			var tf:TextField = new TextField();
			tf.defaultTextFormat = tm;
			tf.alpha = 0.7;
			tf.width = 300;
			tf.text = "マウスが画像に触れると拡大表示されます";
			tf.x = 0;
			tf.y = 90;
			this.stage.addChildAt(tf, 0);
		}
		
		private function showBigImage(e:MouseEvent):void {
			
			if (!_firstBigImage) {
				// 大きな画像が表示されている時は消す
				this.removeChildAt(numChildren - 1);
			}
			var bigImage:Image = new Image(e.target.getUrl(), 0, 0, 0.3, 0.3, 1.0);
			bigImage.x = -400;
			bigImage.y = 70;
			this.addChild(bigImage);
			_firstBigImage = false; 
			Tweener.addTween(bigImage, { x:100, y:120, time:3, transition:"easeOutQuart" });
			// 3秒後にタイマー開始
			var timer:Timer = new Timer(3000, 1);
			timer.addEventListener(TimerEvent.TIMER, function(e:TimerEvent):void {
				bigImage.addEventListener(Event.ENTER_FRAME, function(e:Event):void {
					bigImage.alpha -= 0.05;
				});
			});
			timer.start();
		}
		
		private function addAlphaListener(sp:Sprite, alpha:Number):Sprite {
			sp.addEventListener(MouseEvent.MOUSE_OVER, function(e:MouseEvent):void {
				sp.alpha = 1.0;
			});
			sp.addEventListener(MouseEvent.MOUSE_OUT, function(e:MouseEvent):void {
				sp.alpha = alpha;
			});
			return sp;
		}
	}
}

import flash.display.Bitmap;
import flash.display.Loader;
import flash.display.Sprite;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.net.URLRequest;
import flash.system.LoaderContext;

class Image extends Sprite
{
	private var _url:String;
	
	public function Image(url:String, x:int, y:int, scaleX:Number, scaleY:Number, alpha:Number)
	{
		this._url = url;
		this.x = x;
		this.y = y;
		this.scaleX = scaleX;
		this.scaleY = scaleY;
		this.alpha = alpha;
		var loader:Loader = new Loader();
		var uRLRequest:URLRequest = new URLRequest(url);
		// ポリシーファイルチェックをtrue
		loader.load(uRLRequest, new LoaderContext(true));
		loader.contentLoaderInfo.addEventListener(Event.COMPLETE, completeListener);
	}
	
	private function completeListener(e:Event):void
	{
		var bm:Bitmap = new Bitmap(e.target.content.bitmapData.clone());
		addChild(bm);
	}
	
	// urlを返すgetter
	public function getUrl():String
	{
		return this._url;
	}
}