Date Compare From XML
Hello,
Is the an obvious way to do this....cuz I'm banging my head on the wall here.
I have a XML doc that has a date-time value. I want to compare that date against now. If XML date is in the future, proceed to next frame kinda thing. What format does a date-time have to be in order to convert it to a date object in Flash?
When I do: myDate = new Date(); I get something like this: Thu Mar 4 21:40:29 GMT-0500 2004
How can I compare that to my time stamp coming from XML? Cuz when I try to convert a string to a Date I get "Invalid Date"
I tried this but no luck:
From the XML doc: 2004,04,28,12,47,52,00
AS code: alertDate = alert_xml.firstChild.childNodes[0].firstChild.childNodes[0]; tempS = new String(alertDate); tempD = new Date(tempS);
returns "Invalid Date"
BUT.....This works: tempD = new Date(2004,04,28,12,47,52,00); returns: Fri May 28 12:47:52 GMT-0400 2004
How come I can't (haven't figure'd out yet) use my XML value and convert it to a date?
Thanks and bows in advance!
Dman
Tek-Tips > Adobe(Macromedia): Flash Forum
Posted on: 4 Mar 04 22:14
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Date Compare
How would I, using the getDate function or otherwise, compare today's date with an expiration date set within the script... Once the expiration date is reached, a certain event occurs. But before that time, another event would occur. Perhaps the best way to accomplish this is not with the getDate function, so your suggestions are welcome. Thanks!
DATE COMPARE FROM XML REVISITED
Hi:
I am having the same problem as the one in thread250-791975. There was no answer posted then and I wonder if someone could give me a quick help.
I am extracting a date from an XML node in the form of: 2004,7,29. When I tried to convert it to date using the format below I get an "Invalid date" error:
x=new Date(myxmlnode)
But if I use a literal format like this, I have no error:
y=new Date(2004,7,29) // yields the date
Also, when I trace myxmlnode, it yields the right output: 2004,7,29
I need to use that to determine the number of weeks between that date and the current date. Please help!
Compare Date Objects
I need to know the best way to compare two date objects. Say I have a Date instance that contains the current date and I compare it to another one to figure out whether it's in the past or future. I obviously can't simply compare them with a ">" or "<" operator.
This is probably a no-brainer but I never had to do this before since I usually do all of my date stuff on the server.
Thanks for your advise.
Compare Date Obj Function
hi all,
i did a quick search and didn't find what i'm looking for. can anybody point me to a function that will tell me if one Date object is later or earlier than another?
i'm using the standard AS Date object, and in this case i'm ignoring hours and below -- just dealing with year, month and date.
thanks in advance,
- zoot
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
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
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
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
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,
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.
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)
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);
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);
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
How Do I Compare A Var That Is NaN?
I have a text field where you unput numbers.
If using
ActionScript Code:
if(Number(myNumber) == 0 or Number(myNumber) == null){
trace("YES");
}
When the movie starts (my text field is empty) the field is considered a 0 so it traces YES, but if I type a number then erase everything in the field, the field has a value of NaN- how can I check to see if something is NaN, I assumed that was null.
How To Compare Two Strings?
Hi folks,
I've got two movie clips with a dynamic textbox in each.
I need to campare the two strings they hold, I must know if the text is the same or not.
thanx in Advance,
ZooMann
If Do Not Compare But Execute....?
Hi everybody
I have a problem while scripting a little preloader. Everything goes well until I want a comparison to be made with a "if". I don't know why but my if do not combare but execute what i have to compare. For example:
if (a._width=b._width){
gotoAndPlay(4);
}
if i execute, it will do this : the width of a will be equal to the width of b.... Is there somebody who know what is wrong.
thanks.
Vakarm
here's my frame script:
var vcharge=getBytesLoaded();
var vtotal=getBytesTotal();
var vpourcent=math.ceil((vcharge/vtotal)*100);
//vfondbarretotal is the width of the background of my loading bar.
mcbarre._width=(vfondbarretotal*vcharge)/vtotal;
if (mcfondbarre._width=mcbarre._width) {
gotoAndPlay(4);
}
gotoAndPlay(2);
Compare Two Dates Together
hello,
i have an user inputfield for a date in the format DD.MM.YYYY
now i want to compare the date the user inserts to any other date from a variable or an array
lets say i have a date in a variable: 12.12.1986
the user insert his (any) date for example 04.03.1934...
now i want compare this two dates so the output should be
user date < date in var
i should be a flexible solution so i can use it with an array of dates an check it whit a loop if it is < or > than the inputdate
any ideas? thx
sorry for my english
greetings from austria the homecountry of ****ing "terminator" arnie blackenegger
peter
Compare 3 Or 4 Variables?
What is the quickest way to compare 3 or 4 variables (containing numbers) to see which contains the biggest number?
Thanks
Compare These SWF Compressors
Which of these SWF Compressors is the best?
- SWF Compressor
- Swift Compress
- Optimaze (tried it, no luck)
- SUGGEST YOUR OWN...
[F8] How Do I Compare The Old Value And New Value Of The Same Variable?
Say I have a couple buttons, that when pressed give different values. How can I somehow compare an old value to a new value? Not sure how to set that up.
myBtn1.onPress = function()
{
myValue = 1;
}
myBtn2.onPress = function()
{
myValue = 2;
}
function checkValue()
{
// How can I do this part??
if (myValueNEW < myValueOLD)
{
// Do something
}
}
Thanks for any advice on this rookie question.
[CS3][AS2] How To Compare Strings?
Hi,
I am developing a terminal-like flash applet and need some help.
Here is the layout:
http://img.skitch.com/20080404-un685...c8b24prdhu.jpg
So when the user clicks in the box, types "M" (without quotes), and presses the "go" button, I would like it to check if the string in the box is "M", and if true, go to frame 2.
Here is the Actionscript for my "go" button:
Code:
on (release, keyPress "<Enter>") {
if (command == "M") {
gotoAndStop(2);
} else {
}
}
<< by the way, the box's var is "command" >>
All help is greatly appriciated.
Thank you to anyone who replies!
[F8] Compare - Two Arrays
Hi!
I'm workin on a search function for a record archive, and got two arrays.
array1: contains all the record ID's.
array2: contains the result of a search (record ID's).
For exampel if we got 10 records, and got 3 search-hits.
I need to know what position these hits are in array1?
Regards,
S-fish
Compare Two Strings
please tell how to compare two strings
For Eg:
var str1:String = "1234567";
var str2:String = "(xxx) xx-xx";
Here I need to compare str1 and str2 and make str1 to "(123) 45-67"
Here "x' is to specify a number.
Or tell how to convert str1 to "(123) 45-67" which is of str2's format.
Compare X/Y Positions
Now, the idea is that it works OK when I test the movie on the computer I wrote the script. When I got home and tested the movie, it didn't work (exactly the same code) and it also doesn't work when I post it on the net. So, something very weird is going on and I don't know what's wrong. Can you help me on this?
Thanks.
Here is the code:
Attach Code
onClipEvent (load) {
this.onPress = function() {
this.startDrag(false,0,0,440-this._width,350+30-this._height);
};
this.onMouseMove = function(){
if ( _x < bubbleX ) {
if ( _y < bubbleY ){
gotoAndStop (4);
}else{
gotoAndStop (2);
}
}
if ( _x > bubbleX ) {
if ( _y < bubbleY ){
gotoAndStop (5);
}else{
gotoAndStop (1);
}
}
};
this.onRelease = function() {
this.stopDrag();
};
}
How To Compare Numbers?
I have huge problem with pomparing numbers under Flash CS3 in AS2 mode.
Operation:
parseFloat("965.95")==965.95
produces FALSE when swf is played via the browser and produces TRUE when
played under Flash Player directly. How it behaves under AS3 - I don't
know, I haven't done any tests.
Windows XP Pro
IE 7
Does anybody can suggest workaround?
Compare Arrays
Hi,
I have 2 arrays that contain the same values but in a different order. i'd like to reorder the first array like the second one but i have no ideas how to do that easily.
Thank's for your help.
Chris
Compare Strings
I have this textfile with a lot of words in it.
One word on each line.
How can I compare a flash string to the lines in the textfile?
I want to know if the string matches any of the lines in the file.
Compare Arrays
Hi,
I have 2 arrays that contain the same values but in a different order. i'd like to reorder the first array like the second one but i have no ideas how to do that easily.
Thank's for your help.
Chris
How To Compare .fla Files
I have two .fla files one seems corrupted with one movie clip, is it a way to compare and copy over? I am new to flash, please be detailed. Thanks ahead
String Compare
im trying to compare two strings and the examples i've found in help files and tutorials dont seem to be working properly. here's what i have so far:
buttonSelected = "about";
if ( buttonSelected == "about" )
gotoandplay(3); //do something
this doesnt seem to be working. the instance always returns false. currently i have some buttons and when you click on the "about" button, it stores the string in the variable buttonSelected. when any of the buttons are selected, i want it to play an animation (the same animation for all the buttons), then go to the appropriate fame. does it make a difference how/where/when the variables are created? thanks
Dataset Compare
Hi All,
I want to compare two dataset and retriece the values according to the condition.
Problem, is two datasets are of different length and approx 2000 rows in each.
Can anybody give a sampel code to get rid of this problem,
Thanks,
Srigiri
Compare Arrays
Hey..
I use this code to search for all the MovieClips on the stage
and I can check for specific MovieClips and then assign actions.
ActionScript Code:
function sortStage(mc:MovieClip){
for(i in mc){
var mcArray = mc[i];
if(typeof (mcArray) == "movieclip"){
// Here I can check if the current MC is the "usa_mc"
// This assigns the actions below to the usa_mc
if(mcArray == _level0.map_mc.usa_mc){
mcArray._alpha = 30;
mcArray.onRollOver = over;
mcArray.onRollOut = out;
mcArray.onRelease = hit;
}
}
}
}
how ever I wanna check if the "mcArray" equals to a entry in another Array.. like:
ActionScript Code:
var activeArray:Array = [_level0.map_mc.usa_mc, _level0.map_mc.sweden_mc, _level0.map_mc.uk_mc];
function sortStage(mc:MovieClip){
for(i in mc){
var mcArray = mc[i];
if(typeof (mcArray) == "movieclip"){
// I wanna assign the actions to ALL OF the entries of "activeArray".
// This code below fails of course.. how can I achieve this though=?
if(mcArray == activeArray){
mcArray._alpha = 30;
mcArray.onRollOver = over;
mcArray.onRollOut = out;
mcArray.onRelease = hit;
}
}
}
}
How do I check ONE entry at the time and not compare the complete Array,
since when
ActionScript Code:
if(mcArray == activeArray){
// [i]mcArray [/i]spits out ONE mc at the time but [i]activeArray [/i]spits out all entries at once.
}
Can anyone point me into some help?
Is it clear what I´m trying to achieve?
Compare 2 XMLs
Hi
Is there any way in ActionScript that I could compare 2 XML having same structures for same values?
For Example :
There 2 XMLs (say A,B)
A :
<Test>
<TestForm name="Wiki">
<Version id='123'/>
<Version id='124'/>
</TestForm>
<TestForm name="Web">
<Version id='123'/>
<Version id='124'/>
</TestForm>
</Test>
B :
<Test>
<TestForm name="Wiki">
<Version id='123'/>
<Version id='128'/>
</TestForm>
<TestForm name="Web">
<Version id='129'/>
</TestForm>
</Test>
We compare these 2 xmls and generate a new XML which is a intersection of the above 2.
Result:
<Test>
<TestForm name="Wiki">
<Version id='123'/>
</TestForm>
</Test>
Could anyone help me in this?
Thanks in advance
Daisy
Compare Arrays
Is this possible?...I have two arrays. Array A, that contains 3 elements(a,b,c) and Array B that contains 3 elements(1,2,3). I want to make a conditional statement that compares the two arrays.
if (ArrayA == ArrayB) { //where the corresponding elements values are equal.
In other words...
a=1
b=2
c=3
All 3 elements in the Array match and will return "true".
I am trying to compare the _x and _y positions of multiple objects as in a jigsaw puzzle, upon completion. :?
Compare Values And Sort
I have a multiple choice type of quiz set up where the user ranks items based on their importance. So, each time the user ranks an item over another, it gets a point. I have this set up just fine. At the end of the quiz I have 9 variables, all with different values. How can I sort them according to their value from high to low (keep in mind some may have the same value). Any ideas?
Compare These Optimization Alternatives
Hi All-
I've learned the hard way that files with embedded sounds are ridiculously large. Sooo, I've learned a couple of alternatives to load external sound, which I will list below. Here are my questions for the experts in the group:
1) Which method listed below is best to link to load external mp3s?
2) Will I be better served for progressive downloads if I create a pre-loader with a movie placeholder that loads the movie externally, or have the pre-loader in the same swf?
3) Should I create a preloader that loads that an external movie (movie#1) and should movie #1 load movie #2 with the sound file?
I would greatly differing opinions! Thanks so much!
Here are the options for external:
I have read about two different methods to load an external swf file -
1) Create a new swf with only the sound clip in it. Load it into the new movie using loadMovieNum.
2) Create an empty symbol and load external mp3 via mysound.loadSound("somesong.mp3", true)
Datagrid Matching/Compare Help
i've been searching and trying for weeks on how to compare values of two seperate datagrids.
for example lets say i have a datagrid named mg_dg like this:
PHP Code:
var myDP:Array = new Array ();
myDP.addItem ({id:1, firstName:"firstName_1", lastName:"lastName_1"});
myDP.addItem ({id:2, firstName:"firstName_2", lastName:"lastName_2"});
myDP.addItem ({id:3, firstName:"firstName_3", lastName:"lastName_3"});
myDP.addItem ({id:4, firstName:"firstName_4", lastName:"lastName_4"});
my_dg.dataProvider = myDP;
let say i have another datagrid named mg_dg2 like this:
PHP Code:
var myDP2:Array = new Array ();
myDP2.addItem ({id:1, firstName:"firstName_1", lastName:"lastName_1"});
myDP2.addItem ({id:2, firstName:"firstName_2", lastName:"lastName_2"});
myDP2.addItem ({id:3, firstName:"firstName_3", lastName:"lastName_3"});
myDP2.addItem ({id:4, firstName:"firstName_5", lastName:"lastName_5"});
my_dg2.dataProvider = myDP2;
so if you noticed with my_dg2 that the there is firstName_5 and lastName_5 but there is not one in the my_dg datgrid.
if i were to select from my_dg2 firstName_5 and lastName_5...what i'm looking do is something along the lines of this:
PHP Code:
var dgListener:Object = new Object ();
dgListener.cellPress = function (eObj:Object) {
//if the selected row values from my_dg2 matches any of the row values in my_dg...
trace("match found");
else
trace("no match found");
//proceed to do something else
};
mg_dg2.addEventListener ("cellPress",dgListener);
so it would output "no match found".
i've even spent countless hours trying to hack this out:
http://waxjelly.wordpress.com/2006/0...t-flash-as-20/
this is sorta what i'd like to accomplish but not in the sense of using a textinput component.
it filters the datagrid of the text typed into the textinput component.
any help on how to achieve these results or could come up with a better more intuitive solution to this will greatly be appreciated.
thank you
Compare Array Index
i have two arrays with the same number of index items. the first array contains buttons i have on stage, and the second array contains MovieClips.
i have a function that sets a variable called "activeButton" equal to the last clicked button in the menu.
what i want to do is animate the MovieClip which is contained in the same index of the second array as the currently "activeButton". for example: activeButton = company_btn. the index of company_btn in my first array is [2]. i want to animate the MovieClip in the second array with the index of [2].
is there a way to compare the equality of an index between two arrays? or do i have to get clever with some variables.
thanks
kurt
Length Of Array Value Compare
Hi all
I've got 5 arrays and during the flash movie each array can be assigned different "points" changing the array .length
At the end I want to get the array with the longest length and then I can set the result.
Any ideas??
Thanks
Tom
String Compare Problem
Code:
v2="city";
nextProjectArr=[
[["city"],["a", "b", "c", "d"]]
];
for (i=0;i<nextProjectArr.length;i++) {
trace(nextProjectArr[i][0]);//shows city
trace("v2 is "+v2);//shows city
if (nextProjectArr[i][0] == v2) {
trace("v2 "+v2);
}
else trace("no");// shows no
}
Why would if (nextProjectArr[i][0] == v2) trace 'no' instead of 'city' ???
thx
Compare Values In Arrays
I have two Arrays. One that is a complete list of content that needs to be played. Another is an Array of content that should be filtered. I want to remove elements in the masterPlay if it's company name is == the company in the filtered array.
Is that possible?
For Loop To Compare Arrays
I'm trying to compare my two arrays, so I can create an if statement to say how many numbers have been compared. Any ideas? Here's my code
Code:
import uk.ac.uwe.multimedia.lottery.LotteryDraw;
import flash.text.TextField;
import flash.text.TextFormat;
var lottoDraw:LotteryDraw = new LotteryDraw();
lottoDraw.chooseNumbers();
var everyBall:Array = new Array();
var userInput:Array = new Array();
for(var i:int = 0; i< 6 ; i++) // creates numbers up until it has reached 6 numbers created
everyBall.push(lottoDraw.getNumber(i)) //run function getNumber for variable lotto
everyBall.sort(Array.NUMERIC); // puts the random numbers in numerical order
everyBall.push(lottoDraw.getNumber(6)); // bonus ball - has to be separate from other numbers
trace("The Lottery numbers are: " + everyBall); // makes the text appear
The rest of my code is jsut to do with text boxes and such.
Thanks for any help!!
Randomize An Array And Compare
I need help!!!
I want to create a multidimensional array that holds recipe names and ingredients and then I need to randomize a recipe name out of the array and compare it to ingredients entered interactively.
Large Array(recipe array)
NameIngredientingredientingredient
NameIngredientIngredientIngredient
NameIngredientIngredientIngredient
I want each element in the large array to be it’s own array and to be selected randomly . Then I want to compare the ingredients in that array to a list of ingredients entered interactively and check for equality
MyArray = = List
Finally I want that array element to not be used again...and then loop the recipe array again until it reaches X amount of times and stops.
Please help Me..... I'm new to this
Quickest Way To Compare Variables
i need to compare say, 10 variables (numbers) to find out which are within 600 of each other... any ideas???
i have tried
Code:
if(var1-var2<600) {
}
for each value...
but that was really bad
|