package { import com.greensock.*; import com.greensock.easing.*; import flash.display.MovieClip; import flash.events.Event; import flash.events.MouseEvent; import flash.utils.setTimeout; import flash.display.Bitmap; import flash.display.BitmapData; public class Item extends MovieClip { private var positionSoplya: String = 'Down'; //'Up' private var onDotOver: Function; private var onDotOut: Function; private var positionSoplyaX: int = 60; private var newY: int = 0; public var index: int = 0; public var alias: String; public function Item() { addEventListener(Event.ADDED_TO_STAGE, onAddedToStage); itemFace.overArea.addEventListener(MouseEvent.MOUSE_OVER, onOver); itemFace.overArea.addEventListener(MouseEvent.MOUSE_OUT, onOut); itemFace.overArea.buttonMode = true; alpha = 0; y = 45; } public function show(): void { TweenLite.to(this, 0.8, {alpha:1, y:newY, ease:Expo.easeOut}); } public function setData(obj: Object, onDotOverL: Function, onDotOutL: Function): void { onDotOver = onDotOverL; onDotOut = onDotOutL; visible = false; positionSoplya = obj.posY == 0 ? 'Down' : 'Up'; newY = obj.posY == 0 ? 3 : 153; x = int(Number(obj.xPosImg)); positionSoplyaX = obj.xPosDot - obj.xPosImg; itemFace.yearTxt.text = obj.year; setTimeout(drawText, 1); itemFace.yearTxt.mouseEnabled = false; itemFace.img.addChild(obj.img); } private function onAddedToStage(ev: Event): void { if(positionSoplya == 'Up') { itemFace.y = 10; bg.soplya.rotation = 180; bg.soplya.y = 10; bg.bgShape.y = 10; } bg.soplya.x = positionSoplyaX; itemFace.img.x = Math.ceil((width - itemFace.img.width) / 2); itemFace.img.y = (height - itemFace.img.height - 12) / 2; itemFace.txtBg.width = itemFace.img.width; itemFace.txtBg.x = Math.ceil(itemFace.img.x + itemFace.img.width / 2); visible = true; } private function onOver(ev: MouseEvent): void { onDotOver(index); } private function onOut(ev: MouseEvent): void { onDotOut(index); } private function drawText(): void { /*var bmp:BitmapData = new BitmapData(itemFace.yearTxt.width, itemFace.yearTxt.height, true, 0x00FFFFFF); bmp.draw(itemFace.yearTxt); var res: Bitmap = new Bitmap(bmp); //itemFace.yearTxt.visible = false; res.x = itemFace.yearTxt.x; res.y = itemFace.yearTxt.y - 20; trace(res.y, res.x, res.width, res.height) itemFace.addChild(res);*/ } } }