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.
- On the coding below have I imported all of the classes that I need?
- 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]