[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

LoadVars - ASP to Flash Array

Posted on 2007-10-21
2
Medium Priority
?
1,233 Views
Last Modified: 2012-06-21
I have created a simple DataGrid and I am using the code below:

var content_lv:LoadVars = new LoadVars();
content_lv.onLoad = function(success:Boolean) {
if (success) {
UserGrid.addColumn("Title");
UserGrid.dataProvider = content_lv.myGrid;
}
};

var fetch_content_lv:LoadVars = new LoadVars();
fetch_content_lv.name = content_t.text;
fetch_content_lv.sendAndLoad("http://mydomain.com/search.asp?unitID=1&searchTV=book", content_lv, "POST");

My sample asp output looks like this:

myGrid={ID:"274", Title:"Book+1"},{ID:"275", Title:"Book+2"}

This output is the same as if I just cut and pasted the sample asp output and pasted like so into my actionsript:

var content_lv:LoadVars = new LoadVars();
content_lv.onLoad = function(success:Boolean) {
if (success) {
UserGrid.addColumn("Title");
books = new Array(
{ID:"274", Title:"Book+1"},{ID:"275", Title:"Book+2"}
);
UserGrid.dataProvider = books;
}
};

var fetch_content_lv:LoadVars = new LoadVars();
fetch_content_lv.name = content_t.text;
fetch_content_lv.sendAndLoad("http://mydomain.com/search.asp?unitID=1&searchTV=book", content_lv, "POST");

Obviously the cut and past isn't actually using the asp feed but it works and I think it is down to the use of quotes.

Does anyone know how to parse the ASP output to a Flash array to dynamically generate the DataGrid content?

Any help would be much appreciated.
0
Comment
Question by:NewAS
2 Comments
 

Author Comment

by:NewAS
ID: 20119678
We have a winner:

var content_lv:LoadVars = new LoadVars();
content_lv.onLoad = function(success:Boolean) {
      if (success) {
            for (var i = 1; i<=31; i++) {
                  mydatagrid.addItem({ID:this["ID"+i],Title:this["Title"+i]})
            };
      };
};
var fetch_content_lv:LoadVars = new LoadVars();
fetch_content_lv.name = content_t.text;
fetch_content_lv.sendAndLoad("http://mydomain.com/search.asp?unitID=1&searchTV=book", content_lv, "POST");

var userListener = new Object();
userListener.change = function(event) {
      trace(
              "This ID: " + event.target.selectedItem.ID +
              " and the Title is: " + event.target.selectedItem.Title
             );
};
      
mydatagrid.addEventListener("change", userListener);

My sample ASP code:

If gObjRs.BOF and gObjRs.EOF Then
Else
      Dim intRec, dataGrid

      For intRec=1 To gObjRs.RecordCount
            If Not gObjRs.EOF Then
                  dataGrid = dataGrid & "&ID" & intRec & "=" & gObjRs("book_ID") & "&Title" & intRec & "=" & gObjRs("book_title_TV") & ""
            gObjRs.MoveNext
            End If
      Next
End If

Response.Write (dataGrid)

The above works like a charm, yippee.

Regards, NewAS.
0
 

Accepted Solution

by:
EE_AutoDeleter earned 0 total points
ID: 20968550
NewAS,
Because you have presented a solution to your own problem which may be helpful to future searches, this question is now PAQed and your points have been refunded.

EE_AutoDeleter
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Sometimes you know that one object has a specific child in it, but you can't find the child. This happened to me when I was trying to code some actionScript to make a toolbar work with its embedded buttons.  My partner had created the toolbar usi…
This article describes a solution to a problem of subloading one movie into another when they have different SWF versions. Sometime back, I was working on an ActionScript project while I came across an interesting fact which I would like to share…
The goal of the tutorial is to teach the user how to live broadcast using Flash Media Live Encoder and connecting it to YouTube to broadcast. Log into your Youtube account, choose live stream settings, start live stream from Flash Media Live Enc…
The goal of the tutorial is to teach the user what frame rate is, how to control it and what effect it has on the video.

873 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question