Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with Function and EnterFrame 1

Status
Not open for further replies.

ColonelBlue

Technical User
Jun 24, 2004
110
US
Hello,

I have an enterFrame action that I use on a graphic:
Code:
    onClipEvent (enterFrame) {
        
            
        if (this._alpha >= 0) {
            this._alpha -= 2;
                } else {
            this._alpha = 0;
                }
                        
}

Because I want to use the above code more than a few times, I tried to make it a function.

Code:
function fadeOut() {  

 onClipEvent (enterFrame) {

        
            
        if (this._alpha >= 0) {
            this._alpha -= 2;
                } else {
            this._alpha = 0;
                }
}

But for some reason the function call does not work when I call it via an action on a graphic where initially the code worked when it was explicitly written and not called as a function.

Code:
onClipEvent (enterFrame) {
fadeOut();

}

What am I doing wrong?
Any help would be greatly appreciated.

Thanks in advance.
 

Code:
function fadeOut(_mc) {  
    _mc.onEnterFrame = function() {
        if (_mc._alpha > 2) {
            _mc._alpha -=2;
        } else {
            _mc._alpha = 0;
            delete _mc.onEnterFrame;
        }
    };
};

Then simply use...

fadeOut(some_mc);
// Replace some_mc with the actual mc's instance name & path

Regards. FLASH HELP - OPENED FOR BUSINESS!
TO GET YOUR OWN FREE WEBSITE HOSTING
 
Thank you oldnewbie.
But what if for instance I needed to use that function in a onClipEvent?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top