Hello there…
I am trying to create a picture gallery…
I can arrange the thumbs in the screen and when I click to one of them, it shows the bigger picture.
But the problem is, I want the thumb to do something when the mouse is over it.
Let me show the code:
package {
import com.greensock.easing.Expo;
import com.greensock.easing.Cubic;
import com.greensock.easing.EaseLookup;
import com.greensock.TweenMax;
import flash.events.MouseEvent;
import flash.display.Sprite;
/**
* @author emrea
*/
public class Thumbs extends Sprite
{
private var xml : XML;
private var thumb : Thumb;
private var container : Sprite;
private var app : App;
private var currentImg : Resim;
private var oldImg : Resim;
public function Thumbs(xml : XML, app : App)
{
this.app = app;
this.xml = xml;
container = new Sprite();
addChild(container);
container.y = 680;
Init();
}
private function Init() : void
{
var thumbY : int = -1;
for (var i : int = 0;i < xml.item.length();i++)
{
thumb = new Thumb(xml.item*.thumb);
thumb.resimData = xml.item*.anaimaj;
container.addChild(thumb);
thumb.addEventListener(MouseEvent.CLICK, onMsClick);
thumb.addEventListener(MouseEvent.MOUSE_OVER, onMsOver);
thumb.addEventListener(MouseEvent.MOUSE_OUT, onMsOut);
thumb.x = (i % 2) * (200 + 5);
if(i != 0) thumbY = (i % 2 == 0 ? thumbY - 105 : thumbY);
thumb.y = thumbY;
thumb.mouseChildren = false;
}
}
private function onMsClick(event : MouseEvent) : void
{
if(oldImg)
{
trace("ak")
TweenMax.to(oldImg, 0.5, {alpha : 0 , ease : Cubic.easeOut, onComplete:Kill,onCompleteParams:[oldImg]});
}
currentImg = new Resim((Thumb(event.target)).resimData);
this.addChild(currentImg);
TweenMax.from(currentImg, 2, {alpha: 0 , ease : Cubic.easeIn});
oldImg = currentImg;
}
private function Kill(resim : Resim) : void
{
removeChild(resim);
}
private function onMsOut(event : MouseEvent) : void
{
TweenMax.to(this, 0.5, {alpha : 1,ease : Expo.easeOut});
}
private function onMsOver(event : MouseEvent) : void
{
TweenMax.to(this,0.5,{alpha : 0.5,ease : Expo.easeOut});
}
}
}
When I use that tweenmax.to(this…) part, all the thumbs act like one.
I tried to change this to thumbs but i didn’t work.
What do you suggest me to convert all the thumbs to an individual image?