A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: power to a power

Hybrid View

  1. #1
    Junior Member
    Join Date
    May 2007
    Posts
    4

    power to a power

    *flash8
    *actionscript2

    I've been having problems with this math command

    this._xscale = ((2.71828)^(-(this._x-120)/100)^2)+1;
    this._yscale = this._xscale;

    that it does as the symbols ._x approaches 120 it's scale increases.
    When i graph out this function i get the results i want a nice bell shaped curve that increases at 120 to a value of 2 and sloops down to 1 around ~300.

    after experimenting with flash it appears that it doesn't like power raised to a power such as 2^2^2 or 2^(2^2).

    Anyone have any ideas?

    if you would like to see what the graph looks like enter
    (2.71828)^(-((x-120)/100)^2)+1
    into Java Grapher
    note: change Xmax to 500
    Last edited by FireTime; 05-27-2007 at 11:10 PM.

  2. #2
    亲爱钰 slingsrat's Avatar
    Join Date
    Mar 2002
    Location
    Middle Earth
    Posts
    229
    I'm no expert on this but I'm unsure where you got your syntax from. "^" doesn't seem to have anything to do with raising to a power. 2^2^2 (sic) would be written

    d = Math.pow(Math.pow(2,2),2);

    in actionscript. Anyhow perhaps I'm missing something.

  3. #3
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    a FWIW ...

    ActionScript 2.0 Language Reference
    ActionScript language elements >
    Operators >
    ^ bitwise XOR operator

    var x:Number = 15 ^ 9;
    trace(x);

    // 15 decimal = 1111 binary
    // 9 decimal = 1001 binary
    // 1111 ^ 1001 = 0110
    // returns 6 decimal (0110 binary)

  4. #4
    Junior Member
    Join Date
    May 2007
    Posts
    4
    thanks allot!
    I feel stupid now for not realizing the ^ was not for exponents.

    here is the finished line of code

    Code:
    this._xscale = (Math.pow(2.71828, -Math.pow(((this._x-120)/50), 2))+1)*100;
    this._yscale = this._xscale;
    //as the objects x value approaches 120 it doubles in size

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