# Button coding Problem (sub-novice)

**URL:** <https://forum.kirupa.com/t/button-coding-problem-sub-novice/251704>\
**Category:** flash\
**Created:** [February 11, 2008, 10:15pm UTC](https://forum.kirupa.com/t/button-coding-problem-sub-novice/251704 "2008-02-11T22:15:56Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![SteelCity](https://avatars.discourse-cdn.com/v4/letter/s/3bc359/32.png) [@SteelCity](https://forum.kirupa.com/u/SteelCity)\
**Post date:** [February 11, 2008, 10:15pm UTC](https://forum.kirupa.com/t/button-coding-problem-sub-novice/251704/1 "2008-02-11T22:15:56Z")

</div>

**AS3 button coding problem**  
I’ve only had a couple months exposure to flash, and all of that has been with AS2. Can someone have mercy on me a get me through this tough spot.

1. On the coding below have I imported all of the classes that I need?
2. How can I get the gohome function to do what the startLoad functions are doing in the last part of the coding?

The questions are restated in Red in the coding example below.

[COLOR=red]// importing needed libraries, are anymore need??//[/COLOR]

import flash.net.URLRequest;  
import flash.display.Loader;  
import flash.events.Event;  
import flash.events.MouseEvent;  
import flash.events.ProgressEvent;

hobutt\_btn.addEventListener(MouseEvent.MOUSE\_OVER, buttgrow);  
hobutt\_btn.addEventListener(MouseEvent.MOUSE\_OUT,b uttshrink);  
hobutt\_btn.addEventListener(MouseEvent.CLICK,gohom e); [COLOR=red]//calls up the hopage .swf//[/COLOR]

scobutt\_btn.addEventListener(MouseEvent.MOUSE\_OVER ,buttgrow);  
scobutt\_btn.addEventListener(MouseEvent.MOUSE\_OUT, buttshrink);  
scobutt\_btn.addEventListener(MouseEvent.CLICK,gosc ore); //calls up the scopage .swf//

teebutt\_btn.addEventListener(MouseEvent.MOUSE\_OVER ,buttgrow);  
teebutt\_btn.addEventListener(MouseEvent.MOUSE\_OUT, buttshrink);  
teebutt\_btn.addEventListener(MouseEvent.CLICK,gote e); // calls up the teepage .swf //

galbutt\_btn.addEventListener(MouseEvent.MOUSE\_OVER ,buttgrow);  
galbutt\_btn.addEventListener(MouseEvent.MOUSE\_OUT, buttshrink);  
galbutt\_btn.addEventListener(MouseEvent.CLICK,goga llery); // calls up the galpage .swf //

[COLOR=magenta][COLOR=cyan][COLOR=blue]// the next 4 lines just enlarge and shrink all 5 menu buttons based on mouse//[/COLOR][/COLOR][/COLOR]  
function buttgrow(event:MouseEvent):void  
{  
event.target.scaleX = event.target.scaleY = 1.1;  
}  
function buttshrink(event:MouseEvent):void  
{  
event.target.scaleX = event.target.scaleY = 1;  
}

[COLOR=red]// Here is the problem area. My gohome function //  
//is defined in this startLoad function below //  
// how do I bridge the gap//[/COLOR]  
function gohome  
{  
}

[COLOR=seagreen]function startLoad();  
{  
var mLoader:Loader = new Loader();  
var mRequest:URLRequest = new URLRequest(“hopage.swf”); [/COLOR]// [COLOR=red]when I copy this green section for the other buttons, all I would need to do to change the .swf that is pointed to in the line above right??//[/COLOR]  
[/color][COLOR=seagreen]color=“red”]mLoader.contentLoaderInfo.addEventListener(Event.C OMPLETE,onCompleteHandler);  
mLoader.contentLoaderInfo.addEventListener(Progres sEvent.PROGRESS,onProgressHandler);  
mloader.load(mRequest);  
}  
function onCompleteHandler(loadEvent:Event)  
{  
addchild(loadEvent.currentTarget.content);  
}  
function onProgressHandler(mprogress:ProgressEvent)  
{  
var percent:Number = mProgress.bytesLoaded/mprogress.bytesTotal;  
trace(percent)  
}  
startLoad();[/COLOR][/color]
