A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: Mood Bar. Action Script/Math problem.

  1. #1
    Senior Member
    Join Date
    Jan 2004
    Location
    Canada
    Posts
    309

    Unhappy Mood Bar. Action Script/Math problem.

    I'll try to explain as clearly as possible what I am trying to do here...

    I am making a game. I have bars for different needs. (hygene, energy, etc...). There are 6 needs. This works good.

    I have another bar that I want to reflect all of those bars as the overall mood bar. I want it so that when the variables for hygene, energy, etc.. change the overall mood bar changes as well. The bar works fine. I need some sort of way to constantly check the 6 mood bars and calculate what the overall mood bar variable would equall.

    Does anyone have any idea what I should do?

    Frustrated... lol

  2. #2
    Senior Member Ovaire d'Oz's Avatar
    Join Date
    May 2006
    Location
    France
    Posts
    148
    That depends on how your other bars are animated.
    Is it some animation that you draw, some ActionScript using an onEnterFrame event or a scripted Tween motion. In the first case you would have to calculate the overall using the same function used to set your variables, in the second case you can use the onEnterFrame event for calculation and in the last case, use onMotionFinished.
    Hope it'll help you.

  3. #3
    Senior Member
    Join Date
    Jan 2004
    Location
    Canada
    Posts
    309
    Thanks! Can you tell me more about onMotionFinished?

  4. #4
    Senior Member Ovaire d'Oz's Avatar
    Join Date
    May 2006
    Location
    France
    Posts
    148
    Sure, there you go:
    PHP Code:
    //Given this tween:
    var myTween:Tween = new Tween(healthBar"_x"Strong.easeOut07050false);
    //Then use onMotionFinished
    myTween.onMotionFinished = function() {
        
    calculateOverall(); //This function will be triggered once the tween has reached its final value.
    }; 

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