Go Back   kirupaForum > Flash > ActionScript 3.0

Reply
 
Thread Tools Display Modes
Old 11-26-2009, 08:41 AM   #1
regbolD
Registered User
mouse event and event target

i have these 2 functions and both are the same:

as you can see disabledAction receives e.target as a paremeter from another function (click function actually).

is there a way to somehow call disabledAction from rollOverHandler ?
(so that the code doesnt repeat)

Code:
function disabledAction(target:MovieClip):void {

    var txt:TextField = Finder.findTextfield( target as MovieClip ) as TextField;
    if (txt) {
        txt.textColor = _rollOverColor;
    }
}

function rollOverHandler(e:MouseEvent):void {

    var txt:TextField = Finder.findTextfield( e.target as MovieClip ) as TextField;
    if (txt) {
        txt.textColor = _rollOverColor;
    }
}
regbolD is offline   Reply With Quote

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

Old 11-27-2009, 11:41 AM   #2
Eric Drutel
Registered User
Code:
function disabledAction(target:MovieClip):void {

    var txt:TextField = Finder.findTextfield( target ) as TextField;
    if (txt) {
        txt.textColor = _rollOverColor;
    }
}

function rollOverHandler(e:MouseEvent):void {  
    disabledAction(e.target as MovieClip);
}
You could try as above. In disableAction(), the argument target is a MovieClip, so the cast won't be necessary.
Eric Drutel 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 11:27 AM.

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