Language: ChineseGermanSpanishFrenchDutchItalianRussian
123 Flash Chat Forums

Go Back   TOPCMM Community > SWFKit > SWFKit Support

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 12-20-2004, 09:13 AM
Member
 
Join Date: Oct 2004
Posts: 53
Default displaying array values in ActionScript

hello
i have a prom displaying the values of an array in Actionscript.
here is the code of what i m doing in Ffish Script.

Code:
getCatID = FlashPlayer.getVariable("firstSearch");
res = new Array();
subCat2 = conn.Execute("select * from customers where cat2 ='"+getCatID+"'");
var num_columns = subCat2.Fields.Count();

for (i = 0; i < num_columns; i++){
    res[i] = subCat2.Fields[i];
}

FlashPlayer.putArray("_root.res", res);
now the problem comes when i access the values of this array in actionsscript, it gives 'undefined' message.

pl guide.
thanks in advance.

: :

Reply With Quote
  #2 (permalink)  
Old 12-20-2004, 11:00 AM
Senior Member
 
Join Date: Dec 2002
Posts: 2,015
Default Re:displaying array values in ActionScript

Have you defined the "res" variable in Action script?

You should define the "res" variable in Action script firstly like this
Code:
res = new Array();
Reply With Quote
  #3 (permalink)  
Old 12-20-2004, 11:31 AM
Member
 
Join Date: Oct 2004
Posts: 53
Default Re:displaying array values in ActionScript

yes i have defined the variable just as you explained
Reply With Quote
  #4 (permalink)  
Old 12-20-2004, 02:38 PM
Senior Member
 
Join Date: Feb 2003
Posts: 212
Default Re:displaying array values in ActionScript

Code:
for (i = 0; i < num_columns; i++)   {
    res[i] = subCat2.Fields[i];
}

shouldn't that be

Code:
for (i = 0; i < num_columns; i++)   {
    res[i] = subCat2.Fields[i].value;
}
Reply With Quote
  #5 (permalink)  
Old 12-21-2004, 11:47 AM
Member
 
Join Date: Oct 2004
Posts: 53
Default Re:displaying array values in ActionScript

thanks, now it displays the values thanks

but what is happening is, the values displayed are only of the last one 'row' and not all the 'rows' in the database file.

what i want is all the rows containing the search field (firstSearch) should be stored in the array and then displayed in ActionScript.

just like the example in the "Samples - Database and reporting", where the data is displayed one by one, i like to display all at a time with the help of an array.

i hope u understand what i m tring to say.

can u pl suggest what to do??
Reply With Quote
  #6 (permalink)  
Old 12-21-2004, 03:34 PM
Senior Member
 
Join Date: Feb 2003
Posts: 212
Default Re:displaying array values in ActionScript

If you realy want to do this with arrays, you have to make a multidimensional array
Unfortunatly the putArray doesn't work with multidimensional arrays
You could make a false array by joining the array element with a delimitator like "|"
So to make this false array you can do like this in SWFkit
Code:
getCatID = FlashPlayer.getVariable("firstSearch");
res = new Array();
subCat2 = conn.Execute("select * from customers where cat2 ='"+getCatID+"'");

num_columns = subCat2.Fields.Count();


var subCat2 = new ActiveXObject("ADODB.Recordset");
subCat2.open("select * from Vakken", conn, 1, 2);

subCat2.moveFirst();
while (!subCat2.eof()){
  for (i = 0; i < num_columns; i++)   {
       res[i]+="|"
       res[i] += subCat2.Fields[i];
       subCat2.moveNext();
   }
}
subCat2.close();
FlashPlayer.putArray("_root.res", res);

In flash you then have to split the strings into arrays like this (when you are sure the data has reached flash)

Code:
for(i=0;i<res.length;i++){
    res[i] = res[i].split("|")
}

Its a bit complex.
The example in the sample section uses binddata and no arrays.
It has fewer codes
Reply With Quote
  #7 (permalink)  
Old 12-22-2004, 11:27 AM
Member
 
Join Date: Oct 2004
Posts: 53
Default Re:displaying array values in ActionScript

no this is not working, is there any other way of doing this??

Reply With Quote
  #8 (permalink)  
Old 12-23-2004, 09:42 AM
Senior Member
 
Join Date: Feb 2003
Posts: 212
Default Re:displaying array values in ActionScript

sorry, some balast in the code

Code:
getCatID = FlashPlayer.getVariable("firstSearch");
res = new Array();

var subCat2 = new ActiveXObject("ADODB.Recordset");
subCat2 = conn.Execute("select * from customers where cat2 ='"+getCatID+"'");
num_columns = subCat2.Fields.Count();
subCat2.moveFirst();
while (!subCat2.eof()){
  for (i = 0; i < num_columns; i++)  {
      res[i]+="|"
      res[i] += subCat2.Fields[i].value;
      subCat2.moveNext();
  }
}
subCat2.close();
FlashPlayer.putArray("_root.res", res);
trace("res is " +res)
Reply With Quote
  #9 (permalink)  
Old 12-23-2004, 12:40 PM
Member
 
Join Date: Oct 2004
Posts: 53
Default Re:displaying array values in ActionScript



now its working.

but it gives the correct answers only when the query is as follows

Code:
conn.Execute("select names from customers where cat2 ='"+getCatID+"'");
here also the first value is 'undefined'
???

if the query is as follows
Code:
conn.Execute("select * from customers where cat2 ='"+getCatID+"'");
the results are wrong!!!!
Reply With Quote
Reply

Was this information helpful?    Yes No



Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 07:33 AM.


Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0 ©2007, Crawlability, Inc.