Actionscript 3 :: Get The Data Of The URLRequest From The Complete Event Handler For A URLLoader?
Mar 17, 2011
I have a queue of messages that I would like to send to a URL and I would like to remove messages from that queue only after I am sure they have been successfully sent. To do this I need to know in the COMPLETE event for the URLLoader exactly what data was sent so that I can remove the correct message from the queue.That is if I have something like this.
var urlRequest:URLRequest = new URLRequest(targetUrl);
var urlLoader:URLLoader = new URLLoader();
urlLoader.dataFormat = URLLoaderDataFormat.TEXT;
when handling data, i always have to write the following:
var dataSourceRequest:URLRequest = new URLRequest("/path/file.xml"); var dataSourceLoader:URLLoader = new URLLoader(dataSourceRequest); dataSourceLoader.addEventListener(Event.COMPLETE, handleDataSource);
while i can understand the usefulness of these 2 objects and event listener being separate, since they often work with each other i'd like to know if there is a method that will combine them all? the closest i can get is this, but it's a bit pointless/nesting:
var dataSourceLoader:URLLoader = new URLLoader(new URLRequest("/path/file.xml")); dataSourceLoader.addEventListener(Event.COMPLETE, handleDataSource);
what i'd really love would be something that automatically combines the URLRequest, URLLoader and completed event listener like this:
var dataSource:Whatever = new Whatever("/path/file.xml", handleDataSource);
I am experiencing an interesting problem...I have a URLLoader instance with a Event.COMPLETED listener. I can reproduce behavior such that when the listener is called, there is a discrepancy in the amount of loaded data.
I made a test where I download a file using URLLoader - something like this:
[Code]....
in the middle of the downloading process I physically disconnect the internet connection. the download stalls - but after aproximately 30 seconds downloadSuccessful is invoked, although only half of the data was downloaded. how can I make sure that the data to be downloaded is complete and correct?
I'm querying a web application in a remote server through XML files and receiving answers in the same file format. Until now, sometimes I received a connection error:
Error #2044: Unhandled ioError:. text=Error #2032: Stream Error. URL: http://server/Services/startSesion.com at reg_jugadores_fla::MainTimeline/queryGQ() at reg_jugadores_fla::MainTimeline/reg_jugadores_fla::frame1()
When this occurs, trying to access the services through a web browser, there's a test page where you can try queries, returns a "500 Internal server error". I managed that problem adding a listener to catch the error:
But since yesterday I can't connect anymore using Flash while it's possible to access the test page. I'm not able to talk to any support guy as the company is closed for vacations! I added listeners to try to know what's happening and this is the result in the output window:
AFAIK, status=200 means OK but why the COMPLETE event isn't dispatched?. So, is there anything I can do or just wait until the tech guys return from the beach?
How ever when I keep getting back "error:empty request". I emailed the site owner and he said that my program may be dropping the data during redirects.[URL]
How can I reorganise the code below so the trace commands output i for each element in the photourls array and not just the last element? In a 6 element array, the trace(i); line outputs 5,5,5,5,5,5 rather than 0,1,2,3,4,5.
I�m getting Error #2032 when my URLLoader complete event finishes firing. What I can�t figure out is why. The complete event fires successful (I ran a number of trace statements to make sure it made it all the way to the end of the method with no error) and I�m not getting any helpful output when I trap the IOError. Here is the error message:
I am attempting to build a generic XMLLoader class with a static LOAD method, with the intent to use it as follows...
private var _data:XML = XMLLoader.LOAD("path/to/xml_file.xml");
Then I could use it in any client and go-to-town with e4x.
The general problem I am having is with the URLLoader's COMPLETE event, which necessarily calls a different function to set the XML data.This is preventing me from being able to return the XML from the LOAD method, since the data is being set outside that function. Obviously I need to wait for the COMPLETE event in order to make sure the data is available.
I though, perhaps, I could create and return a _waitForData function, which recursively calls itself until the _data is set, then returns the data. But it seems redundant (since Event.COMPLETE is doing that anyway), and the way I tried it generates a stack overflow error.[code]...
Is there some way in Flex where I can tell when all of the data has finished binding to my AdvancedDataGrid? I have a bunch of label functions that run and I need to a busy cursor while the grid gets populated. I then want to remove it when it's all done. And also fire another event.
i am trying to return an XML object, but having issues. The object is only created via an Event.complete function. I need to return the XML created from my loadXML function via my grabXMLfromFile function.
Code: function grabXMLFromFile(attrPathToXML:String):XML { var fileUrl:String = attrPathToXML; var myUrlRequest:URLRequest = new URLRequest(fileUrl);
I need to parse a particular web page every 25 seconds in order to take some particular values that are frequently updated in this web page. I need the parsed values in order to dinamically fill some text inputs components. So I write the following script:
With this script I'm able to get the webpage and parse the particular line of code that I need but only the first time! When the timer goes to zero the URLLoader function always loads the first version of the webpage and not the one that has been updated in the meanwhile! So I have always the same values! Using the trace function I have discovered that URLLoader loads the first version of the webpage. I don't know what is the problem here. Cache problem? URLRequest or URLLoader problem (maybe I have to clear the previous data?)?
I am building a simple swf that will load in variables from an asp page using a URLloader and URLRequest. The asp page loads in the current values from a SQL database but these values will change every second. My swf loops every 6 frames and loads the data. How much load this puts on the server? And when the server is busy might this cause a problem with the variables I am reading in?
Does AS3 run all actions on frame 1 before going to frame 2 etc? I don't know if this is the best way but my last variable in the ASP page is called Loaded and I test for it before moving on. My major concern is the load I am putting on the website but is this small? In firefox the status box constantly flickers transferring data from ... and waiting .. but in other browsers you can't see the activity.
there you are, you set up your AS3 code to load XML via a URLLoader and URLRequest, as normal. You then take your XML file, and upload it to a server. You then run your program, and trace out the XML you receive. So far so great, and you see the results of your XML traced out. Then you change something on your XML, either adding to it or removing a line. You then run your program again from CS5.5, and trace out the XML, and it shows the same results that it did before you made any changes. I deleted the XML file from the remote server, and it is like it stored it in cache, and still able to read it. If I change the url or file name, it gives me an error, which it should.
If I point the url back to my remote XML file, and run the program again, it gives me the XML results I had in the beginning, before I made any changes to it (regardless if the XML file exists). The only fix I have found so far, is closing CS5.5, and reopening, and then it can see the changes. I did that, and it was able to see my XML changes on my remote server, but again, only one time. If I try to change anything, or delete the XML file, it still pretends as if its there, reading the results that it read the first time I run the program. Is this a cache issue? Anybody else experience this? I never remember running into this problem using CS5/CS4/CS3, only CS5.5. Of course, I can test it all locally first, and then upload the XML file to the remote server when I know that no other changes need to be made, but still, this is really weird!
Peek-a-boo, me again. I'm having some trouble with loading in a txt-file and I can't figure out why, as it works in a new .fla file as well. Here's the code in a nutshell:
PHP Code: goldstar.addEventListener(MouseEvent.MOUSE_DOWN, showHS); var weekrequest:URLRequest = new URLRequest("weekscores.txt"); var weekloader:URLLoader = new URLLoader();
I have written code to read an XML file by using URLRequest and URLLoader in ActionScript 3.0. Code is pasted below. This runs well in AS3.Problem I am facing is because I wrote this in AS3, I am not able to use the DateChooser component in another part of the flash module because it seems like DateChooser component is not supported in AS3. So I want to migrate my below AS3 code back to AS2.
**** Code in AS3 (I need help in writing equivalent code in AS2) :- var xmlText:XML ;var xmlReq:URLRequest = new URLRequest("myFile.xml");var xmlLoader:URLLoader = new URLLoader();
var xmlURLLoader:URLLoader = new URLLoader(); var xmlURLRequest:URLRequest = new URLRequest();
I am taking some old AS code and trying to plug it into Flash Builder. I am getting a "Type not found."warning with those variable declarations. Does anyone know which package to import?
I am writing a flex application that has a MainMovie that loads flex programs (ChildMovie) depending on what the user selects in the MainMovie.
class MainMovie{ private var request:URLRequest = new URLRequest(); public function callPHPfile(param:String, loader:URLLoader,
[code]....
I can see that the callPHPfile function is being executed and received xml data from in httpFox, the problem is that the code in the handlerInChild function is not being executed.
I am loading in binary files with the url class which can be quite large 10mb + and it works fine on my server but another server I am testing on it can sometimes not work. Sometimes it will not load the file and other times it will only load about 20% and it throw a complete event??? Then of course other times it works fine. This server is https maybe that has something to do this it?
I am working on a flash website that loads live inventory data from a public csv file publish by google docs. the csv file is located at a public address on google docs server:[URL].. I am using a URLloader and URLrequest within my flash movie to grab this data and assign it to different variables.
It works great when I preview the movie in flash. However, when I go to publish the movie and preview the html file its loaded into in dreamweaver, I get a security warning from adobe flash player: Adobe Flash Player has stopped a potentially unsafe operation
I went ahead and published the html file that contains the swf file to the web, and when I go to my site, I don't even get the flash player warning; it just sits there like its trying to load the URLrequest and never completes.
I understand that flash player has a security measures that prevents flash files from accessing files outside of the server directory that the swf file is published to. I know you can create policy xml files to tell flash it's okay to load the data, but those policy files have to be located on the public server from which the data is being grabbed. But it's not like I can waltz on to google's servers a stick a policy file in there!
Is there any way to tell the flash player it's okay to load this data without getting that security error? I can't have the end user having to go into their flash settings and adding the location manually. I just need it to work without the security warning.
Is there another method of loading data from an external server without tripping up flash player security? aka, something other than URLloader and URLrequest?
I have loaded a jpeg image in flash. Now I need the handler after the loading complete. I have used ActionScript Code: var imageLoader:Loader = new Loader(); var req:URLRequest=new URLRequest(arr[0]); imageLoader.load(req); mc.addChild(imageLoader); imageLoader.addEventListener(Event.COMPLETE, image_func); function image_func(e:Event):void { trace("image laoded complete"); } The above code is not working for loading complete.
I need to send a byte array of data (its an image source) along with a bunch of other vars to a service.If I send the byte array using something like the following
var request:URLRequest = new URLRequest ( 'http://www.mydomain.com/upload.php' ); var loader: URLLoader = new URLLoader(); request.contentType = 'application/octet-stream';
I have an event listener for a custom event type. This custom event overrides the clone method as required.In this event listener I want to dispatch an instance of a different type of event... a different custom event instance altogether. It also overrides the clone method as required.The problem is I'm getting a type coercion error: TypeError: Error #1034: Type Coercion failed: ...I do not know what is trying to do the casting. My code is:
/* elsewhere in a method */ addEventListener(GestureEvent.GESTURE_SCALE, handlePinched); /* the event handler */
I am writing a program that needs to go to a random frame after clicking a button. However, the program also needs to start on a random frame. When I call the function at the start of the program it gives me an 1120: Access of undefined property event error. The function is originally written as followed:
function randomMatchedTrial(event:MouseEvent) { ... lots of code that probably doesnt matter, but let me know if it does... }
the program starts by calling the function as followed:
randomMatchedTrial(event)
Can event handler functions be called outside of the event listeners they are handling?