Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    Flash








Date Calculation


Was wondering if anyone knew and equation to calculate the weeks of the year. That could be done in flash.

I am creating a front end for a data base system, and well I want to display the weeks.

Thx.




FlashKit > Flash Help > Flash General Help
Posted on: 04-29-2003, 08:53 AM


View Complete Forum Thread with Replies

Sponsored Links:

Date Calculation
Hello,

I searched through the forums and couldn't find exactly what im looking for. Basically i have a Trivia flash movie that changes the trivia each day. I have 365 trivia questions set up and need to be able to calculate what number day it is of the year. Using typical date functions only gives me the day of the month and i need it on a 365 day basis.....so i can change the trivia for a year without it repeating.

Thanks in advance,

Chris

View Replies !    View Related
Date Calculation
Hello,
I need some help!
I need to subtract two dates from each other and come up with a numeric value that will be used in another calculation.
For example:
070107 - 06/28/07 = 4 days
I've looked for conversion to julian date and actionscript and have not had any luck.

Thank you for any help you can provide.
Text

View Replies !    View Related
Date Calculation
Hello,
I have a basic question regarding calculating the difference between two days.

The user will enter two dates in input text fields and I need to calculate the number of days difference between them.

For example a user may enter 092307 as the from date and 092607 as the to date. I need to have the number display as the number of days between them.

Thank you for any assistance you can provide.

View Replies !    View Related
Date How Can I Calculation Two Different Dates Using DateField Component ?
Hi,
I have 2 dateFields and I want to be able to select dates from them and get an answer, of how many days difference there are ?
I can do this without using the dateField.
The code I have for first dateField is :


var dcListener:Object = new Object();
dcListener.change = function(evt_obj:Object) {
var SelectDateate = evt_obj.target.selectedDate;

//BELOW Selects date from DateField Component
var date_str = (SelectDate.getDate()+(SelectDate.getMonth()+1)+Se lectDate.getFullYear());

var minutes = 1000 * 60;
var hours = minutes * 60;
var days = hours * 24;
var today_dateate = new Date();
//Calculate today_date into No. of days
var dnewer = (today_date/days);
//Calculate selected DateField into No. of days
var datefield = date_str/days;
//Calculate difference in days
var caldatefield = (dnewer-datefield);
//Place selected Date, from Datefield into Text box SelectDF_txt
SelectDF_txt.htmlText = true;
SelectDF_txt.htmlText = date_str ;

//Place Calculated Date, into Text box DiffDatefield_txt
DiffDatefield_txt.htmlText = true;
DiffDatefield_txt.htmlText = caldatefield ;
}
dateBoxH_ca.addEventListener("change", dcListener);

The second dateField is similar to above.

Thanks,
Paul

View Replies !    View Related
Date Calculation From A Given Date
Hi all!

Anyone can help me please, how too build a function that:

user insert a date: "20/05/2005"
and the system return me the given date + 7 days, so : "27/05/2005"

Thanks.

View Replies !    View Related
Calculation Expiration Date Based On Number Of Months
Hi, in need of some help, I know how to get the current date, but I'm working on an app by which user accounts expire based on payment options, semiannualy, annually for example. How would I go about this. Like if a user registers and account on December 12, 2004, how can I accurately calculate the date 3,6,12,24 months from then. Thanks alot

View Replies !    View Related
Display Future Date (seven Days From Today's Current Date)
I understand how to display today's current date, but how would I display the date seven days from now? For example, if today's date is 4/29/2003, I want to display 5/5/2003.

Anyone done this before?

Thanks in advance.

Scott

View Replies !    View Related
Convert RSS2 Date Format To Flash Date() Object
How can I take an RFC 822 (RSS 2) formatted string, and read it into a Flash MX Date() object. Flash does'nt like the format.

I have a function that will break the string apart the long way but is there an easier way to accomplish this - I can't believe flash would'nt have it built in like .NET or ColdFusion.

Thanks!

Aaron

View Replies !    View Related
Date Specific Content/dynamic Text/Get Date
Hello,
I am trying to build a page where there is Date specific content, i.e. after a certain date the information becomes obsolete and will need to be replaced with new information.
Does anyone have any idea how I can go about doing this?
Thanks,
Kris

View Replies !    View Related
Comapreing A Datefield Selected Date To Current Date
i have a made a small swf which checks the seleted date on the datefield component is passed current date or not...

i have a function get the day associated with it...

stop();
function getDayName(num) {
switch (num) {
case 0 :
return "Sunday";
break;
case 1 :
return "Monday";
break;
case 2 :
return "Tuesday";
break;
case 3 :
return "Wednesday";
break;
case 4 :
return "Thursday";
break;
case 5 :
return "Friday";
break;
case 6 :
return "Saturday";
break;
}
}
today = new Date();
today = getDayName(today.getDay())+" "+today.getMonth()+" "+today.getDate()+" 00:00:00 GMT+06000 "+today.getFullYear();

on relese event of the button...

dateField is named - arr_date

on (release) {

_global.selday = _root.arr_date.selectedDate;


_global.selday2 = getDayName(_global.selday.getDay())+" "+_global.selday.getMonth()+" "+_global.selday.getDate()+" 00:00:00 GMT+06000 "+_global.selday.getFullYear();

res = (selday2<today);
_root.dis = res;
}

the thing is sometimes res says "TRUE" for future dates also.

download fla here
can anyone help on this.

Thanks

View Replies !    View Related
Display Date And Day With Computing Three Days From The Date With Certain Restriction
Hi

i have a code that display date and day from your local machine.
Here it is:
================================================== ===========
function howlong(arg) {
if (length(arg) == 1) {
arg = "0"+arg;
return arg;
} else {
arg = arg;
return arg;
}
}
myDate = new Date();
//hr = howlong(String(myDate.getHours()));
//mnt = howlong(String(myDate.getMinutes()));
daytext = myDate.getDay();
//daytext = daytext+3;
dd = myDate.getDate();
//dd = dd+3;
mm = myDate.getMonth();
//yyyy = myDate.getFullYear();
switch (daytext) {
case 0 :
daytext = "Sunday";
break;
case 1 :
daytext = "Monday";
break;
case 2 :
daytext = "Tuesday";
break;
case 3 :
daytext = "Wednesday";
break;
case 4 :
daytext = "Thursday";
break;
case 5 :
daytext = "Friday";
break;
case 6 :
daytext = "Saturday";
break;
}

switch (mm) {
case 0 :
mm = "Jan";
break;
case 1 :
mm = "Feb";
break;
case 2 :
mm = "Mar";
break;
case 3 :
mm = "Apr";
break;
case 4 :
mm = "May";
break;
case 5 :
mm = "Jun";
break;
case 6 :
mm = "Jul";
break;
case 7 :
mm = "Aug";
break;
case 8 :
mm = "Sep";
break;
case 9 :
mm = "Oct";
break;
case 10 :
mm = "Nov";
break;
case 11 :
mm = "Dec";
break;
}

textdate = (daytext+", "+mm+". "+dd+".");
================================================== ===========

Now problem is it should compute three days from that date with certain restrictions like (dont count Saturday and Sunday, Dec 25th, Nov, 22nd, Jan 1st)...

I have to display the date based on the above rules..

plz help

Thanks
maxarindam

View Replies !    View Related
Converting A Date Serial Number To A Real Date
I'm reading dates from Excel and I get this type of serial number : 37477. It's actually the number of days since 1-1-1900. Is there a function to convert that directly into a date in Flash ?
Thanks,

View Replies !    View Related
DATE() Reads Date From Server Or User?
2 questions about DATE() function:

1º The value is taken from the date setted on the server or the user machine?

2º How do i break apart the value to check each value? I mean, day, month, etc.

Im working on a quiz that has to display a different question every 15 days. Im loading them from a TXT. I´m missing that part of the code.

Thanks for any help.

View Replies !    View Related
Flash MX: Date To String And Back To Date
Greetings,

Im struggling to (a date which is converted to a string to format date as mm/dd/yyyy hh:mm:ss") transform the string textDate into a Date?

Im looking at mxateFormatter but I dont understand how it works
Any advice and guidance would be appreciated.

Cheers
Rob W



Code:
displaydate = new Date();
var day = displaydate.getDate()>9 ? displaydate.getDate() : "0"+displaydate.getDate();
var month = displaydate.getMonth()+1;
var years = displaydate.getFullYear();

if (month <9)
{
var month = "0"+month;
}

displaydate = (month + "/" + day + "/" + years);

timedisplay = new Date();
var hours = timedisplay.getHours()>9 ? timedisplay.getHours() : "0"+timedisplay.getHours();
var minutes = timedisplay.getMinutes()>9 ? timedisplay.getMinutes() : "0"+timedisplay.getMinutes();
var seconds = timedisplay.getSeconds()>9 ? timedisplay.getSeconds() : "0"+timedisplay.getSeconds();
timedisplay = (hours + ":" + minutes + ":" + seconds);

_root.textDate = (displaydate + " " + timedisplay)

View Replies !    View Related
Bad Data From Date.getDay() And Date.getMonth()
I am trying to utilize the Date class to retrieve the current date, and populate fields for each date part. However, the day and month returned from either the day/month properties or the getDay()/getMonth() methods are incorrect: today is 4/11/2008, yet I get back a month of 3 and a day of 5!

Here is the relevant code:

var curDate:Date=new Date();
NewProjectStartMonthField.text=String(curDate.getMonth());
NewProjectStartDayField.text=String(curDate.getDay());
NewProjectStartYearField.text=String(curDate.fullYear);

View Replies !    View Related
Figuring Out A Previous Date With Date Class
I have a need to allow people to choose a date range in my application. I can't figure out how to format a dat that is say 30 days prior to today.


For instance:

var Today_Date = new Date();
var Proior_Date = Toay_Date - newDate(30);

View Replies !    View Related
Comparing Current Date With Date String
Im loading in a date from a database and storing it in a string called dateToCheck. The dates I am loading in from my datebase could be anything so I want to check if its past, present or future but as its a string and not a date when I compare to the current date it doesn't seem to work.

Im storing the current date in actions script like this


var today_dateate = new Date();
var date_str:String = (today_date.getDate()+"/"+(today_date.getMonth()+1)+"/"+today_date.getFullYear());


Do I need to convert the value date value Im loading from my database into a proper date before I can check it agains the current date? If so is there any easy way of doing it.

Thanks

View Replies !    View Related
Posting The Date <--- NOT GETTING DATE FROM SYSTEM -->
Anyway to make a button post the date that it was pressed on. Like lets say I have an update news button. when someone updates it I want it to replace a variable with the current date, and NOT updating it as the movie is playing but posting the date that the button was pressed.

View Replies !    View Related
If Start Date Is Greater Then End Date>>?
Hello,

Lets say a user enters in a start date of 5/22/2002 and enters in a end date of 4/22/2002. I need Flash to give me an error message letting the user know that the date is not right.


Any ideas??

Thanks

View Replies !    View Related
Date Generation Without Using Date Function
I'm writing a program for a rental company. The code will
allow the user to select a date from a gui, enter the
number of days that the user will stay, and generate a
departure date. The script works in some cases but not
others. You can view this work in progress at:

http://tripdogs.com/two

as this work is not complete, some explanation as to
how to execute program:

select month and date
click "click to verify date"
click "check availability"
click "1" other buttons not functional
enter "enter # of nights"
click "Select"

The program gets the date right sometimes, sometimes not.
Any help would be much appreciated.
Thanks in advance, Ron Sullivan <bigal@adelphia.net>

The code is on the select button (I've pasted it below):

on (release) {
nextFrame ();
property = "Breakers"+" Villa";
view = "Ocean"+" View" ;
normalRate = "$"+200.00;
internetRate = "$"+"160.00";
saving = "$"+nights*40+".00";
total = "$"+nights*160+".00";
departureDate = Number(_level0.days.ad)+Number(nights);
if (_level0.Select_md.am=="Jan") {
y = "31";
if (Number(_level0.days.ad)+Number(departureDate)>y) {
departureMonth = "Feb";
departureDate = (Number(_level0.days.ad)+Number(nights))-31;
} else {
departureMonth = "Jan";
}
} else if (_level0.Select_md.am=="Feb") {
y = "28";
if (Number(_level0.days.ad)+Number(departureDate)>y) {
departureMonth = "Mar";
departureDate = (Number(_level0.days.ad)+Number(nights))-28;
} else {
departureMonth = "Feb";
}
} else if (_level0.Select_md.am=="Mar") {
y = "31";
if (Number(_level0.days.ad)+Number(departureDate)>y) {
departureMonth = "Apr";
departureDate = (Number(_level0.days.ad)+Number(nights))-31;
} else {
departureMonth = "Mar";
}
} else if (_level0.Select_md.am=="Apr") {
y = "30";
if (Number(_level0.days.ad)+Number(departureDate)>y) {
departureMonth = "May";
departureDate = (Number(_level0.days.ad)+Number(nights))-30;
} else {
departureMonth = "Apr";
}
} else if (_level0.Select_md.am=="May") {
y = "31";
if (Number(_level0.days.ad)+Number(departureDate)>y) {
departureMonth = "Jun";
departureDate = (Number(_level0.days.ad)+Number(nights))-30;
} else {
departureMonth = "May";
}
} else if (_level0.Select_md.am=="Jun") {
y = "30";
if (Number(_level0.days.ad)+Number(departureDate)>y) {
departureMonth = "Jul";
departureDate = (Number(_level0.days.ad)+Number(nights))-30;
} else {
departureMonth = "Jun";
}
} else if (_level0.Select_md.am=="Jul") {
y = "31";
if (Number(_level0.days.ad)+Number(departureDate)>y) {
departureMonth = "Aug";
departureDate = (Number(_level0.days.ad)+Number(nights))-31;
} else {
departureMonth = "Jul";
}
} else if (_level0.Select_md.am=="Aug") {
y = "31";
if (Number(_level0.days.ad)+Number(departureDate)>y) {
departureMonth = "Sep";
departureDate = (Number(_level0.days.ad)+Number(nights))-31;
} else {
departureMonth = "Aug";
}
} else if (_level0.Select_md.am=="Sep") {
y = "30";
if (Number(_level0.days.ad)+Number(departureDate)>y) {
departureMonth = "Oct";
departureDate = (Number(_level0.days.ad)+Number(nights))-30;
} else {
departureMonth = "Sep";
}
} else if (_level0.Select_md.am=="Oct") {
y = "31";
if (Number(_level0.days.ad)+Number(departureDate)>y) {
departureMonth = "Nov";
departureDate = (Number(_level0.days.ad)+Number(nights))-31;
} else {
departureMonth = "Oct";
}
} else if (_level0.Select_md.am=="Nov") {
y = "30";
if (Number(_level0.days.ad)+Number(departureDate)>y) {
departureMonth = "Dec";
departureDate = (Number(_level0.days.ad)+Number(nights))-30;
} else {
departureMonth = "Nov";
}
} else if (_level0.Select_md.am=="Dec") {
y = "31";
if (Number(_level0.days.ad)+Number(departureDate)>y) {
departureMonth = "Jan";
departureDate = (Number(_level0.days.ad)+Number(nights))-31;
} else {
departureMonth = "Dec";
}
}
}

View Replies !    View Related
Date Math In Date Object?
This seems like an easy question, which i'm sure has an easy answer. How do i do math with days?

ex:
today + 4 = 11/20/2002 (4 days from today)

Seems easy enough but can't find any example of it

View Replies !    View Related
DateChooser Start Date End Date
Hello everyone!
i am new to this forum and this type of scripting. I self taught myself PHP and now i am trying to teach myself Flex 2. I am trying to create a datechooser that takes the first date that is clicked and make all dates before that first date disabled.
I figure i can accomplish this by datechooser.disableranges is equal to the date they just clicked.
then as they click the second date send both the dates to a PHP file.

Any tutorials or script that i can backwards decompile to help figure this out is appreciated. I have tried searching for weeks on tutorials and such but have came across nothing.

View Replies !    View Related
Date Chooser Day And Date Not Selectable
Hello,
Anyone knows how to make the day and date not selectable in the datefield or date chooser component???

It is possible to make any one day not available, but what i need is only a single day not selectable..

For example, i can make every tuesdays of a month not selectable But, i need to make for example the Tuesday 3rd only Not selectable

Any help will be greatly appreciated.
Cordially.
Gerard.

View Replies !    View Related
Flash Date And Oracle Date
Is it possible to convert a date being retrieved from an oracle database to the flash Date format in flash so that the different Actionscript date functions can be applied to the retrieved date.

View Replies !    View Related
Countdown To Date, Loading Date From Txt
Hey everyone,

I'm working on a Flash movie to countdown to a certain date, and I am wanting to assign that date in a .txt file so it is easy to change the date without modifying the FLA.

Here's the ActionScript I have for finding the date it's counting down to from the .txt file:

loadText = new loadVars();
loadText.load("date.txt");
loadText.onLoad = function() {
eventDate = new Date(this.year, this.month, this.day);
};

And the date.txt file has this in it:

year=2003&month=12&day=25


It doesn't seem to be working :- .

Any help would be awesome .

-Nick

View Replies !    View Related
Countdown To Date, Loading Date From Txt
Hey everyone,

I'm working on a Flash movie to countdown to a certain date, and I am wanting to assign that date in a .txt file so it is easy to change the date without modifying the FLA.

Here's the ActionScript I have for finding the date it's counting down to from the .txt file:

loadText = new loadVars();
loadText.load("date.txt");
loadText.onLoad = function() {
eventDate = new Date(this.year, this.month, this.day);
};

And the date.txt file has this in it:

year=2003&month=12&day=25


It doesn't seem to be working :- .

Any help would be awesome .

-Nick

View Replies !    View Related
3d Calculation
http://www.nlc.net.au/~oceana/3d/3d.htm
On the webpage are 2 graphics which explain my question (I'm not so sure about figure 2). I need two equations;
-----------------------------------------------------------
Figure 1. I want to derive (x3,y3 - the point at which the line intersects with the plane) from the other co-ordinates (x1,y1,z1),(x2,y2,z2),(x4,y4,z4),(x5,y5,z5),(x6,y6 ,z6),(x7,y7,z7)
-----------------------------------------------------------
Figure 2. Rotating a point: I want to derive (x2,y2,z2) from (x1,y1,z1), a1, a2
-----------------------------------------------------------
First and formost, i'm stupid.
I've looked at the 3d tutorials and movies and again...i'm stupid.
-----------------------------------------------------------
If anyone could give me these 2 equations, USING THE VARIABLES THAT I HAVE GIVEN, you would be single handedly responsible for unleashing the worlds stupidest flash coder into the world of 3d.
Finally, i'm stupid... should have paid more attention in school.
Any help is greatly appreciated, thanks!
BlinkOk (posted in games/actionscript/3d)

View Replies !    View Related
MMP Calculation
I have a problem, In flash MX i have 120 pic and a few textboxes. what i need to do is get the values from the textboxes devide them by 120 odd numbers. So far so good
The problem i have is that i cant figure out how i can take the returned quotients and sort them so i get the highest 120 and still know from which text box they came from.
Can Anyone help.

View Replies !    View Related
Calculation
Hi, very newbie here.
I need to build a calculation.
Where X times Y% equals total. ( X xY%=? )
I need a separate box for each number.
Does anyone have any ideas for this or could point
me to a tutorial about it?
It's just a little ditty for my home web site.
Thanks in advance
frobby

View Replies !    View Related
Calculation Help
I'm making a volumetric converter for a site and with a bit of help from Fkit I've figured out the basics. However it gives the answer to lots of decimal places. How do I make it give the answer to one decimal place, please?

View Replies !    View Related
AS Calculation
I need to determine the number of pages of my catalog in order to make them visible or not.
- Every page contains 6 items, so If myCatID_A contains 12 items :
THEN this will give 6/12 = 2 pages (good !!).
- But if my CatID_B contains 13 I'll have 13/6 = 2.166666666666 !!!! How to tell to A.S that he need to count 3 pages instead of 2.xxxx ???

Thank you,

View Replies !    View Related
Calculation
I cannot get to make an item (veg1) turn into a value ($1.99). when I click on the squares on the left, a name appears in each text box. Then I need to input an integer. By pressing total_btn, it should calculate all the sub1_txt + ...+ sub4_txt.
Kindly advise how to make it to work.

View Replies !    View Related
Help On Simple Calculation
Hi everyone.
I know what I am asking is a very simple thing.Its simple calculation.
But I am just not able to figure it out. Please help.
What i want to do is make a simple calculation on some question like

How old are you
i.under 15 we will award him 4 points
ii.15 to 30 we will award him 3 points
iii.30 to 50 we will award him 2 points
iv.50 plus we will award him 1 point
How much do you weigh
______ kgs
What is your height
______ cms
Ideal body weight in kilos is your height in centimeters minus 100. So if you are 175 centimeters tall, you can be up to 75 kilos. Your ideal weight range would be between 72.5 – 77.5 Kilos.
Users within the weight range get 5 points
Users 1 – 5 kilos above or below rangeget 4 points
Users 6 – 10 kilos above or below range get 3 points
Users 11 – 15 kilos above or below range get 0 points
Users 16+ kilos above or below range get -10 points

The maximum score that a user can get is 9. That is for users who are under 15, within their weight range.

I want to know how would I calculate the weightage and the different varitions in weight ranges.
I am also attaching the FLA.
Kindly help please

View Replies !    View Related
Pause In Calculation?
Hello,
I've made a flash to calculate some numbers.
There are lots of calculations to be done in the press of one button but for some reason the correct end result is not reached unless i press the calculate button twice.
Here is my code...

function onCalculate() {
one = Number(Head);
two = Number(Forequarter);
three = Number (Hindquarter);
four = Number (Gait);
five = Number (ntb);
six = Number (coat);
seven = Number (size);
eight = Number (temperament);
nine = Number (showshine);
ten = Number (feet);
eleven = Number (headsop);
twelve = Number (forequartersop);
thirteen = Number (hindquartersop);
fourteen = Number (gaitsop);
fifteen = Number (ntbsop);
sixteen = Number (coatsop);
seventeen = Number (sizesop);
eighteen = Number (tempermentsop);
nineteen = Number (generalsop);
twenty = Number (feetsop);
twentyone = Number (headsoptotal);
twentytwo = Number (forequartersoptotal);
twentythree = Number (hindquartersoptotal);
twentyfour = Number (gaitsoptotal);
twentyfive = Number (ntbsoptotal);
twentysix = Number (coatsoptotal);
twentyseven = Number (sizesoptotal);
twentyeight = Number (temperamentsoptotal);
twentynine = Number (generalsoptotal);
thirty = Number (feetsoptotal);
headsoptotal = one*headsop;
forequartersoptotal = two*forequartersop;
hindquartersoptotal = three*hindquartersop;
gaitsoptotal = four*gaitsop;
ntbsoptotal = five*ntbsop;
coatsoptotal = six*coatsop;
sizesoptotal = seven*sizesop;
tempsstotal = generalsoptotal*temperamentsop;
generalsoptotal = (eight+(nine/2))/2;
feetsoptotal = ten*feetsop;
sum = headsoptotal + forequartersoptotal + hindquartersoptotal + gaitsoptotal + ntbsoptotal + coatsoptotal + sizesoptotal + tempsstotal + feetsoptotal;
total = sum*10;

}

I think it has something to do with the caculations in the bold line,
tempsstotal = generalsoptotal*temperamentsop;
I just want to be able to press a 'calculate' button once and for the program to work it all out in one go any idea's anyone?

Thanks in advance
Ady

p.s dont laugh at my code, i'm very new to this!

View Replies !    View Related
MX Simple Calculation Help
I want to make a simple calculation tool, but I have no idea where to start. It looks pretty simple as I am sure it is not that hard to make.

All I need to do is have an imput box where someone can put in a number the have it auto multiply that number by .30. Then take that # and multiply it by 12

here is an image incase I didn not explain it well

View Replies !    View Related
183 Days Calculation
I’m new so I’m Justin. In my epic battle between a Lotus Notes developer and my attempt to transition to HTML and Flash I have ran into a problem. In our current database (in Lotus Notes) there is a 183 day calculator for someone who tested. You put in their test date and get the date they can retest. Is it possible to do the same in flash? Could someone show me how please?

View Replies !    View Related
Calculation Question
i have some drag and drop object. how can i give them some value etc(cost, engery they used)??? and then do a calculation to between them?

View Replies !    View Related
Simple Calculation (anyone Know How)
I have price * amount = total

amount is an input box

so the user can input any amount they require

press a button and it will work out the total

CalculatePrice = function (answer) {
P = Price;
A = Amount;
the_total = P*A;
return the_total;
};
submit.onRelease = function() {
text_answer = CalculatePrice(the_total);
};

The above works

got that work working but i need lots of these, now am a bit stuck here is the code that does not work:


CalculatePrice = function (answer) {
P = Price;
A = Amount;
P1 = Price1;
A1 = Amount1;
the_total = P*A;
the_total1 = P1*A1;
return the_total , the_total1;
};
submit.onRelease = function() {
text_answer = CalculatePrice(the_total);
text_answer1 = CalculatePrice(the_total1);
};

As you can see I have more than one total to work out, does anyone know how to do this? if so please let me know.

I have also attached the .fla

View Replies !    View Related
Flash Calculation
I have 4 digital display components with instance names mat, oat, rat and %oa
I’m trying to write a flash calculation that computes mat and displays the result

My formula is mat = (oat-rat)(%oa) + rat

The operator would input the outside temperature (example 85)
Then they would input the return air temperature (example 72)
Then they would input the percent outside air (example 10% or .1)
Then the operator would press a button and the values would be plugged into the equation and computed and the answer displayed on the mat display

Mat=(85-72)(.1)+ 72

Mat = 73.3


Variables are:
Mat is mixed air temperature
Oat is outside air temperature
rat is return air temperature
%oa is percent outside air

curTemp1 = mat.val; this reads the value of the display
curTemp2 = oat.val; this reads the value of the display
curTemp3 = rat.val; this reads the value of the display
curTemp4 = %oa.val; this reads the value of the display


how would I write the code for this

View Replies !    View Related
Flash Calculation
I have 4 digital display components with instance names mat, oat, rat and %oa
I’m trying to write a flash calculation that computes mat and displays the result

My formula is mat = (oat-rat)(%oa) + rat

The operator would input the outside temperature (example 85)
Then they would input the return air temperature (example 72)
Then they would input the percent outside air (example 10% or .1)
Then the operator would press a button and the values would be plugged into the equation and computed and the answer displayed on the mat display

Mat=(85-72)(.1)+ 72

Mat = 73.3


Variables are:
Mat is mixed air temperature
Oat is outside air temperature
rat is return air temperature
%oa is percent outside air

curTemp1 = mat.val; this reads the value of the display
curTemp2 = oat.val; this reads the value of the display
curTemp3 = rat.val; this reads the value of the display
curTemp4 = %oa.val; this reads the value of the display


how would I write the code for this

View Replies !    View Related
Simple Calculation
I'm trying to do a simple calculation but I'd really like the answer to round to the nearest 2 decimal places. It is a financial calculator. I don't know much actionscript...

Any help is greatly appreciated!

----------------------------

function onCalculate() {
one = Number(number_one);
two = Number(number_two);
result_sum = one + 15 + 50;
result_product = result_sum * 1.1;
}

View Replies !    View Related
Question Abt Calculation
i got few mc which is dragable. how do i give them some value and do calculation on them??

View Replies !    View Related
Calculation Help Needed
Hi There,

I'm a bit new to actionscripting. I'm creating a calculator in flash, basicly recreating something that was created in excel. My questions is, is there any tutorials or any sample code that someone could point me to where I can learn from. I'm basicly looking to have a user enter data into about 12 text input information and then after that execute calculations based on the inputed information.

Thanks in advance for any help.

View Replies !    View Related
Calculation Help Needed
I've built a calculator in flash and I can't get the function to calculate. Is there anyone that might be able to chat with me to figure this out? My aim is spectsteve7.

Thanks in advance.

View Replies !    View Related
Reverse Calculation
Okay, I'm going to ask someone a huge favour..
I have been working with this all day but cant seem to figure it out..
Math problem again

anyway, I have a function that calculates y based on a property called Y, and some other variables as well, like z, in order to get the perspective-view I want for my game.

and in my editor i've made, I have what you could call a reversed version of that function. it calculates the Y based on y, so I could click the mouse somewhere and it would place it at the right Y in gamespace.

At first this was easy to do, when the calculation looked something like this.

ActionScript Code:
y= horizon+Y*z+z/10;
then the reversed function would look like this.

ActionScript Code:
Y= (y-horizon-z/10)/z;

that's pretty simple, altough I admit that does confuse me a bit.
and now when I have added more compexity to the function for more depth I just cant manage to reverse it. this is what it looks like...

ActionScript Code:
y=int(horizon+z/ground*(600-horizon)+(Y+(0-(Y*Y)/(((600-horizon)/18.5)*(600-horizon))))*(z/100));
yep, that's a big bad one. I started out with cutting out almost all of the function, then adding bit by bit while updating the reversed function.
I only got as far as this..

ActionScript Code:
y= (Y+(0-(Y*Y)));
reversed version:

ActionScript Code:
Y=y-(y-(Math.sqrt(0-y)));
and now it gets confusing, I cant even think straight, all I do is moving around the divisions and stuff and hope it will give the correct result.. but im not getting anywhere =

I really hope someone would help me with this, even if just pointing me in the right direction.
Any comment would be welcome.
Thank you =)

View Replies !    View Related
String Calculation In AS3
I have made this StringCalc class in AS3, which parses a string into objects and then calculates it. Before I made it, I googled around to check if there existed anything like it, but i could only find unanswered questions asking for the very same thing, or unfinished attempts.

Now I am throwing this out here, both to share it and hopefully to get some suggestions on how to make this class more efficient. It also proably contains bugs, and should do more errorhandling. All comments are appreciated. I have coded it in Rambo style, it does the job, but looks rather messy. I would think there are better practises, but im not very experienced in this kind of coding.

It currently support addition, subtraction, division, multiplication and ordered operations (parantheses)

Usage:
trace( StringCalc.calculate("4*(2+10)") );

Test with this example here



PHP Code:



package no.muldal.math {
    
    public class StringCalc {
        
        public static function calculate(value:String):Number {
            
            var s:String = value;
            
            // Convert nonenglish comma desimal delimiters to
            // english dot
            while (s.search(",") != -1) {
                s = s.replace(",", ".");
            }
            
            // These two loops beneath appends the proper
            // multiply sign when a formula is written
            // like 2(2+2), and converts it to 2*(2+2)
            
            for (var g:int = 0; g < s.length; g++) {
                if (s.charAt(g) == "(" &&
                    s.charAt(g-1) != "(" &&
                    s.charAt(g-1) != "+" && // if operator is already assigned, skip
                    s.charAt(g-1) != "-" &&
                    s.charAt(g-1) != "*" &&
                    s.charAt(g-1) != "/" &&
                    g != 0 // if it is not the first char
                ) {
                    s = s.substring(0, g)+"*"+s.substring(g, s.length);
                }
            }
            
            for (var h:int = 0; h < s.length; h++) {
                if (s.charAt(h) == ")" &&
                    s.charAt(h+1) != ")" && 
                    s.charAt(h+1) != "+" && // if operator is already assigned, skip
                    s.charAt(h+1) != "-" &&
                    s.charAt(h+1) != "*" &&
                    s.charAt(h+1) != "/" &&
                    h != s.length-1 // if it is the last char, dont append
                ) {
                    s = s.substring(0, h+1)+"*"+s.substring(h+1, s.length);
                }
            }
            
            
            // Code beneath sorts out the ordered operations
            // into a xml structure. I used XML cause it was 
            // easy to debug and navigate in.
            
            var equation:XML = <equation/>;
            var currentOrder:XML = equation;
            var startIndex:int = 0;
            
            for (var i:int = 0; i < s.length; i++) {
                var o:XML;
                var e:String;
                if (s.charAt(i) == "(") {
                    e = s.substring(startIndex, i);
                    if (e != "") {
                        currentOrder.appendChild(e);
                    }
                    startIndex = i+1;
                    o = <order/>;
                    currentOrder.appendChild(o);
                    currentOrder = o;
                }
                if (s.charAt(i) == ")") {
                    e = s.substring(startIndex, i);
                    if (e != "") {
                        currentOrder.appendChild(e);
                    }
                    startIndex = i+1;
                    currentOrder = currentOrder.parent();
                }
                if (i == s.length-1) {
                    e = s.substring(startIndex, i+1)
                    if (e != "") {
                        currentOrder.appendChild(e);
                    }
                }
            }
            
            // This traverses the operations in the correct
            // order and calculuates them accordingly
            
            var t:Function = function(order:XMLList):* {
                var eq:String = "";
                for (var j:int = 0; j < order.length(); j++) {
                    if (order[j].nodeKind() == "text") {
                        eq += order[j];
                    } else if (order[j].localName() == "order") {
                        eq += arguments.callee(order[j].children());
                    }
                }
                return calc(eq);
            }
            
            t(equation.children());
            
            return t(equation.children());
        }
        
        
        // The calculating function. Splits the operation
        // by operators into objects in an array, which
        // makes it easy to calculate the actual equation
        
        private static function calc(eq:String):* {
            
            var startIndex:int = 0;
            
            var a:Array = new Array();
            
            for (var i:int = 0; i < eq.length; i++) {
                var o:Object;
                if (eq.charAt(i) == "+") {
                    o = new Object();
                    o.operation = "add";
                    o.value = eq.substring(startIndex, i);
                    a.push(o);
                    startIndex = i+1;
                } else if (eq.charAt(i) == "-") {
                    o = new Object();
                    o.operation = "subtract";
                    o.value = eq.substring(startIndex, i);
                    a.push(o);
                    startIndex = i+1;
                } else if (eq.charAt(i) == "*") {
                    o = new Object();
                    o.operation = "multiply";
                    o.value = eq.substring(startIndex, i);
                    a.push(o);
                    startIndex = i+1;
                } else if (eq.charAt(i) == "/") {
                    o = new Object();
                    o.operation = "divide";
                    o.value = eq.substring(startIndex, i);
                    a.push(o);
                    startIndex = i+1;
                }
                
                if (i == eq.length-1) {
                    o = new Object();
                    o.operation = "none";
                    o.value = eq.substring(startIndex, i+1);
                    a.push(o);
                }
            }
            
            var result:Number;
            
            // If there is no value, insert zero.
            // I.e. if a user has written -2+2, this equals to
            // the equation 0-2+2 etc.
            if (a[0].value == "") {
                result = 0;
            } else {
                result = parseFloat(a[0].value);
            }
            
            for (var j:int = 0; j < a.length; j++) {
                
                // If there is no value, insert zero. Prevents
                // script from breaking, when users insert stuff
                // like 2+++2, which translates here to 2+0+0+2
                // Probably should return error instead?
                if (j != a.length-1) {
                    if (a[j+1].value == "") {
                        a[j+1].value = "0";
                    }
                }
                
                if (a[j].operation == "add") {
                    result += parseFloat(a[j+1].value);
                } else if (a[j].operation == "subtract") {
                    result -= parseFloat(a[j+1].value);
                } else if (a[j].operation == "multiply") {
                    result *= parseFloat(a[j+1].value);
                } else if (a[j].operation == "divide") {
                    result /= parseFloat(a[j+1].value);
                }
                
            }
            
            return result;
        }
        
    }
    





My usecase is a project I am working on that has a WebService that returns formulas in a string. Later I will add support for translating predefined variables which exist in the same WebService. Then it will be able to calculate i.e. (Tp*Sp) where Tp is bound to a slidebar etc.

View Replies !    View Related
Strange Calculation
Hello Friends,

I'm doing a simple calculation here like :
Gamma = _root.Punit;
Neutron = stepperMain.value;
Sigma = Gamma + Neutron;
trace(Gamma);
trace(Neutron);
trace(Sigma);
totalPrice.text = Sigma;

------------------
And if Gamma is equal to 13,90
and if Neutron is equal to 2
the result is 13.92 !!!! super !! Grrrrrrrrrrr!

if you can help !

thanks

View Replies !    View Related
Mileage Calculation
Hi, Got a project where I need to get values for total miles between two cities (US). Does anyone have a script or example for how to get the values based on a text field and dropdown menu for state?
Thanks.

View Replies !    View Related
Random Calculation?
http://www.moond.com/main.html

any expert can give some opinions or methods to do the plant growing like that website?

View Replies !    View Related
Surface Calculation
Hi, My Boss asked me to make a programm with which a object could be drawn (mathematic shape 6 edges) and the surface of that object could be calculated. Is there anyway this could be done with Flash ?

View Replies !    View Related
Problem With A Calculation
Hi there!
i have a little problem with a calculation i do not know how o solve
here's some actionscript (this happens in a enterFrame function):

PHP Code:



diff = _root.s_line._y - this._y;
pos_y = _root.s_line._y - (diff * 0.75);
pos_x = 506 / 100 * prozent_ablauf;
draw_point(pos_x, pos_y); 




diff is the distance from a line to a specific point, for example 50pixels. this scripts calculates steps from these 50pixels down to 0, whereas the steps always get a little smaller.
is there a way to do the opposit, so that the steps in the beginning are smaller and then always get a little bigger until they reach 0?
thanks for any help :-)
manuel

View Replies !    View Related
Copyright © 2005-08 www.BigResource.com, All rights reserved