Anyone done a flash thermometer animation?

HI guys –

I am trying to find a way to do a thermomenter animation in flash - the mercury in the thermometer would be linked to a percentage ie 85%

In the beginning - this can just be an amount from some place else in the flash file…ie a set percentage 85%

But moving on – I am not sure how exactly i would do the scripting for this!

or even add a script in so that it looks for the percentage in a database?

Any advice?

This Flash Thermometer seems to be fairly extensive.

Is this for a preloader? If not, what is the percentage for?

hmm well its for a site where people are fundraising –

Ie they have a total amount that they are aiming for : say £200 and then the thermometer would show the percentage that they have fundraised so far!

I don’t think it would be very difficult to do. Basically create a movieclip animation of a thermometer with the liquid filling up across x number of frames. Where’s the data coming from?

create a movieclip called thermo and another inside it called mercury inside thermo. make mercury 100 frames long and make it frame one make it the height you want it to be for 1% and frame 100 make it the height you want it to be for 100% and make a motion tween so you have a 100 frame motion tween of the mercury rising in the thermo mc. put a stop() action in the begining of the mercury mc to prevent it from playing. then put the thermo mc on the maintime line and use this code:

var getPercent:LoadVars = new LoadVars();
getPercent.load(‘the-php-file-to-get-the-amount-gotten-and-goal.php’);
getPercent.onLoad = function (success) {
if(success){
goal = getPercent.goal;
amount = getPercent.amount;
setThermo(amount,goal);
}
}
function setThermo(a:Number,g:Number){
percent = Math.round((a/g)*100);
thermo.mercury.gotoAndStop(percent);
}

hope that helps

OK, thanks guys —
Would that scripting only work for a .php file??

Problem is i dont know Nutting about developing or actionscript –
All i know is that the developers here use asp.net and sometimes VB … so how would that example above work?

I just know that it has to somehow tie in from an amount in the database - and im guessing that they will use asp.net or VB to get this –

hmm im clueless i know! :wink: :wink:

just change where it says .php file to .aspx or whatever its coming from, and the .aspx page needs to get the info from the DB and send it to flash as a variable amount for the amount they’ve grossed and goal for the goal amount

the variables also need to be url-encoded when sending to flash

oooh ok thanks!!! i might IM you once ive worked on this – only start in a couple weeks!

Many thanks guys!!! :):slight_smile: yayay