Ok out of curiousity I started to mess around with returning values from ASP in to Flash yesterday without a great deal of success.
Has anyone done, this and if so can you advise me where I am going wrong or point me to a decent tutorial referring to Flash and ASP?
I know my ASP script is working when calling it through a browser, but it doesn’t seem to load in to Flash.
I think this is because my ASP script, is not telling Flash to print the variables. Here is the code I am using, can anyone advise me if this is right:
The important part for this is the <b>bolded &'s</b>. When you get a response from your asp document, it should be something like tim&jackie&Ithoughtthiswasagreatsite&4 (A nice long string of variables and &'s connecting them).
and here’s the actionscript that I had on my movieclip that contained all my dynamic text fields:
Yes that did the trick. I’m now getting values back from ASP
My next problem is that it is only returning the last records from the ASP script in the date and description dynamic text fields.
The way I thought it would work, is that by creating two fields for the variables you are returning from the ASP script the Flash file would be a sort of template which would then create another date and description field for each variable returned from ASP.
Therefore if you had 3 records, Flash would create 6 dynamic text fields. If you see what I mean.
I’m not the expert on this, but I’ll try to explain what I can:
Therefore if you had 3 records, Flash would create 6 dynamic text fields. If you see what I mean.
I think it does work as a template, but it won’t keep making more dynamic text fields. If you had four field (like I did for the one I made), you’ll only ever have four. From what I know it’s only the text that you’re passing into each field that’s changing, so it shouldn’t be duplicating anything.
So it’s only returning the last records for date and description eh? Well… in my example I had this:
loadVariables (“getdetails.asp?Record=0”, this);
The record=0 sends which record from your database it should take. I’m not sure how you have your table setup, so it’s pretty hard to say how you could switch it. But that’s how I indicated which record to take.
Ok I understand what you are saying i.e that flash will only ever have two dynamic text fields, however it will return as many values to these two dynamic text fields. Right?
In my news table, all I have is:
NewsID
Date
Description
But I am wanting to return all my records, when running the ASP code through the browser it correctly displays.
Here is the code I am using:
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.ConnectionString="DRIVER={Microsoft Access Driver (*.mdb)};" &_
DBQ=" & Server.MapPath("f5.mdb")
objConn.Open
strSQL = "SELECT * FROM news ORDER BY DATE DESC"
Set objRS = Server.CreateObject("ADODB.Recordset")
objRS.Open strSQL, objConn
Do While Not objRS.EOF
'sDate = objRS(1)
Response.Write "date="&Server.URLEncode(objRS(1)) & "&"
'sDescription = objRS(2)
Response.Write "description="&Server.URLEncode(objRS(2)) & "&"
objRS.MoveNext
Loop
Set objRS = Nothing
Set objConn = Nothing
I haven’t done what you’re wanting to do before. But, you can approach it like this:
Make an movieclip that holds your dynamic text fields where your information is going to go into. Use your asp like you have been, and use a for loop to duplicate the movieclip as many times as you need it for however many records you have. Of course this will end up causing some problems if you have a lot of entries, so you’d probably need to make something to scroll the whole bunch incase it displayed off the screen.
OR
You could always just use the getURL command and load an asp page that loads this information for you with some line breaks in there to separate the information. A good number of sites do this, and it’d probably save you the headache. Maybe that’s not exactly what you’re looking for, but it’s a plausible alternative solution if you’re willing to entertain the idea.