ActionScript 2.0 :: Getting Data With Loadvars And Put It In Array
Feb 20, 2004
I want to write out some names from a DB and then get it with loadvars and then put it in an array for easy using later, how do I do this the best way? First thing first I have made an ASP file like this:
Code:
<%
Dim objConnect, objRS, SQL, strConn, i
Set objConnect= Server.CreateObject("ADODB.Connection")
Set objRS= Server.CreateObject("ADODB.Recordset")
[Code] ....
How do I loop out this thing and put it all in an array =?
All the examples in the text books, etc. show the LoadVars object being used with a .txt file. Can I use it with a .xml file or not? I have tried but the output panel just shows rubbish data!
I am using the loadVars class (Flash 8) to load key/value pairs from a mySQL database through php (example &pic1=pic1.jpg&pic2=pic2.jpg&...).
The ultimate goal is to create a dynamic slideshow with a variable length, depending on how many pics were submitted by the user. Since the associative array object returned by loadVars does not share the "length" property of indexed arrays, my guess is that the values need to be converted into a new indexed array before being able to use them in the slideshow.
I'm messing around with trying to load variables from a text file and it's just not working as I'd expect. First, my text file is formatted like this
[Code]...
For example, if I do something like create a simple Dynamic Text Box on the same frame as the above code, to show the value from _level0.Test.variable1, it displays "undefined" even though the debugger indicates this variable has the value "value1" as I wish it to. (using "trace(_level0.Test.variable1)" yields no better results)
I have attemped using onLoad and onData alongside the above code, and neither one has made the situation better. I have also attempted trying to reference the variable in a few different ways, and it's just returning the same thing every time. When I was experimenting last night, I managed to get the variables to show up properly on a "trace()" but not when referenced by other things in the flash file. Regrettably, I cannot remember how I did this. Either way it didn't quite work still. Do I need to do something else to be able to reference loaded data in my project, or is there some fundamental mistake I am making? I'm usng Flash CS3 Pro, if that makes any difference. Flash Player is up to date, etc.
I'm loading data from sql, by using asp.net. I've made the script in vb, but now i have problems with flash. I can load data, by using Code: trace(this.body); But i dont't know how to get the data with the while loop
I'm using Flash MX (2002) and I need to get my variable values saved to a server each time my test subjects run and finish my swf/fla (PHP scripts and a .txt file on the server are being worked on, but that's a different nightmare!). I'm pretty sure I should use LoadVars, NOT SharedObject for this data capture right?. The data must not be overwritten each time over the course of a few months of data collection. The 3 variables are: username (name of the user), counter (this keeps track of which version the user chooses from the start menu), numcorrect (keeps track of the number of times the <right> arrow key is pressed).
2 main problems: I don't know where to put in the LoadVars obj (in the AS code of "finaldisplay" frame?) AND I don't know how to build/format the LoadVars object to capture the data in the 3 variables I listed above. I've got several Flash books and have done online tutorials, so for something so simple (3 lousy variables!)...why is my life so miserable? Here's my zipped .fla.
I want to load headlines that are linked to URL(s) into my flash movie where the dynamic txt box(tickertxt) is here:_root.scroll.scrollbox. tickertxt.I am working along with my programmer and he built php page that says:num=1&url1=ticker.php%3Fid%3D1&headline1=Test.[code]
So far I'm able to load simple data ( like "name", "address" ...) or to create an array of simple items. I wonder how I can load external data to create an array of multiple choice questions, each of which consisting of ["text of question",["choice1", "choice2", ...], correctChoice]. The questions show one at a time. Something like what I did here: [URL]
I'd rather not use XML if possible, as I don't understand it v well yet.
I am having problems with loadVars over https. What I am trying to do is sending credit card information from a flash store to a PHP-script on a server over https, and the PHP-script should return a reply. (So I am using the LoadVars sendAndLoad command). The problem is that the reply I get from the script is empty. If I try the same over http, it works fine.
I'm using Flash MX (2002) and I need to get my variable values saved to a server each time my test subjects run and finish my swf/fla (PHP scripts and a .txt file on the server are being worked on, but that's a different nightmare!). I'm pretty sure I should use LoadVars, NOT SharedObject for this data capture right?. The data must not be overwritten each time over the course of a few months of data collection.
The 3 variables are: username (name of the user), counter (this keeps track of which version the user chooses from the start menu), numcorrect (keeps track of the number of times the <right> arrow key is pressed).
I don't know where to put in the LoadVars obj (in the AS code of "finaldisplay" frame?) AND I don't know how to build/format the LoadVars object to capture the data in the 3 variables I listed above.
I was wondering if anyone had found out that there is a limit to how much information can be sent with LoadVars. I guess that limit could be the number of properties of the loadVars object, or size of the properties being sent.
I've got a small problem with loadvars. I want to send data from Flash to PHP, which usually works well. But right now I need to send "larger" amounts of data around 10-20kb and loadvars doesn't work anymore.
Using loadvars to open browser-windows seems to work fine, but I want everything to happen inside of flash.
The code is:
Code: datastring = "1, 2, 3 (...) 4998, 4999, 5000"; // long text loadstring = 'save.php?data='+datastring; db = new LoadVars();
[Code].....
Works fine with small text, with big text nothing happens. How to do this the right way?
Edit: Loadvars seems to work up until 4050 characters, 4051 and it doesn't send anymore. But I can't really split the query..
I have an application that reads a PHP script and populates the Flash applets using the following on frame 1:
[Code]...
A combobox (created with the returned data) is created on frame 61. When a selection is chosen in the combobox I need to add the value returned from the combobox to the variable catvar, add this variable to the LoadVars object and run the script again. It seems to set c.catvar initially but when I use the 'sendAndLoad command the second time c.catvar isn't included. Is it possible to add variables to a LoadVars object created on frame 1 from frame 61?
I have done many assignments where I have developed Flash movies that access external databases over a web pages and present the results in custom made graphs. Perfect for scorecard applications etc. The main benefit of using Flash has been that the whole thing can be embedded and run from PowerPoint,
The problem is that it executes #Second before #First, which means that the object is not fullly loaded but the code continues nonetheless. Is there a way handle this? I have tried using a while loop, but this is ugly and makes flash crash. Is there any decent way to handle this, does it have to do with better code structure/program flow or is there a technical way to make it wait? Also note: This code is executed on the server side, which means there are no frames involved.
UPDATE:When projects get bigger, this gets very ugly, especially when you are retrieving mulitple things from a server, you have to use very deep nesting, you have to keep repeating the same code, example for buying a serial:
I want to load headlines that are linked to URL(s) into my flash movie where the dynamic txt box (tickertxt) is here: _root.scroll.scrollbox.tickertxt
I am working along with my programmer and he built php page that says: num=1&url1=ticker.php%3Fid%3D1&headline1=Test
Here is my actionscript. I cannot get it work: newsItems=new Array(); myVars = new LoadVars(); myVars.load("ticker.php?flash"); function () { for (x=1; x<total;x++){ newsItems[x]=new Array(); [Code] .....
For the life of me, I've tried everything: I've researched LoadVars on Adobe forum, used David Powers' books, googled 'flash to php', LoadVars, etc. and tried sendAndLoad, send, and using $_POST, $_GET, $_REQUEST. $HTTP_POSTVARS but I keep getting this same error.
I have a Unix server running Apache/PHP 4 - LoadVars worked to load name-value pairs into an array -see thread)
My goal with this simple app is to prototype being able to pass a variable from flash to a variable in php.
Parse error: syntax error, unexpected T_VARIABLE in flash_to_SQL.php on line 5
Actionscript 2.0 code:
var c :LoadVars = new LoadVars(); c.testing = "123FOUR"; c.send ("
I am using FMS 4.5 and have a simple application which I want to use to send two strings to a php file. But I get a compilation error whenever I try to assign any value to these objects:
Here is main.asc:
<code> var variables = new LoadVars(); variables.username = "uname"; variables.send(http://url.abc.com/test.php,POST) </code>
I can't compile with the second line. FMS just says: Sending error message: Compilation error
This code is being run from a frameset in IE8. When the new window is opened, the form data is not being recognized. It appears that the http header, "content-type: application/x-www-form-urlencoded", is not being passed into IE and this is causing the post data not to be processed. The data is there, IE is just doing nothing with it.
This code works fine in FF and Chrome, and in fact the correct headers are passed in FF and Chrome.
NOTE: The new page is on a different site, but i don't know why that would cause a problem with a POST and not a GET.
I have tried adding the header to the send request, but that has no effect at all. The contenttype header is still missing and it still works everywhere but IE.
My current work around is to use a GET instead of a post, but that's ugly and it limits us in the size of data we can pass but for now at least it works.
I would like to send data from PHP to Flash however, it sends just fine but when displaying on Flash, it does not display the contents in the variable. Instead, it displays the name of the variable. This may be a simple answer but I'm quite new to this. Here is the code in Flash.
I'm using an onLoad function (importing variables from a text file) and I'm creating arrays within a for loop in the onLoad function. I'm using something like this:
Code: this["dvdAry" + i] = this[indexAry[i]].split("##"); So say the first array is called dvdAry0 .
How can I access that Array from a function? Please note the function, the onLoad function and the arrays are all being created on the same timeline.I've tried tracing the array dvdAry0 from the function after the array is created in the onLoad function, but it comes up as undefined. Is the array created on the object that I'm using onLoad on?I'm using a loadVars Object called loadDVDsText.
One of the moderators, could you've a look at this tutorial: [URL] it doesn't works with me, maybe because I've 2004 so if you change loadVars() into LoadVars() it should work
There seems to be a problem with Firefox 2.x sending variables to PHP scripts with the LoadVars.send/POST method.
<br>
The same problem doesn't occur in IE or Opera. <br>See this url for example to try in both FF and IE/Opera: here. <br>The source files are here g.zelenka@iinet.net.au
Is it possible to "POST" JSON data in the body of a request with LoadVars? I understand LoadVars sends data as name>value pairs. How can I send the data in the body instead?
I have an xml file (externally saved) that is similar to the following:
[root] [main] [title]...[/title]
[Code]....
What I like to do is to get what's in [title] tag using HTTPservice, import it into Flex, and save it as array objects, and do the same thing for [content]. This way I can later refer the array object saying title[0] or content[2].
I have bought Learning AS 3.0 (O'Reilly) but I have been having difficulty getting one of the tutorials to run. The tutorial shows how to record data from a microphone to a byte array, playback the saved data and save as a WAV file. For some reason, I can't get this working. When the swf runs, the Flash Settings screen doesn't pop up to request permission to access the microphone but I can still trace properties such as gain.
I've uploaded a zip containing all the classes and an FLA - just use RecordMicrophone_Example.as file as the document class. Here is the problematic area of the code:
I have No problems inserting data from flash to PHP into MySQL,it's sendind them back properlly.All I'd like to see happen is for one row of data to be inserted into a dynamic text field. here's what i've got if i access this php file, it prints out a vertical list from a single MySQL row,I was happy.
$query = "select row from table"; $result = mysql_query($query, $db);
while($row = mysql_fetch_row($result))[code]...
and Instead of the vertical list (which i would love to see)i get an unparsed data array.