A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: slowly increasing alpha effect

  1. #1
    Junior Member
    Join Date
    Mar 2001
    Posts
    14

    resolved

    What i am trying to do is when a botton is clicked, it will sent a movie instance to another frame and stop. where it stops i have another movie that is 100 layers and 1 frame. on that movie i am trying to get it to loop and display a slowly insreasing alpha effect. this is the code i have and im not sure what im doing wrong.

    onClipEvent (load) {
    setProperty (this, _alpha, 0);
    i = 0
    z = 0
    }
    onClipEvent (enterFrame) {
    do {
    z = 0
    a = random(5);
    i = i+a;
    if (i>100) {
    i = 100;
    }
    setProperty (this, _alpha, i);
    do{
    z++
    } while (z<1000)
    }while (i<100);
    }
    this code only seems to display the movie when its at 100% alpha. any help would be greatly appreciated.

    thanks

  2. #2
    Junior Member
    Join Date
    Aug 2000
    Posts
    10
    Have you tried putting the var z into another movieclip?
    call that one "alpha" then...

    onClipEvent (enterFrame) {
    setProperty (this, _alpha, _root.alpha:z);
    if (_root.alpha:z<100) {
    i = random(5);
    _root.alpha:z = _root.alpha:z + i;
    }
    }

    not completly sure if thats gunna help.
    Simon

    [Edited by smilerroberts on 07-03-2001 at 11:25 AM]

  3. #3
    Senior Member
    Join Date
    Feb 2001
    Posts
    1,835

    you can't use a while loop in this way - the frame only gets redrawn once the actionscript has finished executing, ie. when the alpha is at 100%

    so simply change the alpha value once in every loop, something like

    onClipEvent(enterFrame){
    i = random(5);
    _alpha = Math.min(_alpha+i,100);

    if(_alpha == 100)
    gotoAndPlay("fadeFinished");
    }

    will ened some customisation to suit your exact needs but you can see what's going on anyway

    - n.

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