Copy link to clipboard
Copied
Hi guys,
I am quite new with Flash and right now I have a animation tracking the power being produced by a device that I have. However, I would like to make an indication of the highest value achieved since the start.
Maybe a line could be created in the middle of the donut and the rotation of the donut will "push" the line as it rotates. The line will then stay at the highest value that it has been pushed to, giving an indication of the highest value attained.
Here is a segment of my code on how I get the donut to rotate(I use phidgets with Flash.)
function onSensorChange(evt:PhidgetDataEvent):void{
trace(evt);
tf_sensors[evt.Index].text = evt.Data;
current = phid.getSensorValue(1)/13.2 - 37.8787;
voltage = (phid.getSensorValue(0)+10)/13.2 - 37.8787;
power = current*voltage;
myText.border=true;
myText.text =power.toString();
donut.rotation = power*1.8;
}
}
Any help would be greatly appreciated!
Thanks in advance!
You didn't do what I indicated in my response. When you use...
else {
line.rotation = 0;
}
You are telling the line to return to the 0 rotation value (where it started). You only want to adjust the rotation value when the rotation of the donut is greater, otherwise, do nothing (which means get rid of the else).
Copy link to clipboard
Copied
If you want to use the line as you describe, then all you should have to do is have a conditional that checks if the rotation value of the circle is higher than the rotation value of the line and if so, adjust the line to the circle rotation. If it is not, don't move the line.
Copy link to clipboard
Copied
(you're drinking too much coffee.)
you can use a new variable to track max watts:
var maxW:Number = 0;
function onSensorChange(evt:PhidgetDataEvent):void{
trace(evt);
tf_sensors[evt.Index].text = evt.Data;
current = phid.getSensorValue(1)/13.2 - 37.8787;
voltage = (phid.getSensorValue(0)+10)/13.2 - 37.8787;
power = current*voltage;
maxW = Math.max(maxW,power);
myText.border=true;
myText.text =power.toString();
donut.rotation = power*1.8;
}
}
how you want to use maxW is unclear. after looking at your video it doesn't seem, at all, clear what that line you showed would have to do with maxW.
it makes more sense, to me, to display maxW in a textfield especially because your watts display appears erratic.
Copy link to clipboard
Copied
Here is an update to the problem,
I can't get the line to stay at the highest value attained.
Link to video of the problem(embed doesn't work) :http://www.youtube.com/watch?v=TaJn_gK6iYw&feature=plcp
Here is the code:
stage.addEventListener(Event.ENTER_FRAME, adjustRotation);
function adjustRotation(evt:Event):void
{
//myText.border=true;
power = 50;
rotate = Math.random()*100+50;
TweenMax.to(donut, 0.3, {rotation:rotate});
actualpower = rotate/1.8;
myText.text = actualpower.toString();
if(line.rotation < donut.rotation)
{line.rotation = donut.rotation+180;}
else {
line.rotation = 0;
}
}
I used donut.rotation + 180 because I have no idea how to change the registration point of the line so I placed the left of the line at the center of the donut.
According to what I understand from my code, when the value of line rotation is less than donut rotation, the line will rotate to teh same value as the donut rotation. When the value of the line rotation is more than the current donut rotation value, the line should stay still, but as seen in the video, the line moves along with the donut regardless of their values.
Thanks!
P.S. Link to video added because embedding doesn't work http://www.youtube.com/watch?v=TaJn_gK6iYw&feature=plcp
Copy link to clipboard
Copied
Anyone could help me with this?
Copy link to clipboard
Copied
You didn't do what I indicated in my response. When you use...
else {
line.rotation = 0;
}
You are telling the line to return to the 0 rotation value (where it started). You only want to adjust the rotation value when the rotation of the donut is greater, otherwise, do nothing (which means get rid of the else).