Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
0

Highest value indication on animation

Guest
Oct 19, 2012 Oct 19, 2012

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.

Donut Rotation.PNG

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!

TOPICS
ActionScript

Views

951
Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Oct 26, 2012 Oct 26, 2012

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).

Votes

Translate
LEGEND ,
Oct 19, 2012 Oct 19, 2012

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.

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 19, 2012 Oct 19, 2012

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.

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Oct 21, 2012 Oct 21, 2012

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

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Oct 26, 2012 Oct 26, 2012

Copy link to clipboard

Copied

Anyone could help me with this?

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 26, 2012 Oct 26, 2012

Copy link to clipboard

Copied

LATEST

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).

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines