View Full Version : how to make a button to control the temperature ?
yuzhan618
July 20th, 2008, 11:02 AM
hi, i wanna make two 'up' and 'down' button to control the number of temperature going up and down, and also moving to left and right .
anyone can tell me how to do it?
thanks a lot.
sekasi
July 20th, 2008, 11:15 AM
Start with the livedocs. Come back with specific problems.
yuzhan618
July 20th, 2008, 11:26 AM
thanks..
now i think i just need some idea of the logic behind the codes. I can not figure out what kind of function i need to use to make the number changes also moves...
saxx
July 20th, 2008, 03:58 PM
ok, picture this
Layers in this order
thermostat body[regular layer]
thermostatcontent(the space where you will see the red)[mask]
mc_redBox[masked layer]
then you have your buttons
every time you press the up button, mc_redBox.y goes up, and the same thing with the down, be sure to use a tweening engine like tweener or tweenlight
sekasi
July 20th, 2008, 04:21 PM
eww layers :P
saxx
July 20th, 2008, 05:00 PM
well if you want to do absolutely everything in AS then thats another story. I don't have time to explain that :)
yuzhan618
July 21st, 2008, 09:46 AM
thanks for reply..:)
I wanna show you my code, there still has some problem , when I test it, I hit the " upTemp_mc" and "downTemp-mc" buttons, the output still shows "none of the ones above"...i dont know why....
codes:
//import Tweener for use in ActionScript
import caurina.transitions. Tweener;
//set the myTemp to 102 and set the text of the myCounter TextField
var myTemp:Number = 102;
myCounter.text = myTemp + "oF";
//add listeners that triggers the function boostMyLine when the buttons are clicked
uptemp_mc.addEventListener(MouseEvent.CLICK, boostMyLine);
downtemp_mc.addEventListener(MouseEvent.CLICK, boostMyLine);
//the function boostMyLine
//this function boosts the length of the myLine by 1px.
//it takes 0.6 second to boost the line, while this is done the function showMyUpdate runs
//when the line is fully boosted the function completedMyUpdate runs
function boostMyLine(e:Event):void {
if (e.target.name == "uptemp_mc") {
Tweener.addTween(myLine, {width:myTemp+1, time:0.6, onUpdate:showMyUpdate, onComplete:completedMyUpdate});
} else if (e.target.name == "downtemp_mc") {
Tweener.addTween(myLine, {width:myTemp-1, time:0.6, onUpdate:showMyUpdate, onComplete:completedMyUpdate});
} else {
trace("none of the ones above");
}
}
//as the line is being boosted the width of the myLine is being written to the myCounter TextField
function showMyUpdate():void {
//trace(”function showMyUpdate”);
myCounter.text = String(Math.round(myLine.width)) + " oF";
}
//finally, if the myLine exceeds 200 px, it will be 200
function completedMyUpdate():void {
myTemp = myLine.width;
if (myTemp > 200){
Tweener.addTween(myLine, {width:200, time:0.6, onUpdate:showMyUpdate});
myTemp = 200;
}
}
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.