A Flash Developer Resource Site

Results 1 to 8 of 8

Thread: alpha problem

  1. #1
    Senior Member xaero182's Avatar
    Join Date
    Sep 2002
    Posts
    159

    alpha problem

    hey,

    can someone plz help me with this code:

    onClipEvent (load) {
    this._alpha=0;
    }
    onClipEvent (enterFrame) {
    this._alpha+=(100-this._alpha)/5;
    trace(this._alpha);
    }


    the object's alpha never reaches a value of 100


    thx

    Xaero
    Attached Files Attached Files

  2. #2
    Senior Member
    Join Date
    Apr 2001
    Posts
    102
    hey,

    I dont really have an explaination for this but this seems to work
    (wierd problem though, would love to know what causes this)

    Code:
    onClipEvent (load) {
    	this._alpha=0;
    	alpha =0;
    }
    onClipEvent (enterFrame) {
    	alpha+=((100-this._alpha)/5);
    	this._alpha = alpha
    	trace(this._alpha);
    }

  3. #3
    Senior Member
    Join Date
    Aug 2000
    Location
    Montréal
    Posts
    14,141
    that's because _alpha is a property. If you'd have tried it with _x or _rotation you would have had the same approx. numbers.
    To get an exact value, use variables. For example:
    onClipEvent (load) {
    this._alpha = al = 0;
    }
    onClipEvent (enterFrame) {
    al += (100-this._alpha)/5;
    this._alpha=al;
    }

    gparis

  4. #4
    Senior Member xaero182's Avatar
    Join Date
    Sep 2002
    Posts
    159
    thx guys!!!

    is this the same reason the _rotation property goes crazy above 180°?

    thx!!!

    Xaero


  5. #5
    Senior Member
    Join Date
    Aug 2000
    Location
    Montréal
    Posts
    14,141
    as i said, don't use properties directly in you equations. use variables.
    gparis

  6. #6
    Senior Member
    Join Date
    May 2001
    Posts
    1,838
    Also, be careful.

    That codes is "deceleration - move toward 100". From MATH view, theoretically, it will progressively be near 100 but never equal 100;

  7. #7
    Senior Member xaero182's Avatar
    Join Date
    Sep 2002
    Posts
    159
    ok,
    thanks to you all!!!

    greets

    Xaero

  8. #8
    half as fun, double the price senocular's Avatar
    Join Date
    Feb 2002
    Location
    San Francisco, CA (USA)
    Posts
    4,361
    _alpha is actually based on a range of 0-255. Because of this any attempt to adjust it by 100/256 = 0.390625 or less, nothing will happen. previous posts offer appropriate solutions

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