A Flash Developer Resource Site

+ Reply to Thread
Results 1 to 7 of 7
  1. #1
    Member
    Join Date
    Jul 2012
    Posts
    58

    How to convert numerical variable to a bar?

    So I recently discovered how to keep track of Hp and Exp in flash. Is there a way I can convert the variables to bars instead of numbers?

  2. #2
    Senior Member Steven FN's Avatar
    Join Date
    Mar 2010
    Location
    CA, USA
    Posts
    274
    You can just set the width of a shape to equal the HP/EXP.

    Code:
    hpBar.width = hp;
    expBar.width = exp;

  3. #3
    Member
    Join Date
    Jul 2012
    Posts
    58
    can you elaborate please? I understand I have to make a dynamic text box and insert the variable name into the text box for numbers, but I don't know how to do that with bars....

  4. #4
    Senior Member Steven FN's Avatar
    Join Date
    Mar 2010
    Location
    CA, USA
    Posts
    274
    Ok, just draw a rectangular bar and convert it to MovieClip, give it the instance name "hpBar". Then where you set the "hp" value to dynamic text box, just add the above code.

    AS2 version would be hpBar._width = hp;

  5. #5
    Member
    Join Date
    Jul 2012
    Posts
    58
    im sorry, i tried to follow your instructions, but it didnt work.....
    when i tested my movie the hp didnt change....
    sorry :/

  6. #6
    Senior Member Steven FN's Avatar
    Join Date
    Mar 2010
    Location
    CA, USA
    Posts
    274
    You can post your source code / snippet or just upload your FLA, so members can take a look.

  7. #7
    Member
    Join Date
    Jul 2012
    Posts
    58
    aw, its fine....
    I'll figure it out one way or another

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