Question

Flash Gauges, how do you build them?!?!?

Asked by: LORD_MINION

I am a pretty verse Flash guy and am currently building a program that requires gauges that are like the ones you find in a car. I found this site........http://www.dundas.com which has some .NET/FLASH based gauges for a idea of what I am looking to code. I have the hard part done, I am feeding the data from a MYSQL backend via PHP into FLash which works perfect, now I just need to animate those numbers. I have fooled with the x_scale feature in actionscripting but I can't get it to do anything like a circle gauge OR get it to read anything other then 0-100 as a var. I need to be able to make the gauge read from anywhere from like 0-300 to like 300-500 and 100-10000 and such..........I can hardocde these gauges no problem but they need that kind of range.

Really I'm just looking on HOW to do these I can do the hard part and perfect them into what I need and share it here.

Thanks in advanced!

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2005-03-20 at 20:08:29ID21358129
Tags

flash

,

gauges

Topic

Adobe Flash

Participating Experts
2
Points
400
Comments
24

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. ActionScript text Animation
    www.Lunarmedia.com/home.html is a site that boasts that they have figured out how to use actionscript to animate long strings of text and by the looks of the site they must have. Doing it character by character would be excruciatingly slow. I'm relatively new to flash and d...
  2. Create a flash gauge
    I am a beginner at flash and have been trying to build myself a flash gauge. The gauge is to have a range of 0 to 100 and consist of a dial type display (with numbers around the outside of a circle and a pin/arrow in the middle pointing to the appropriate value i.e. in the ...
  3. Actionscript to close a windowless flash animation
    How do I create a button that will close my flash animation? The animation is windowless and positioned absolutley using DIV tags much like those pesky flash popup ads on some sites. If you could help by telling me which actionscript to use or posting it I would appreciate i...
  4. actionscript animating motion path
    is there a way where i can use actionscript to attach a movieclip to a line drawn with the pen tool on the stage and have it move along the line? i am having some ideas of working on some animations which has a set of movieclips that will move in a irregular motions and i th...
  5. Which is faster - Actionscript Tween or in-flash animation?
    I am working on a new Flash game, and have currently animated the 'peeps' walking using the actionscript Tween class. The movements are stored in an array and executed one after the other. However, performance is a big issue in this game, and I was wondering if it would be l...

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: BillystyxPosted on 2005-03-20 at 23:39:35ID: 13589138

As in a speedometer or tacometer of a car? something like this will make it spin according to a measure - but you need to be able to convert your measurements into 180 + or - to do it. Is it going up and down on the dial or just up, How is this happening, (user, variables from your action script? I would say we need more info on what you have to help:)

onClipEvent(enterFrame){
      
      if(_rotation<xspeed){
      _rotation +=10;
      }
}

Billystyx

 

by: ellandrdPosted on 2005-03-21 at 03:28:58ID: 13590122

Here is the way I would suggest solving your problem, this method realies heavily on ActionScripting so you don't have tons of tweens or additional objects you don't need.

See Demos and source at:
gauge/">http://www.XXdream.com/EE/gauge/

First though you need to solve the math part of this which will make the programming and implementation pretty simple.

So your dial is going to rotate based on a value from 0-100, you need an expression that will convert 0-100 into a valid angle for the needle to point to. For instance if you want to have 0-100 represent a dial that goes from 0 all the way around to 360 degrees you need a simple formula like "angle = value * 3.6" Where angle is the direction to point the needle and value is the text field variable. On the other hand a more realistic gauge could be like the oil gauge in your car which usually point -30 to +30 degrees from vertical, if you wanted to move a needle in a gauge like that you would first find the total range of the needle, in this case it's 60 degrees, so now your formula would be "angle = value * 0.6" resulting in a angle range of 0-60 for value inputs of 0-100. Hopefully now you can see the first part which is converting your values to an appropriate angle range. To keep this part simpler however, I'm going to imagine the needle range is 100 degrees, going from an angle of -50 to 50.

Now to start creating this make a movie clip which is your indicator arrow, make sure the registration point is the spot the needle will rotate around. Set the rotation of the needle in the movie clip to left most point the needle will start from, i.e., 0 on the gauge, in this case I'm using -50 degree rotation. It's very important you rotate the needle in the movie clip and that you do not rotate the actual movie clip.

Now in your movie clip make another layer on top of your art for the actions. In the first frame you will need the following actions:
If (/:value > _rotation)
      Set Variable: "angle" = (/:value - _rotation) * .2 + _rotation + 1
      Set Property ("", Rotation) = Int(angle)
Else If (/:value < _rotation - 1)
      Set Variable: "angle" = _rotation - ((_rotation - /:value) * .2) - 1
      Set Property ("", Rotation) = Int(angle)
End If

In the second frame you just need one action:
Go to and Play (1)


The basis of what is going is that the script calculates how far it has to go and than applies a fraction of that to the current angle. I've made samples available for download and viewing at:
gauge/">http://www.XXdream.com/EE/gauge/

needle1 uses the above method with a angle range of 100 and accelerated movement based on distance.

needle2 uses a 180 degree range and linear movement.

Both set a variable in the main timeline called value to a random number between 0-100 to test the movement. It is very important that you uses a variable text field called value in your main timeline in order for the gauge to respond.

 

by: ellandrdPosted on 2005-03-21 at 03:31:15ID: 13590133

here is a question asked before...

http://www.experts-exchange.com/Web/WebDevSoftware/Flash/Q_21205075.html?query=Flash+Gauge&clearTAFilter=true

might give you some guide to your problem

Sean

 

by: LORD_MINIONPosted on 2005-03-24 at 18:41:55ID: 13627566

Thank you for the reply, I have been busy so havn't been able to respond. I tried that site listed above and it doesn't seem to resolve. If I could see the example I think it may help me more. You can email me it at spam at ipforge dot com.

Also does this only work in Flash 7?

 

by: LORD_MINIONPosted on 2005-03-24 at 19:23:12ID: 13627727

I have tried this over and over with no such luck, I think seeing the fla will help me greatly.

Thanks again for all your help and I look forward to hearing from you!!

 

by: LORD_MINIONPosted on 2005-03-28 at 18:10:28ID: 13648898

Anyone else care to take a crack at this.........maybe something that was written in Flash MX or MX2004 and not from the flash 4 days?

Points increased to 400!!!

 

by: BillystyxPosted on 2005-03-28 at 22:44:01ID: 13650051

What problems did you have with ellandrd code?
And what have you got? IE how far have you got?
If you can post your fla we canmaybe take a look and fix it/manipulate it.

Billystyx

 

by: LORD_MINIONPosted on 2005-03-29 at 06:43:29ID: 13652661

Well I can't post the code since it's at home right now, but it's what he said to do and it doesn't work. I know this code was written in mid-2000 so I'm wondering if Flash 7 is having a problem with it. I play the movie and the needle never moves when I feed it diffrent values. I put a input text field on the page that holds the value which I type in and it should change but it doesn't. I even tried it his way and set the values within the script and it still doesn't work. A posted working .fla of this would really be helpful since I can't seem to get it to work even when I just try to mess with the _rotation property. Thanks guys!

 

by: BillystyxPosted on 2005-03-29 at 06:55:28ID: 13652774

I don't have one of those, but if you post yours I will be happy to try to fix it:) I cannot do it until this evening either - so I am happy to wait.

Billystyx

 

by: LORD_MINIONPosted on 2005-04-04 at 19:40:19ID: 13703735

I have messed with this for a few day now, still not getting it. I can't ever seem to get ANYTHING to rotate. What I have posted is very simple. I am taking a dynamic text field.........assigning it a var so I can type in the angle I want........then it will display that var, then it's suppose to turn the needle movie that many degrees off it's starting point. It does not...........enjoy the madness.........please help, if I get the desired result I'll double the points!

http://ipforge.ath.cx/RWX/needle.zip

 

by: BillystyxPosted on 2005-04-04 at 23:33:01ID: 13704497

try this one to get you started:)
http://members.lycos.co.uk/billystyx/download.htm

top left corner of htm is a link controler 2, this has several example files - yours is needle1

Billystyx

 

by: LORD_MINIONPosted on 2005-04-05 at 06:35:35ID: 13706921

Hmmm ok finally getting movment so that is good :) However it just spins in a circle. I need to be able to set a range, and have it go to that degree and stop. You know like a gauge in your car. I will be playing around wtih this tonight........lets keep on it. Thank you for your help so far, look forward to hearing more responces.

 

by: BillystyxPosted on 2005-04-05 at 06:52:16ID: 13707091

instead of _rotation -=var1;
do
if(_rotation!=var1){
_rotation +=1;
}

so it goes there and stops

then your next step to figure out is how to convert that to some rotation vs speed, vs where on the dial type thing. But I would say that was up to you to figure out:)

I/we can help with the details - like how to make flash do things, you need to come up with the inspiration!

Billystyx

 

by: LORD_MINIONPosted on 2005-04-05 at 08:05:31ID: 13707970

I have no problem with inspiration, I do that through making this program look and function easily. As in the coding aspect it's little difficult to go against what it must be to work. I am however messing with this code from here also along with what you have shown me so far......

http://www.experts-exchange.com/Web/WebDevSoftware/Flash/Q_21205075.html?query=Flash+Gauge&clearTAFilter=true

However I am rotating the whole movie and not just the needle.......any suggestions?

Also when you say........

instead of _rotation -=var1;
do
if(_rotation!=var1){
_rotation +=1;
}

I'm sure exactly what you mean.........I do understand however the code.........which I believe is flawed.........since the gauge will be in constant motion since it's set to +1 when not equal to var1. Playing with this now......suggestions welcome!

 

by: LORD_MINIONPosted on 2005-04-05 at 08:13:48ID: 13708070

Update.......

if (NEEDLE._rotation>var1) {
      _rotation += 1;
} else if (NEEDLE._rotation<var1) {
      _rotation -= 1;
}

I wrote this and it works fine however I'm still rotating the whole movie........anyhelp on how to get it to target just the needle?

 

by: BillystyxPosted on 2005-04-05 at 08:17:34ID: 13708114

do NEEDLE._rotation +=1;
unless the code is in the needle clip.

Sorry, I can't remember (it was all that time ago - last night or something).

This will rotate the needle anyway, referencing it with NEEDLE._rotation rather than just _rotation

Billystyx

 

by: BillystyxPosted on 2005-04-05 at 08:21:24ID: 13708157

With the code I supplied above it was with the intention that you set the value of var1, and then the needle spins until it reaches that var1 value.
Thus you would need only to set a calculation  that coverts a text field value (like 100 as in mph), to covert it to a rotation value where 100 might be = approx 30 on the dial...
Do you see what I mean?

Billystyx

If still no luck tonight and I have time I will try to create a dial as an example

 

by: LORD_MINIONPosted on 2005-04-05 at 08:30:26ID: 13708250

Yea I am not worried about the math part to much, I have read the _rotation function works on a -180 to 180 degree method........I can figure out a equation for this no prob. It's the rotating of the whole movie vs just the needle part I'm fighting now. I think I am just not correctly targeting the needle movie somehow. I have tried to put the code in the needle clip also and it does not work. I think it may be because the value var1 is not referenced correctly down to the root stage or whatever that is called. Still toying with this now.......if you get a functioning gauge please do post it, I learn best from seeing the code in action then modifing it accordingly. Trust me......I have ALOT to modify!! ;) Thanks again for your help so far, let me know what you come up with and I'll do the same.

 

by: BillystyxPosted on 2005-04-05 at 08:34:54ID: 13708302

no worries - can you post your up to date file and I will pick it up tonight:)

 

by: BillystyxPosted on 2005-04-05 at 15:20:45ID: 13712278

ok look here-

http://members.lycos.co.uk/billystyx/download.htm

top left corner of htm page controler 2

clickon that - there are severalflas in 1 zip file but yours is needle3

Billystyx

you type in the text field a number between 1 and 110 and the speedo moves up, take it out and it moves back down to 0. Far from perfect but hopefully enough to work with - good luck with it. (the lines aren't marked properly - sort of like a speedo in an old car:)

 

 

by: LORD_MINIONPosted on 2005-04-05 at 19:42:49ID: 13713444

if (var1>NEEDLE._rotation) {
        angle=(var1 - NEEDLE._rotation)*.2+NEEDLE._rotation+1;
        this.NEEDLE._rotation=int(angle);
} else if (var1<NEEDLE._rotation - 1) {
        angle=NEEDLE._rotation-(( NEEDLE._rotation-var1)*.2)-1;
        this.NEEDLE._rotation=int(angle);
}

This ended up working, I was just mistargeting my movie. Now I just need to figure out the math part. Billy you get the points for your help........if you'd like to continue to help with the math part please do.

Here is the new problem..........the gauge is set up to rotate from -180 to +180. So say i need a range f a gauge to be 100 to 320? What would be the correct math to be able to transverse from neg to piositive and fit in that range?

 

by: LORD_MINIONPosted on 2005-04-05 at 20:16:39ID: 13713569

Also think about a gauge that may go from say 100 to 3000...........

 

by: BillystyxPosted on 2005-04-06 at 00:51:06ID: 13714549

Using the method I gave I just converted the number of degrees of rotation into rotation=speed*3 - because if speed was 10 mutliplied by 3 would be 30 degrees of rotation, based on dial from 0 to 110, this left a gap of 30 degrees as there is (approx) on a usual speedo, between the 0 mark and the 110 mark.

So same would be applicable for a dial from 100 to 320 - the marks are not so important as how far around the needle is pointing according to the speed you choose.

Maths, however, is not my strongest point - I find math sites more helpful whenever doing stuff like this than actual flash/programming related sites...

but, if I calculated mine by going I want the speedo to go to 120 (when allowing for the whole circle), then if you want a range of 220 (from 100 to 320), then you go 360/220 which gives 1.636 as the number to multiple your var1 by.
like this:
(var1-100)*1.63636363636= degrees rotation

hope this helps a bit:)

Billystyx

 

by: LORD_MINIONPosted on 2005-04-06 at 06:20:29ID: 13716381

Ok no worries I'll find out a equation.........the issue it it's not /360.........the rotation is based on a -180 to 180 degree range.........this is where it gets complicated.

Thanks anyway Billy!

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...