LOADING
Loading
Hi , welcome back.
LogoutLOGOUT
 
  Lost password?  
Hi
 




 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 09-29-2007, 03:20 AM
SpectacularStuf SpectacularStuf is offline
Registered User
 
Join Date: Sep 2007
Posts: 1
Rep Power: 0
SpectacularStuf is on a distinguished road
Function Consolidation Help

Okay,
I know there has to be an easier way to write this.
Can someone please point me in the right direction?
There has got to be a way to use 1 function and some type of variable to make to add the new sprites from an array with a for statement. I just don't know how. Any help would be greatly appreciated.
Thanks,
Wayne
Code:
//Add the button onto the stage
var homebutton:Sprite = new Sprite();
var aboutbutton:Sprite = new Sprite();
var servicesbutton:Sprite = new Sprite();
var specialsbutton:Sprite = new Sprite();
var contactbutton:Sprite = new Sprite();
homebutton.buttonMode = true;
aboutbutton.buttonMode = true;
servicesbutton.buttonMode = true;
specialsbutton.buttonMode = true;
contactbutton.buttonMode = true;
homebutton.addChild(home);
aboutbutton.addChild(about);
servicesbutton.addChild(services);
specialsbutton.addChild(specials);
contactbutton.addChild(contact);
// AddEvent for Home Button
this.home.addEventListener("mouseOver",homedoOver);
this.home.addEventListener("mouseOut",homedoOut);
this.home.addEventListener("mouseDown",homedoDown);
this.home.addEventListener("mouseUp",homedoUp);
// AddEvent for about Button
this.about.addEventListener("mouseOver",aboutdoOver);
this.about.addEventListener("mouseOut",aboutdoOut);
this.about.addEventListener("mouseDown",aboutdoDown);
this.about.addEventListener("mouseUp",aboutdoUp);
// AddEvent for services Button
this.services.addEventListener("mouseOver",servicesdoOver);
this.services.addEventListener("mouseOut",servicesdoOut);
this.services.addEventListener("mouseDown",servicesdoDown);
this.services.addEventListener("mouseUp",servicesdoUp);
// AddEvent for specials Button
this.specials.addEventListener("mouseOver",specialsdoOver);
this.specials.addEventListener("mouseOut",specialsdoOut);
this.specials.addEventListener("mouseDown",specialsdoDown);
this.specials.addEventListener("mouseUp",specialsdoUp);
// AddEvent for contact Button
this.contact.addEventListener("mouseOver",contactdoOver);
this.contact.addEventListener("mouseOut",contactdoOut);
this.contact.addEventListener("mouseDown",contactdoDown);
this.contact.addEventListener("mouseUp",contactdoUp);
addChild(homebutton);
addChild(aboutbutton);
addChild(servicesbutton);
addChild(specialsbutton);
addChild(contactbutton);
//Home Button Function 
function homedoOver(evt:MouseEvent)
{
 home.gotoAndPlay(2);
}
function homedoOut(evt:MouseEvent)
{ 
 home.gotoAndPlay(11);
}
function homedoDown(evt:MouseEvent)
{ 
 home.gotoAndPlay(21);
}
function homedoUp(evt:MouseEvent)
{ 
 home.gotoAndStop(10);
}

//About Button Function 
function aboutdoOver(evt:MouseEvent)
{
 about.gotoAndPlay(2);
}
function aboutdoOut(evt:MouseEvent)
{ 
 about.gotoAndPlay(11);
}
function aboutdoDown(evt:MouseEvent)
{ 
 about.gotoAndPlay(21);
}
function aboutdoUp(evt:MouseEvent)
{ 
 about.gotoAndStop(10);
}

//Services Button Function 
function servicesdoOver(evt:MouseEvent)
{
 services.gotoAndPlay(2);
}
function servicesdoOut(evt:MouseEvent)
{ 
 services.gotoAndPlay(11);
}
function servicesdoDown(evt:MouseEvent)
{ 
 services.gotoAndPlay(21);
}
function servicesdoUp(evt:MouseEvent)
{ 
 services.gotoAndStop(10);
}

//Specials Button Function
function specialsdoOver(evt:MouseEvent)
{
 specials.gotoAndPlay(2);
}
function specialsdoOut(evt:MouseEvent)
{ 
 specials.gotoAndPlay(11);
}
function specialsdoDown(evt:MouseEvent)
{ 
 specials.gotoAndPlay(21);
}
function specialsdoUp(evt:MouseEvent)
{ 
 specials.gotoAndStop(10);
}

//Contact Button Function
function contactdoOver(evt:MouseEvent)
{
 contact.gotoAndPlay(2);
}
function contactdoOut(evt:MouseEvent)
{ 
 contact.gotoAndPlay(11);
}
function contactdoDown(evt:MouseEvent)
{ 
 contact.gotoAndPlay(21);
}
function contactdoUp(evt:MouseEvent)
{ 
 contact.gotoAndStop(10);
}
Reply With Quote
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Decompiling haXe puppy Members Cafe 3 12-16-2008 10:38 AM
Slight actionscript forum Agent-VIP Newbies 0 05-08-2007 12:30 AM
Newbie! Cannot access flash.net.FileReference paulr Actionscript 2.0 7 12-21-2006 11:33 AM
Buttons ... damned BUTTONS gooup Flash 8 3 10-15-2006 12:31 AM
Functions ssjskipp Flash MX ActionScript 5 03-22-2005 12:42 AM




All times are GMT. The time now is 12:46 PM.