Hi all, first post here.
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:
Now I'm used to other languages. I've been programming on almost everything since the early 1980s like BASIC on the Commodore 64 and BBC machines, assembler on the Amiga and PHP/MySQL online. The logical way of passing the URL as a parameter to cut down on masses of code is giving me nothing but error message after error message.
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 :(
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:
Code:
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 :(