PDA

View Full Version : Passing value into a .swf gauge


drmazey
02-26-2006, 05:21 AM
I have a round dial gauge numbered from 1-100. I have a report that has percentages for each month. I want to be able to select a month from a drop-down and have the gauge change to the number for that month. I am trying to pass the values via text file but did nto know if this is the logical way to go or even really where to begin. Any direction is greatly appreciated.

Ronen
02-26-2006, 09:17 AM
if u have a script that generates that report in a txt file, use loadVars
if it generates an xml file use XML object.

is that it?

reyco1
02-26-2006, 11:04 AM
heres a gauge fla I made for ya if you dont have one already. Code is preety simple.

drmazey
02-26-2006, 04:34 PM
I have gone through the .fla file and this is exactly what I am looking for. Thanks much for this.

As for the generation of the data, I can either push the data out to a text file or to a xml file. Is one much better to use than the other?

reyco1
02-26-2006, 07:16 PM
XML is much better dude... Add a combobox component to the fla above and instance name it myList. Then ammend this code:


//load xml data and populate the listbox
var x:XML = new XML();
x.ignoreWhite = true;
x.onLoad = function(success) {
if (success) {
var theItems = this.firstChild.childNodes;
for (q=0; q<theItems.length; q++) {
myList.addItem({label:theItems[q].attributes.person, data:theItems[q].attributes.percentage});
}
var getData:Object = new Object();
getData.change = function() {
theData = myList.selectedItem.data;
needle.rotateTo(theData);
};
myList.addEventListener("change", getData);
}
};
x.load("gauge.xml");


Then place the attached xml file in the same directory as your fla and enjoy :D

drmazey
02-27-2006, 02:04 AM
Ok, the addition of the combo box gave me a basis of how the data is being passed in by selection. Currently the app I am using has its own combo boxes built in and are controlled via javascript. Let say I have a result set of year 2005, with each month having a percent. When the user selects the month, it will also export the data for that row out to an xml file, then the dial will move based on the data in that XML file, so bascially what I want to be able to do is have the gauge without any control, just automatically change based on a single value in the XML file. Is this possible or am going off in the wrong direction? I appreciate all the help on this. Flash is somewhat new to me but am learning it as it seems like possibilites are endless with it.

drmazey
02-27-2006, 02:07 AM
With the needle, is there a way to color it? Say for instance from 0-50 is red, then 51-75 is yellow and 76-100 is green. Is not a need just curious.

reyco1
02-28-2006, 06:20 AM
There is dude. I'm working on the same thing for my company. :D

I'm making a gauge component which does exactly what you are looking for. Once I'm done with it, I will post it here for you.

Im 85% in making an application like "Crystal Xcelsius"

reyco1
03-04-2006, 07:45 PM
Here's that gauge component I promised. Good luck with the rest of your project dude:

http://www.actionscript.org/forums/showthread.php3?t=98865

drmazey
03-19-2006, 02:29 AM
This link did not return anything.

drmazey
03-19-2006, 02:30 AM
Sorry I have been away on some business so have not had a chance to be on here lately.

reyco1
03-29-2006, 04:36 PM
I removed the gauge component. Thinking about going commercial with it. Never the less, If you are interested, I will give it to you. Contact me as soon as you can ;)

I have it pulling data from both xml and excel (.csv format)

drmazey
04-14-2006, 04:29 AM
I would be interested in it. I have a high level of background in graphic so can design some gauges as well if you need them. Going public may be a good idea...you can send Excelsius on their way packing.