PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197
how do i fade out a movie clip using actionscript?
A Flash Developer Resource Site

Results 1 to 8 of 8

Thread: how do i fade out a movie clip using actionscript?

  1. #1
    banned by dp
    Join Date
    Jun 2002
    Posts
    245

    how do i fade out a movie clip using actionscript?

    Is there a way to do this with code...and so that you can vary the speed at which it fades out?

    Thanks.

  2. #2
    Banned
    Join Date
    Apr 2001
    Location
    Montréal, Québec.
    Posts
    25,397
    On a button's actionscript? Or on a frame's?

  3. #3
    Have a look in the samples folder in flash MX, there is an image loader fla. that fades a movieclip with _alpha

  4. #4
    Senior Member
    Join Date
    Jun 2002
    Location
    Toronto, Canada
    Posts
    305
    If you have a movieClip labeled 'myClip' put this code on the frame
    Code:
    inSpeed=10;
    outSpeed=10;
    myClip._alpha=0;
    myClip.onRollOver=function(){
    	this.onEnterFrame=function(){
    		this._alpha+=inSpeed;
    		if(this._alpha>100){
    			this._alpha=100;
    			delete this.onEnterFrame;
    		}
    	}
    }
    myClip.onRollOut=function(){
    	this.onEnterFrame=function(){
    		this._alpha-=outSpeed;
    		if(this._alpha<0){
    			this._alpha=0;
    			delete this.onEnterFrame;
    		}
    	}
    }
    Hope this helps,
    Cheers
    Last edited by untitledskate; 01-05-2004 at 09:37 AM.

  5. #5
    Member
    Join Date
    Jan 2010
    Location
    Drobeta Turnu Severin
    Posts
    59
    Here is what I don't know how to do:
    I need a progressive alpha fade starting from top to bottom, and in fade in starting from bottom to top.
    In AS3 is easier..... in AS2 I know it's possible but I don't know the code.

    My code (put for a movieclip that acts like a button). onRelease goes to the frame where another movieclip (background to a dynamic text field) is fading out and in. The problem is that all the movieclip fades. I need to make it dissapear from top to bottom..... and appears viceversa.

    m1.onRollOver = over;
    m1.onRollOut = out;
    m1.buttText.buttonText.text = "Cricket";
    m1.onRelease = function() {
    gotoAndPlay(3);
    imgbg._alpha=0;
    imgbg.onEnterFrame=function() {
    if(this._alpha >= 100){
    delete this.onEnterFrame;
    } else {
    this._alpha += 5;
    }
    }
    }
    Last edited by alex_popa_81; 08-02-2011 at 10:16 AM.

  6. #6
    Registered User
    Join Date
    Sep 2011
    Posts
    1

    how do i fade out a movie clip using actionscript?

    yes you will need to use either an onEnterFrame or setInterval to fade the Movieclip over time. So lets say for example you wanted to fade out a MovieClip named "myClip"...

    var speed:Number = 5; myClip.onEnterFrame = function() { this._alpha -= speed; if(this._alpha < 0) { delete this.onEnterFrame; } }
    The above is just one to do it. Then simply change the speed variable to make it fade slower or faster.


    3d animation

  7. #7
    Registered User
    Join Date
    Oct 2011
    Posts
    1
    I have a similare problem. I have a star field effect happening with objects spawning and fadding in from the middle of the stage and floating towards the edge of the stage in all directions. I need to make them fade out just before they get to the edge of the stage. At the moment I have the bellow Action script running to remove the Movie Clip object.

    if ( (this._x < -this._width) ||
    (this._x > (Stage.width + this._width)) ||
    (this._y < -this._height) ||
    (this._y > (Stage.height + this._height)) ) {
    this.removeMovieClip();

    Does anyone know how I could tell the objects to fade out when they reach the edge of the canvas?

  8. #8
    Prid - Outing Nig 13's Avatar
    Join Date
    Jul 2006
    Location
    Norway
    Posts
    1,864
    Actionscript Code:
    onClipEvent(load){
        fadeOut = false;
        alphaSpeed = 10;
    }

    onClipEvent(enterFrame){
        this._x = _root._xmouse;
        this._y = _root._ymouse;
        if ( (this._x < -this._width) || (this._x > (Stage.width + this._width)) || (this._y < -this._height) || (this._y > (Stage.height + this._height)) ) {
            fadeOut = true;
        }
        if(fadeOut == true){
            if(this._alpha > 0){
                this._alpha -= alphaSpeed;
            } else {
                this.removeMovieClip();
            }
        }
    }
    I am back, guys ... and finally 18 :P

    BRING BACK THE OLD DESIGN!! OR AT LEAST FIX THE AS TAGS

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center