View Full Version : trace returning undefined when it shouldn't! :(

04-07-2008, 12:16 PM

Can u have a look the trace(SelectedDate.indexOf(CurrentDate.dat)); returns 'undefined' any ideas why?

I did the pastebin for easier reading here is the code as well:

on (release) {

var SelectedDate:String
SelectedDate = MyCalendar.selectedDate;

var DateArray:Array = new Array();
DateArray.push({dat:"Apr 8", details:"Some event here..."});
DateArray.push({dat:"Apr 9", details:"Some event here..."});
DateArray.push({dat:"Apr 10", details:"Some event here..."});
DateArray.push({dat:"Apr 11", details:"Some event here..."});
DateArray.push({dat:"Apr 12", details:"Some event here..."});

//set wether a result has been found to no as default
var Found:Boolean;
Found = false;
//the var used for looping through the array
var Count:Number;
Count = 0;

//beginning of array loop through
while (DateArray[Count]) {

CurrentDate = DateArray[Count];
var TheDate:String;
var TheSelection:String;
TheDate = CurrentDate.dat;
TheSelection = SelectedDate;

if (SelectedDate.indexOf(CurrentDate.dat) > -1) {
var Result:String;
Result = CurrentDate.dat + ":\n" + CurrentDate.details;
Found = true;
if (Found == true) {
infoLabel.text = Result;
if (Found == false) {
infoLabel.text = "Sorry:\n- Nothing was found for this date.";

04-07-2008, 08:57 PM
indexOf works only with Strings, not Arrays. So perhaps try


since it would have already been extracted to this variable.

04-13-2008, 03:12 PM
if solution above did not work try this...


EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum