PDA

View Full Version : Simplifying Code


stevehanton
08-12-2005, 10:49 PM
I am very interested in help that anyone could offer that could help me simply the following code.

The repeating element (with the buttons and loading of an external movie) will be repeated around 40 time and I would love to find out how to make this code simpler to tidy things up.

onClipEvent (enterFrame) {
if (!loaded && this._url != _root._url) {
if (this.getBytesLoaded() == this.getBytesTotal()) {
loaded = true;
_root.transition.gotoAndPlay("opening");

this.mainmenu.mainbuttons.news_butt.onRelease = function ()
{
if (_root.section != "news.swf")
{
_root.section = "news.swf";
_root.transition.gotoAndPlay ("closing");
}
}

this.mainmenu.mainbuttons.about_butt.onRelease = function ()
{
if (_root.section != "aboutus.swf")
{
_root.section = "aboutus.swf";
_root.transition.gotoAndPlay ("closing");
}
}

this.main_butt.onRelease = function ()
{
if (_root.section != "root_menu.swf")
{
_root.section = "root_menu.swf";
_root.transition.gotoAndPlay ("closing");
}
}

this.mainmenu.mainbuttons.serv_butt.onRelease = function ()
{
if (_root.section != "services1.swf")
{
_root.section = "services1.swf";
_root.transition.gotoAndPlay ("closing");
}
}

this.mainmenu.mainbuttons.hom_butt.onRelease = function ()
{
if (_root.section != "root_menu.swf")
{
_root.section = "root_menu.swf";
_root.transition.gotoAndPlay ("closing");
}
}


}
}
}