A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: fade out movie

  1. #1

    fade out movie

    How do you fade-out using actionscript on externally loaded .swf's?

    I've created websites with a main core site / example: http://www.thetimberlodge.com having each section load as a seperate .swf movie. Each loaded movieClip fades in using this actionscript:
    __________________________________

    onClipEvent (load) {
    this._alpha = 0;
    }
    onClipEvent (enterFrame) {
    if (this._alpha<=100) {
    this._alpha += 20;
    }
    }
    __________________________________

    How do I fade-out the same loaded .swf when you click on another section (button) from the main movie (core)? They fade-in fine but I want them to fade-out the same way when you click on a new button...
    Click fade in, new click fade out...

  2. #2
    ActionScript Insomniac
    Join Date
    Jan 2003
    Location
    43d03.21'N, 89d23.65'W
    Posts
    1,173
    Put this code in the timeline that contains the button and the clip:

    code:

    myButton.onRelease = function() {
    myClip.onEnterFrame = function() {
    if (this._alpha > 0) {
    this._alpha -= 20;
    } else {
    delete this.onEnterFrame;
    }
    }



    Then clicking the button will assign the clip a new onEnterFrame function, which will do the fading. When _alpha reaches zero, the onEnterFrame function picks itself up by the seat of its pants, and drops itself in the trash can.

    This approach will, I think, obliterate your original onEnterFrame function. If you want to fade that clip in again, you'll need to assign it a fade-in function in the same way.

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