hjkhghopjkertteerterterterertertrtoirh
bnmbertsurhetertertertertertertertpdf'tdfg
/
srv
/
www
/
virtual
/
dev1.wccweb.jp.dac4.biz
/
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.Sprite; import flash.display.MovieClip; import flash.events.Event; import flash.events.MouseEvent; import flash.events.TextEvent; import flash.text.StyleSheet; import flash.text.TextField; import flash.text.TextFieldAutoSize; import events.FooterEvent; import events.ViewEvent; import display.View; import display.ThumbNail; import util.StaticFunctions; public class Footer extends Sprite { private var thumbArray:Array = new Array(); private var thumbContainer:Sprite = new Sprite(); private var slideBtnArray:Array; private var tagSortObj:Object = new Object(); private var tagViewArray:Array = new Array(); private var settingH:Number = 0; private var oldCnt:int = 0; private var activeArray:Array; public function Footer():void { Main._stage.addEventListener(Event.RESIZE, _resize ); thumbContainer.x = 100; addChild(thumbContainer); thumbContainer.mask = thumbMask; slideBtn1.alpha = 0; //スライドショーのON、OFFのボタン slideBtnArray = [slideBtn0, slideBtn1]; _resize(null); } public function setThumbNail(_array:Array):void { var _bmd:BitmapData; var _obj:Object; var _bmp:Bitmap; var _thumb:ThumbNail; activeArray = _array; //存在する写真の数だけサムネイルを生成していきます。 for (var i:int = 0; i < _array.length; i++) { _bmd = _array[i]; _bmp = new Bitmap(_bmd); _thumb = new ThumbNail(); //StaticFunctions.resizeOver(元の画像の幅,元の画像の高さ,変更したい最低幅,変更したい最低高さ,幅に合わせるか):Object //返り値{width:リサイズした時の幅,height:リサイズした時の高さ} _obj = StaticFunctions.resizeOver(_bmd.width, _bmd.height, 28, 28, true); _bmp.width = _obj.width; _bmp.height = _obj.height; //センタリングします。 _bmp.x = 1-(_bmp.width - 28) / 2 _bmp.y = 1-(_bmp.height - 28) / 2; _thumb.addChild(_bmp); _bmp.mask = _thumb.maskMc; _thumb.fixX = i * 31; _thumb.y = _thumb.hideY; //サムネイルそれぞれにユニークなIDを渡しておきます。 _thumb.id = i; thumbContainer.addChild(_thumb); if(i!=0){ _thumb.addEventListener(MouseEvent.CLICK, _click); _thumb.addEventListener(MouseEvent.ROLL_OVER, _rollover); _thumb.addEventListener(MouseEvent.ROLL_OUT, _rollout); _thumb.buttonMode = true; }else { _thumb.bgMc.alpha = 1; } thumbArray.push(_thumb); _thumb.show(0); } //btnsMc.rBtn.buttonMode = btnsMc.gBtn.buttonMode = btnsMc.bBtn.buttonMode = true; //btnsMc.rBtn.addEventListener(MouseEvent.CLICK, _clickRGB); //btnsMc.gBtn.addEventListener(MouseEvent.CLICK, _clickRGB); //btnsMc.bBtn.addEventListener(MouseEvent.CLICK, _clickRGB); slideBtn1.addEventListener(MouseEvent.CLICK, _clickSlide); slideBtn1.buttonMode = true; thumbContainer.addEventListener(Event.ENTER_FRAME, enterFrame); } private function enterFrame(e:Event):void { //マウスの位置、サムネイルの数、ステージの幅によって、サムネイルをスクロールさせる場合はさせます。 var W:Number = 31 * activeArray.length; if (W > thumbMask.width) { var gox:Number = 100 - (W - thumbMask.width) * (thumbMask.mouseX*thumbMask.scaleX / thumbMask.width); thumbContainer.x = thumbContainer.x + (gox - thumbContainer.x) / 7; if (thumbContainer.x > 100) thumbContainer.x = 100; if (thumbContainer.x < 100 - (W - thumbMask.width)) thumbContainer.x = 100 - (W - thumbMask.width); }else{ thumbContainer.x = 100; } } public function show():void { //最初にしたから出てくる時用の関数です。 settingH = bg.height; Tweener.addTween(this, { y:Main._stage.stageHeight - settingH, time:0.5, transition:"easeOutExpo" } ); } private function thumbReTile(_array:Array):void { //activeArrayを選択されたタグを含むサムネイルにします。サムネイルを並び替えていきます。 activeArray = _array; //一旦すべてのサムネイルを下に引っ込めます for each(var _thumb:ThumbNail in thumbArray)_thumb.hide(); //指定されたタグを含むサムネイルだけを並べて、上に上げます。 for (var j:int = 0; j < _array.length; j++) { thumbArray[_array[j]].fixX = j * 31; thumbArray[_array[j]].show(0.03 * j + 0.7); } } private function _clickSlide(e:MouseEvent):void { setSlideBtnEnabled(); //スライドショーのON,OFFが押されたイベントを発行します。 dispatchEvent(new FooterEvent(FooterEvent.IS_SLIDESHOW, slideBtn0.alpha ? true : false)); } private function setSlideBtnEnabled():void { //スライドショーのON,OFFボタンの設定をします。(選択されている方のボタンを押せなくします。) for each(var btn:MovieClip in slideBtnArray) { btn.alpha = btn.alpha ? 0 : 1; btn.buttonMode = btn.alpha ? false : true; if (btn.alpha) btn.removeEventListener(MouseEvent.CLICK, _clickSlide); else btn.addEventListener(MouseEvent.CLICK, _clickSlide); } } public function setListener():void { //viewの方で、写真が切り替わったら、サムネイルの選択状況を切り替えるsetEnabledを実行します。 Main.view.addEventListener(ViewEvent.CHANGE_PHOTO, function(e:ViewEvent) { setEnabled(e.value); } ); } public function setTags(_obj:Object):void { //Mainからタグソート用のObjectが渡されます。 tagSortObj = _obj; //テキストボタンを作っていきます、一番左は’ALL’とします。 tagViewArray.push('ALL'); //タグの種類の数だけ追加していきます for (var str in tagSortObj) if (str != 'ALL') tagViewArray.push(str); //スタイルシートを作ります。 var style:StyleSheet = new StyleSheet(); style.setStyle(".red", { color:"#FF0000" } ); style.setStyle(".gray", { color:"#666666" } ); tags_txt.styleSheet = style; tags_txt.autoSize = TextFieldAutoSize.LEFT; addEventListener(TextEvent.LINK, onLinkEvent); reSetTags('ALL'); } private function reSetTags(fix_str:String = 'ALL'):void { //タグソート用のテキストボタンを作ります。 tags_txt.htmlText = ""; for (var i:int = 0; i < tagViewArray.length; i++) //選択されているタグの場合はclassをredに、身選択のタグのclassはgrayにしてhtmlTextで書き出します。 tags_txt.htmlText += (tagViewArray[i] == fix_str) ? "<span class='red'>" + tagViewArray[i] + "</span> " : "<a class='gray' href='event:" + tagViewArray[i] + "'>" + tagViewArray[i] + "</a> "; } //タグがクリックされた時に呼び出されます。 private function onLinkEvent(e:TextEvent):void { reSetTags(e.text); thumbReTile(tagSortObj[e.text]); dispatchEvent(new FooterEvent(FooterEvent.SELECT_TAGS, tagSortObj[e.text])); } //右側にあるRGBのボタンのクリック時用Function //private function _clickRGB(e:MouseEvent):void { // e.currentTarget.alpha = !e.currentTarget.alpha; // dispatchEvent(new FooterEvent(FooterEvent.SELECT_RGB,[btnsMc.rBtn.alpha , btnsMc.gBtn.alpha, btnsMc.bBtn.alpha])); //} //サムネイル用 private function _click(e:MouseEvent):void { if (slideBtn0.alpha) setSlideBtnEnabled(); dispatchEvent(new FooterEvent(FooterEvent.SELECT_THUMB, e.currentTarget.id)); } //サムネイル用 private function _rollover(e:MouseEvent):void { Tweener.removeTweens(e.target.bgMc); e.target.bgMc.alpha = 1; } //サムネイル用 private function _rollout(e:MouseEvent):void { e.target.bgMc.alpha = 1; Tweener.addTween(e.target.bgMc, { alpha:0, time:0.6, transition:"easeOutExpo" } ); } //画面がリサイズされた時の調整用。 private function _resize(e:Event):void { thumbMask.width = Main._stage.stageWidth - 100 - 5; //btnsMc.x = Main._stage.stageWidth; bg.width = Main._stage.stageWidth; y = Main._stage.stageHeight - settingH; } //サムネイルのマウスアクションコントロール public function setEnabled(n:int):void { var _thumb:ThumbNail = thumbArray[oldCnt]; _thumb.addEventListener(MouseEvent.CLICK, _click); _thumb.addEventListener(MouseEvent.ROLL_OVER, _rollover); _thumb.addEventListener(MouseEvent.ROLL_OUT, _rollout); _thumb.buttonMode = true; _thumb.bgMc.alpha = 0; _thumb = thumbArray[n]; _thumb.removeEventListener(MouseEvent.CLICK, _click); _thumb.removeEventListener(MouseEvent.ROLL_OVER, _rollover); _thumb.removeEventListener(MouseEvent.ROLL_OUT, _rollout); _thumb.buttonMode = false; _thumb.bgMc.alpha = 1; oldCnt = n; } } }