Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 03-09-2010, 05:19 PM   #1
Registered User
Join Date: Sep 2008
Posts: 26
Default Interactive pie chart / odometer

Hi all,
here's what I need to do: I need to have a pie that is not 100% complete circle, like a pacman facing north. That area is static and represents a data range from 0.00 to 1200.00. I need to have another slice over it that dynamically reflects input data from 0.00 to 1200.00. In the example below I have the static max. data range as blue and the dynamic data range as orange showing a data input of 6.70:


Anyone can help me with this? All I find online is pie charts that are full circles and use percentages instead of numerical data... Attached is a test.fla (CS3 format) with the above shapes. Thanks
Attached Files
File Type: zip test_pie.zip (4.6 KB, 48 views)
mas_bass is offline   Reply With Quote
Old 03-12-2010, 10:27 AM   #2
Registered User
Join Date: Sep 2008
Posts: 26

Got an answer from user DawsonK on flashkit, here it is in case anyone needs it. Just paste this code on main timeline.

ActionScript Code:
var inputVal = 66.70; // var baseMC = _root.createEmptyMovieClip("baseMC", _root.getNextHighestDepth()); baseMC._x = 150; baseMC._y = 150; var dynamicMC = baseMC.duplicateMovieClip("dynamicMC", _root.getNextHighestDepth()); // var startSize = 320*-1; var startPos = 70; drawWedge(baseMC,200,20,100,startSize,startPos,[0, 0x000000],[0x0033CC, 100]); // processsInput(inputVal); // onMouseDown = function () {     processsInput((1200/Stage.height)*_ymouse); }; function processsInput(inVal) {     var wedgeSize = (startSize/1200)*inVal;     var wedgeStart = startPos;     drawWedge(dynamicMC,200,20,100,wedgeSize,wedgeStart,[0, 0x000000],[0xFF6600, 100]); } // function drawWedge(mc, sx, sy, radius, arc, startAngle, lstyle, fstyle) {     mc.clear();     var segAngle, theta, angle, angleMid, segs, ax, ay, bx, by, cx, cy;     arc = (Math.abs(arc)>360) ? 360 : arc;     segs = Math.ceil(Math.abs(arc)/45);     segAngle = arc/segs;     theta = -(segAngle/180)*Math.PI;     angle = -(startAngle/180)*Math.PI;     ax = Math.cos(angle)*radius;     ay = Math.sin(angle)*radius;     mc.lineStyle.apply(mc,lstyle);     mc.beginFill.apply(mc,fstyle);     mc.moveTo(0,0);     mc.lineTo(ax,ay);     if (segs>0) {         for (var i = 0; i<segs; i++) {             angle += theta;             angleMid = angle-(theta/2);             bx = Math.cos(angle)*radius;             by = Math.sin(angle)*radius;             cx = Math.cos(angleMid)*(radius/Math.cos(theta/2));             cy = Math.sin(angleMid)*(radius/Math.cos(theta/2));             mc.curveTo(cx,cy,bx,by);         }     }     mc.endFill(); }
mas_bass is offline   Reply With Quote

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

All times are GMT. The time now is 04:51 AM.

Follow actionscriptorg on Twitter


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2015, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.