Actionscript 3 :: Add An Event To URLLoader Class?
Jan 2, 2012
Keeping into consideration the Actionscript 3 event HTTPStatusEvent:HTTP_RESPONSE_STATUS, which is ONLY AVAILABLE for AIR (and not Flash 9/10)
Quote from site:
Language Version: ActionScript 3.0
Runtime Versions: AIR 1.0, Flash Lite 4
I would like to add the same EVENT by extending the HTTPStatusEvent Class of Actionscript 3 for Flash (9/10).
I'm working on Adobe Flash CS3 and I'm trying to get the "last" location of a URL loader (I'm calling a php with a header("Location: ..."); ) so I need the location after it changes. This should be made directly by flash and I cannot use php proxies not other.
Also, I cannot find the source code of the AIR HTTPStatusEvent Class, which I need to get the event (specifically, the responseHeaders and responseURL properties that the AIR class has).
I'm having an issue getting URLLoader to work the way I want. I basically need to pull information from xml files, parse that information into objects, and then work with said objects afterwards.Here's pseudocode for my current implementation (which does not work)
var xmlLoader:URLLoader = new URLLoader(); xmlLoader.addEventListener(Event.COMPLETE, loadXML); xmlLoader.load(new URLRequest("xml1.xml"));
I have code that sends variables to an .asp file to be put on a database, and all that works fine the database connects and is updated fine, the thing is flash doesn't recognize that the operation was successful and won't continue with the further functions. I understand this may be due to a problem on my asp file, but the SQL executes successfully which I see when i check my DB, so I was wondering if anyone could look at my AS code and see any problems?
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?
I have a flash element in a page that load a chart based on some complex queries that can take up to a minute to load. I call the query with this code :
var chartData:URLLoader = new URLLoader(); chartData.addEventListener(Event.COMPLETE, onLoaded); chartData.addEventListener("httpStatus", onHttpStatus);
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 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;
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�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 made a class for connection with php-script, which handles sql-requests. it sends requests via URLLoader(), here is simplified code:
Actionscript Code: public class SQLWrapper extends MovieClip{ private var serverUrl:String = "http://192.168.177.128/";private var request:URLRequest; private var
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?
In all the ActionScript examples I come across, people write custom events with the types defined inside the custom event's class definition. But, in my experience, it makes more sense for the object dispatching an event to own its own definition of that event (which, in ActionScript 3, is a String).
[EDIT: After writing this question, I've found there to be cases for both positions -- in some situations, event types should be stored on the event object, and, in others, they should be stored on the object dispatching the event.]
I would like to extends the Event class to add some events I am using in game. But I don't want the new Event Class to have the old public static types. For instance I don't want to have:
NewEventClass.ENTER_FRAME
How do you go about extending the Event class without getting the old types mixed in?
Is there any way to outsmart AS3 to leave out the uneeded types?
Or should I avoid creating a new Event type altogether and just add the new strings?
I'm newish to OOP AS... trying to build a image loader that wipes between loads. having trouble getting my onloadComplete event to call a method in the main body of the class. what am I missing?
Can event listeners only be added to the class which dispatched the event? I ask because I want to have the logic for the listener on the main class, and the action is dispatched on click from a thumb which is instantiated in a scroller class. Kinda like this:
ActionScript Code: pseudo code: class main { main() {
[code]....
This doesn't work. Why can't the main class listen for an event on the thumb class?
I've done a class to be able to listen to the event for a CLASS not on an instance.
Code: class net.webbymx.events.XClassEventListener {[code]....
why did I do this.It cames with my rugby game.I have player in two teams. When a player throw the ball I want the other teammate to act like "wait for ball" and the opponent like "seek for ball". Plus I'm lazy (and I don't want to register the listener for each instance of the player I'm creating). So this class is made to be able to handle as many instance of a class I want without adding a listener on each of them. I'm just creating a global listener on the class and then I will be able to receive dispatched event for any instance of this class .so in my team I can do
Is it possible to dispatch event from class that isnt extended class of MovieClip? I created my own class and put import flash.events.Event; import flash.events.*; but when i call dispatchEvent compiler throws error:"1180: Call to a possibly undefined method dispatchEvent."
I have a document class called Main.as In the class constructor I have the following listener:
enter code here var listeningFORModeChangeToStudent:Sprite = new Sprite; listeningFORModeChangeToStudent.addEventListener(TellAllModeChangeToStudent.STUDENT,exp); addChild(listeningFORModeChangeToStudent);
[code]....
In a third class I make a call to the despatcher in the previous class:
enter code here var ThisTellAllModeChangeToStudent:TellAllModeChangeToStudent = new TellAllModeChangeToStudent; ThisTellAllModeChangeToStudent.tellAllModeChangeToStudent();
I have trace statements in eveything and from this I know the despatcher in TellAllModeChangeToStudent is being called.The problem is that the listener in the main.as is not calling the function exp.I cant see why and I dont know how to check if the listener is actually seeing the dispatch event?
I want to dispatch a custom event from the Country() sto the MenuButton();[code]When a country is hovered a custom event is dispatched which I want the MenuButton to listen and if the parameter passed is the same as its name to get highlighted. The Country Class is the Base Class for my countries movieclips I have on stage and the MenuButton the Base Class for the menu button.
In a nutshell I have a custom event that I am dispatching from one class that is not getting picked up by the other class even though i have added the appropriate addEventListener calls on its constructor.Here's how the classes are laid out:
The NetworkManager class extends the MovieClip class as does the LoginScreen and Application classes as well.Now within the oLoginScreen class I dispatch the ValidateCredentialsEvent by calling it this way:
ActionScript Code: dispatchEvent (new ValidateCredentialsEvent(ValidateCredentialsEvent.VALIDATE_CREDENTIALS, oLoginData, true, false));
Then when I debug the code, I can step through and see that the ValidateCredentialsEvent is being generated but it is never picked up by the oNetworkManager class whatsoever.Is this occuring because the NetworkManager and LoginScreen classes are children of the Application class and because of this can't capture events raised by one another without using the Application class as the intermediary to redispatch these events? My whole idea here was to create a generic network managing object that could be called from anywhere within the application, by any object, using custom events.
I have created a class (extends the Event class) for use in one of my projects. If I trace the custom event object in the called function I get 'Event' as the type, but if I trace a TimerEvent, or MouseEvent, etc, I get TimerEvent or MouseEvent... Let me demonstrate:
var c:CustomObject = new CustomObject(); c.addEventListener(CustomEvent.ON_SEND_MESSAGE,fnc); function fnc(e:CustomEvent) {
I have a class (called Units) that defines sprites which react to mouse events (being dragged around).My main .as class (called Loader) imports the Units class, sets up several shapes from Units as objects into an array (my_array[i] = new Units(j,k,l);) and then calls addChild in a loop to add them to the display list (addChild(my_array[i].shape);).All fine and dandy, but if I want a shape to go to the top of the display list when dragged about, how do I do it? The problem is that the mouseEvent is in the Units.as class, but the addChild is in the Loader.as class.The only thing I can think of is to strip the mouseEvent out of Units.as and add it to Loader.as - but that would mean adding an event to every shape in a loop, which seems inefficient.