Go Back   kirupaForum > Flash > Flash CS4

Reply
 
Thread Tools Display Modes
Old 11-27-2009, 08:13 AM   #1
Still Learning
Registered User
Simple Button Help

I have recently read and practiced the instructions given in "Buttons in Flash" tutorial on this site, and although everything works beautifully it does not give me the code for linkage i.e. either external website or mail.

The existing code is:
function setupEvents() {
// associate events with event handlers
myButton.addEventListener(MouseEvent.CLICK, clickButtonHandler);
myButton.addEventListener(MouseEvent.MOUSE_OVER, hoverButtonHandler);
}
setupEvents();

function clickButtonHandler(e:MouseEvent) {
//trace("Clicked Button!");
outputField.text = "Clicked";
}

function hoverButtonHandler(e:MouseEvent) {
//trace("Hovered Over Button!");
outputField.text = "Hovered";
}


How do I include the relevant behaviours to these buttons?

I would appreciate your URGENT advises.

Thank you in advance.
Lisa
Still Learning is offline   Reply With Quote

Sponsored Links (Guests Only) - Register | Need Help?
 

Old 11-27-2009, 08:53 AM   #2
Swooter
Swooter - AS/JS/HTML/CSS
 
Swooter's Avatar
What behaviors do you mean?

Opening a website:
ActionScript Code:
navigateToURL(new URLRequest("http://kirupa.com"), "_blank");


Opening the default e-mail program:
ActionScript Code:
navigateToURL(new URLRequest("mailto:my@email.com?subject=Some subject&body=Some text"), "_blank");

__________________

AS / JS / HTML / CSS / PHP
Swooter is offline   Reply With Quote
Old 11-27-2009, 11:34 AM   #3
Still Learning
Registered User
Many thanks

You a darling. Quick on though, do I not need to apply some script for this to happen with the "hit button"?

Sorry, I realise this is obviously a very simple process but I myself am at a loss. Whatever happened to just applying a behaviour as in Flash 8?

I would appreciate you assistance.


Quote:
Originally Posted by Swooter View Post
What behaviors do you mean?

Opening a website:

ActionScript Code:
navigateToURL(new URLRequest("http://kirupa.com"), "_blank");



Opening the default e-mail program:

ActionScript Code:
navigateToURL(new URLRequest("mailto:my@email.com?subject=Some subject&body=Some text"), "_blank");
Still Learning is offline   Reply With Quote
Old 11-27-2009, 11:48 AM   #4
Swooter
Swooter - AS/JS/HTML/CSS
 
Swooter's Avatar
Behaviour as in Macromedia's definition of an action linked to an element without the need of scripting it yourself?

Anyways, when using the code you supplied before:


ActionScript Code:
function setupEvents() {
// associate events with event handlers
myButton.addEventListener(MouseEvent.CLICK, clickButtonHandler);
myButton.addEventListener(MouseEvent.MOUSE_OVER, hoverButtonHandler);
}
setupEvents();
function clickButtonHandler(e:MouseEvent) {
//trace("Clicked Button!");
navigateToURL(new URLRequest("http://kirupa.com"), "_blank");
outputField.text = "Clicked";
}
function hoverButtonHandler(e:MouseEvent) {
//trace("Hovered Over Button!");
outputField.text = "Hovered";
}

__________________

AS / JS / HTML / CSS / PHP
Swooter is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 05:15 PM.

SUPPORTERS:

kirupa.com's fast and reliable hosting provided by Media Temple. flash components
Creative web apps. Make your own free flash banners and photo slideshows.
Check out the great, high-quality flash extensions. Buy or sell stock flash, video, audio and fonts for as little as 50 cents at FlashDen.

Flash Transition Effects

Flash Effect Tutorials

Digicrafts Components
Flash effects. Art without coding. Upload, publish, deliver. Secure hosting for your professional or academic video, presentations & more. Screencast.com
Streamsolutions Content Delivery Networks Flipping Book - page flip flash component.
Flash-Gallery.com - Get your flash photo gallery (flash component or swf gallery Learn how to advertise on kirupa.com
 

cdn
content delivery network (cdn)

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd. Copyright 2010 - kirupa.com Copyright 2010 - kirupa.com