View Full Version : Passing an Array to Flash
Potemkyn
11-19-2008, 07:06 PM
I'm interested in filling an Array in ASP/ASP.NET using data from an MS SQL DB and passing it to Flash. Is this actually possible and are there limits? I'm using ASP (VB), coding in Visual Studio 2005 and for Flash I have CS3, coding in AS2.
I've been able use loadVarNum() to send a pair of variables to an ASP page and processed queries the db and sent the results back to Flash.
Thanks!
Mike
Potemkyn
11-20-2008, 09:23 PM
I've completed a work-around using a watch in Flash. It tends to ping the ASP page one additional time than there are lines in the table, but it works and my arrays are filled properly.
Anybody got a better way of doing this?
Mike
Potemkyn
11-24-2008, 04:56 PM
Clarification. ASP is spitting the data back and I can see it in the dynamic text field, but it is NOT getting put into the array.
Any suggestions?
Mike
yell0wdart
11-25-2008, 03:41 PM
The easier bet would be to pass XML into ActionScript from your server side code. Have your asp page return XML in the response stream and have your AS code load an XML document from the asp page's url like you would a file path.
You could write a little class or set of static methods to encapsulate that logic and return an int array based on the XML returned from your asp page. ;)
Potemkyn
11-25-2008, 03:59 PM
This is when I realize I'm only an Intermediate ActionScript Coder - or light coder as someone else put it. :o
I've loaded a static XML document that I typed out myself, never had ASP write one out - or do a 'response stream' Sounds like the best way to handle this as there is quite a bit of text to pass.
As for writing "a class or set of static methods to encapsulate that logic and return an int array based on the XML returned from your asp page." That sounds interesting. But it, like the response stream above, is uncharted waters.
Any guides, examples, or tutorials available that you'd recommend?
I've setting up a group of varibles on the fly with the set command:
set('PageTitle_'+currentPageReturned, pageTitleReturned);
set('PageNarration_'+currentPageReturned, pageNarrationReturned);
While the concept works when I prototyped it, it does not store the variables passed. This is in a function called by the watch I set up. Interestingly enough, the function also has two lines of code that put the responses into two dynamic text boxes:
currentPageTitle+= pageTitleReturned;
pageArray[currentPageReturned] = pageTitleReturned;
currentNarration+= pageNarrationReturned;
narrationArray[currentPageReturned] = pageNarrationReturned;
and (as you can see) it is supposed to put the data into two arrays, which also does NOT happen. It seems to be similar to the problem with loading the XML file into an array. Try to access the data too soon and you'll end up getting nothing.
:confused:
Mike
yell0wdart
11-26-2008, 03:48 PM
Well... let me get one thing strait, since a lot of people tend to confuse the two. Are you working with ASP? Or are you working with ASP.NET? The platform you're using will determine how you're going to build XML and send it back to ActionScript... both will be using Response.Write, however.
Secondly regarding XML, Kirupa has a good basic tutorial on working with XML in ActionScript: http://www.kirupa.com/developer/flashcs3/using_xml_as3_pg1.htm
What I would do is read that, then build a sample XML document that you can load into AS and iterate over the nodes to dynamically build your array. You can write a method/function to do this for you and return the array.
Once you've got that figured out, it should be a cinch to learn how to build your XML in ASP.NET via C# or VB.NET or in classic ASP w/ VBScript.
Potemkyn
12-01-2008, 02:54 PM
I'm using ASP/VB flavor, though I am coding it in Visual Studio 2005. I'm just getting started on learning ASP.NET.
Been awhile since I browsed Kirupa. I came across the tutorial Parsing External Data Array (http://www.kirupa.com/developer/mx2004/external_array.htm). This uses PHP and Flash, do you know if it can be done using ASP or ASP.NET?
Mike
yell0wdart
12-01-2008, 03:40 PM
Sure. Basically, all they're doing with the PHP is echoing back a comma delimited string through the response stream. You can do the exact same thing in ASP or ASP.NET, in very much the same fashion. Instead of doing an echo($myString);, you'd do a Response.Write(myString);.
Potemkyn
12-01-2008, 04:17 PM
Alright! Maybe this will be easier than my new function with 36 daynamic text boxes I was contemplating.
I'll look into creating and filling an array in ASP.NET and then sending it to Flash via: Response.Write(myString); Then all I have to do is delineiate it in Flash.
Thanks!
Also, I'd have to go back and look at my ASP, but I don't use the echo($myString); command. What's the advantage of using this?
again, thanks!
Mike
yell0wdart
12-01-2008, 04:30 PM
You can't use echo($myString); in ASP. echo is a PHP method. ;)
Potemkyn
12-01-2008, 05:50 PM
Dough! :o
Well, that seems to be a good reason not to use it in ASP. ;)
Mike
|
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.