PDA

View Full Version : ASP to Flash - Array problems


ekko
06-20-2005, 05:12 AM
Here is a link to the asp file:

http://d415899.u53.fluidhosting.com/LoadForFlashArray.asp

ASP Code:


<!-- #include file="include.asp" -->

<%
dim con
dim rst
dim count

set con = getconnection
set rst = server.CreateObject ("ADODB.recordset")

rst.activeconnection=con
rst.source = "select * from tblappetizerrecipe"
rst.Open

count = 0
while not rst.EOF
call Response.Write "&id" & count & "=" & rst("recipeID")
call Response.Write "&name" & count & "=" & rst("recipename")
count = count + 1
call rst.MoveNext
wend
call Response.Write "&count=" & count

call rst.Close
set rst = nothing
call con.close
set con = nothing
%>


Here is my actionscript:


myVars = new LoadVars();
myVars.onLoad = function(success){
if(success){
for(i=0; i<this.count-1; i++){
ids[i] = this["id" + i];
names[i] = this["name" + i];
}
}
}
myVars.load("LoadForFlashArray.asp");



Now when I set a text area's variable in the properties pane to something like ids[0] or names[1] nothing shows up. However, if I would pull a non-array variable like "count" in and make that the variable for the text field it works fine (in other words single variables work, arrays don't). For example:


myVars = new LoadVars();
myVars.onLoad = function(success){
if(success){
for(i=0; i<this.count-1; i++){
ids[i] = this["id" + i];
names[i] = this["name" + i];
loopCount = this.count;
}
}
}
myVars.load("LoadForFlashArray.asp");


In the above example if I assign "loopCount" to the textfield variable field the ASP "count" variable displays properly, but I still can't get the arrays to display.

Any ideas? Can you not just assign an array directly to a text field?

Thanks

CyanBlue
06-20-2005, 05:14 AM
Howdy and Welcome... :)

What if you change those lines like this???

ids.push(this["id" + i]);
names.push(this["name" + i]);

ekko
06-20-2005, 05:20 AM
Tried that and it still doesn't work.

In the text field properties bar in Flash where it says "Var:" do I just enter something like:


names[4]

Cota
06-20-2005, 06:01 AM
I had a similar problem some time ago, CyanBlue actually solved it for me and we came up with this solution, slightly modified to fit you're situation

myVars = new LoadVars();
myVars.onLoad = function(success){
if(success){
for(i=0; i<this.count-1; i++){
theID = "id" + i;
theName = "name" + i;
_global.ids[i] = this[theID];
_global.names[i] = this[theName];
loopCount = this.count;
}
}
}
myVars.load("LoadForFlashArray.asp");

It was a few months ago using MX, so it might be alittle out dated if you're using MX2004.

ekko
06-20-2005, 06:49 AM
Do I just set the Var: propery of the text field to "_global.ids[1]" then?

Timmee_3Styler
06-20-2005, 01:54 PM
just got a quick question about the asp code:

What does the "call" action do ?

ekko
06-20-2005, 09:41 PM
just got a quick question about the asp code:

What does the "call" action do ?


The call is not really necessary for the subroutining... just personal preference of our ASP coder. For example:

Call Response.Write("Hello World!") 'will work
Response.Write "Hello World" 'will work
Response.Write("Hello World") 'will error out...parentheses dictate Call for subroutines

ekko
06-20-2005, 09:48 PM
Also for those that may read this thread in the future, my problem is just latency issues. I was calling the Flash Array defined within the onLoad function from outside of the function, but that function had not built the Flash Array yet.... as a result there was nothing there. Something to keep in mind for the future.

Thanks to all who helped-