Found this site using Google while trying to figure out why I couldn't add a URL to a button and thanks to an existing question on here, I've done it. Problem is, seems long-winded. Here's my code:
Expand|Select|Wrap|Line Numbers
- btnHomePage.addEventListener(MouseEvent.CLICK,callHomePage);
- btnAboutUs.addEventListener(MouseEvent.CLICK,callAboutUs);
- btnFacilities.addEventListener(MouseEvent.CLICK,callFacilities);
- btnContactUs.addEventListener(MouseEvent.CLICK,callContactUs);
- function callHomePage(event:MouseEvent):void {
- var url:String="home.php";
- var request:URLRequest=new URLRequest(url);
- try {
- navigateToURL(request,'');
- } catch (e:Error) {
- trace("Error occurred with Home Page");
- }
- }
- function callAboutUs(event:MouseEvent):void {
- var url:String="aboutus.php";
- var request:URLRequest=new URLRequest(url);
- try {
- navigateToURL(request,'');
- } catch (e:Error) {
- trace("Error occurred with About Us");
- }
- }
- function callFacilities(event:MouseEvent):void {
- var url:String="facilities.php";
- var request:URLRequest=new URLRequest(url);
- try {
- navigateToURL(request,'');
- } catch (e:Error) {
- trace("Error occurred with Facilities");
- }
- }
- function callFacilities(event:MouseEvent):void {
- var url:String="contactus.php";
- var request:URLRequest=new URLRequest(url);
- try {
- navigateToURL(request,'');
- } catch (e:Error) {
- trace("Error occurred with Contact Us");
- }
- }
Anyone able to help me cut this mass of code down to only one function with the URL being passed each time please?
I'm using Adobe Flash CS9 Professional and loaded it yesterday for the first time after buying a (thick) book which claims to be also for beginners but its lost me already.
Having to learn Flash for the business - thought I could get away without it :(