I'm new to using actionscript 3 and I was wondering if it was possible to simplify this code and create a loop of some sort, so I could easily replicate the function whenever I'm importing a new button.
The code is this:
videobutton.addEventListener(MouseEvent.CLICK, fl_OpenVideo);
gallerybutton.addEventListener(MouseEvent.CLICK, fl_OpenGallery);
contactbutton.addEventListener(MouseEvent.CLICK, fl_OpenContact);
function fl_OpenVideo(event:MouseEvent):void{
if (!(currentClip is Vids))
{
currentClip.play();
var newClip:Vids = new Vids;
addChild(newClip);
newClip.play();
newClip.y =140;
currentClip = newClip;
}
}
function fl_OpenGallery(event:MouseEvent):void
{
if (!(currentClip is Gal))
{
currentClip.play();
var newClip:Gal = new Gal;
addChild(newClip);
newClip.play();
newClip.y =140;
currentClip = newClip;
}
}
function fl_OpenContact(event:MouseEvent):void
{
if (!(currentClip is Con))
{
currentClip.play();
var newClip:Con = new Con;
addChild(newClip);
newClip.play();
newClip.y =140;
currentClip = newClip;
}
}