A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Mathematics +preloader

  1. #1
    Member
    Join Date
    May 2004
    Posts
    47

    Mathematics +preloader

    I just don't get it.

    I have this preloader where I get % loaded (start: 0 completed: 100%)
    Now I need to move a movieclip _x cordinate from _x 65 to 200

    How can I move the clip based on percent loaded?
    eg.
    start: 0% mc._x = 65
    end: 100% mc._x = 200

    can anyone please help me out

    thanks in advance,
    best regards T

  2. #2
    Senior Member jbum's Avatar
    Join Date
    Feb 2004
    Location
    Los Angeles
    Posts
    2,920
    When you want something to go from a to b as a percentage goes from 0 to 100, the basic formula is:

    x = a + (percentage/100) * (b-a);

    So your example would be:

    mc._x = 65 + (percentLoaded/100) * (200-65);

    which can be reduced to:

    mc._x = 65 + (percentLoaded*(200-65))/100;

    mc._x = 65 + percentLoaded*135/100;

    mc._x = 65 + percentLoaded*1.35;

  3. #3
    Member
    Join Date
    May 2004
    Posts
    47

    Thanks

    Thanks for helping jbum, I got the same formula from a person at the Macromedia Forums

    Thanks again,

    best regards T

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