hjkhghopjkertteerterterterertertrtoirh
bnmbertsurhetertertertertertertertpdf'tdfg
/
srv
/
www
/
virtual
/
wccweb.jp
/
web
/
htdocs
/
wphh
/
2009
/
fm
/
display
/
Upload FileeE
HOME
/*======================================================================*//** * * 3PCPG * * @author Copyright (c) 2008 muraken[undefined™(http://www.undefined.nu)] * @version 1.0.0 * *//*=======================================================================*/ package display{ import caurina.transitions.Tweener; import flash.display.Bitmap; import flash.display.BitmapData; import flash.display.BitmapDataChannel; import flash.display.BlendMode; import flash.display.Sprite; import flash.events.Event; import flash.events.TimerEvent; import flash.geom.Point; import flash.geom.Rectangle; import flash.net.URLRequest; import flash.utils.Timer; import events.ViewEvent; import events.FooterEvent; import display.Footer; import util.StaticFunctions; import flash.display.Loader; import flash.display.LoaderInfo; public class View extends Sprite{ private var bitmap1:Bitmap; private var bitmap2:Bitmap; private var bitmap3:Bitmap; private var nextPhoto:int = 0; private var dataArray:Array; private var activeArray:Array = new Array(); private var flgSlideShow:Boolean = true; private var flgResize:Boolean = false; private var timer:Timer; private var loader:Loader = new Loader(); private var info : LoaderInfo; private var nextBmd:BitmapData; public function View(_array:Array) { //BitmapDataの入った配列を保存しておきます。 dataArray = _array; info = loader.contentLoaderInfo; //最初はタグ"ALL"なので、アクティブな画像を入れる用の配列activeArrayに全部のidを入れておきます。 for (var i:int = 0; i < _array.length; i++) activeArray.push(i); //タイマーを作ります。 timer = new Timer(4000, 0); //Rチャンネル用の表示オブジェクトです。 bitmap1 = new Bitmap(); //Gチャンネル用の表示オブジェクトです。 bitmap2 = new Bitmap(); //Bチャンネル用の表示オブジェクトです。 bitmap3 = new Bitmap(); //blendModeをBlendMode.SCREENに設定します。 bitmap1.blendMode = bitmap2.blendMode = bitmap3.blendMode = BlendMode.SCREEN; addChild(bitmap1); addChild(bitmap2); addChild(bitmap3); } public function setPhoto(n:int):void { setSlide(false); for (var i:int = 0; i < activeArray.length; i++) { if (activeArray[i] == n) { nextPhoto = i; break; } } loadPhoto(); } public function setListener():void{ Main.footer.addEventListener(FooterEvent.SELECT_THUMB, function(e:FooterEvent) { setPhoto(e.data as int);}); Main.footer.addEventListener(FooterEvent.SELECT_RGB, function(e:FooterEvent) { setRGB(e.data as Array); } ); Main.footer.addEventListener(FooterEvent.IS_SLIDESHOW, function(e:FooterEvent) { setSlide (e.data as Boolean); } ); Main.footer.addEventListener(FooterEvent.SELECT_TAGS, function(e:FooterEvent) { setTags (e.data as Array); } ); Main._stage.addEventListener(Event.RESIZE, _resize); } public function setRGB(_array:Array):void { //フッタのおまけの右側にあるRGBのボタンが押された時にvisibleを調整します。 bitmap1.visible = _array[0]; bitmap2.visible = _array[1]; bitmap3.visible = _array[2]; } public function setTags(_array:Array):void { //タグが指定された時に、idの入った配列が渡されます。 activeArray = _array; nextPhoto = 0; if (flgSlideShow)timer.delay = 4000; hide(); } public function setSlide(f:Boolean):void { //自動再生をするかしないかが引数です。 flgSlideShow = f; if (f) { //自動再生をする場合タイマーをstartさせます。 timer.delay = 4000; timer.addEventListener(TimerEvent.TIMER, timerFunc ); timer.start(); hide(); }else { //自動再生をしない場合タイマーをstopさせます。 timer.removeEventListener(TimerEvent.TIMER, timerFunc ); timer.stop(); } } //タイマーから呼び出される関数 private function timerFunc(e:TimerEvent):void { //リサイズされた時にタイマーの時間をいじりますので、その場合ここで初期化します。 if (flgResize) { timer.delay = 4000; flgResize = false; } hide(); } private function loadPhoto():void { //timerを一回とめます。 timer.stop(); //大きな画像を読み込みます。読み込みが完了したらLoaderInfoInitFuncが実行されます。 var url:URLRequest = new URLRequest(dataArray[activeArray[nextPhoto]]); info.addEventListener(Event.INIT, LoaderInfoInitFunc); loader.load(url); } private function LoaderInfoInitFunc(e:Event):void { info.removeEventListener(Event.INIT, LoaderInfoInitFunc); //読み込まれた画像をBitmapDataに変更して次に表示されるnextBmdにdrawします。 nextBmd = new BitmapData(loader.width,loader.height,false); nextBmd.draw(loader, null, null, null, null, true); //timerを再起動して、画像を表示します。 timer.start(); show(); } private function show():void { var _bmd:BitmapData = nextBmd.clone(); var _obj:Object = StaticFunctions.resizeOver(_bmd.width, _bmd.height, Main._stage.stageWidth, Main._stage.stageHeight, true); var pt:Point = new Point(0, 0); var rect:Rectangle = new Rectangle(0, 0, _bmd.width, _bmd.height); var blackBmd:BitmapData = new BitmapData(_bmd.width, _bmd.height, false, 0x000000); //RGBチャンネルそれぞれに画像を色分解します。 var r_bmd:BitmapData = blackBmd.clone(); var g_bmd:BitmapData = blackBmd.clone(); var b_bmd:BitmapData = blackBmd.clone(); r_bmd.copyChannel(_bmd, rect, pt, BitmapDataChannel.RED, BitmapDataChannel.RED); g_bmd.copyChannel(_bmd, rect, pt, BitmapDataChannel.GREEN, BitmapDataChannel.GREEN); b_bmd.copyChannel(_bmd, rect, pt, BitmapDataChannel.BLUE, BitmapDataChannel.BLUE); bitmap1.bitmapData = r_bmd; bitmap2.bitmapData = g_bmd; bitmap3.bitmapData = b_bmd; bitmap1.width = bitmap2.width = bitmap3.width = _obj.width; bitmap1.height = bitmap2.height = bitmap3.height = _obj.height; //センタリングした位置に向かうように、画像の行き先を計算します。 var fixX:Number = -(_obj.width - Main._stage.stageWidth) / 2; var fixY:Number = -(_obj.height - Main._stage.stageHeight) / 2; bitmap1.x = fixX; bitmap1.y = -bitmap1.height; bitmap2.x = -bitmap2.width; bitmap2.y = fixY; bitmap3.x = Main._stage.stageWidth; bitmap3.y = fixY; //Tweenerを使って3枚の画像を一箇所に動かします。 Tweener.addTween(bitmap1, { y:fixY, time:1, transition:"easeOutExpo" } ); Tweener.addTween(bitmap2, { x:fixX, time:1, transition:"easeOutExpo" } ); Tweener.addTween(bitmap3, { x:fixX, time:1, transition:"easeOutExpo" } ); //サムネイルの選択画像が変わるようにイベントを発行します。 dispatchEvent(new ViewEvent(ViewEvent.CHANGE_PHOTO, activeArray[nextPhoto])); if (++nextPhoto >= activeArray.length) nextPhoto = 0; } private function hide():void { //Tweenerを使って画像をそれぞれ画面外に向かって動かします。Tweenが終わったらloadPhoto()を実行します。 Tweener.addTween(bitmap1, { y:-bitmap1.height, time:1, transition:"easeOutExpo" } ); Tweener.addTween(bitmap2, { x:-bitmap2.width, time:1, transition:"easeOutExpo" } ); Tweener.addTween(bitmap3, { x:Main._stage.stageWidth, time:1, transition:"easeOutExpo", onComplete:loadPhoto } ); } private function _resize(e:Event):void { //画面がリサイズされたら、show()からやり直します。 flgResize = true; timer.delay = 3000; if (--nextPhoto < 0) nextPhoto = activeArray.length - 1; show(); } } }