How to test if a URL is valid in Actionscript 3.0?

HY, everyone!
I'm trying to make a function that tests whether a URL is valid and returns true if it is, false otherwise, so that I can use it in a statement "if".



The I try to do is using two event listeners for the property "contentLoaderInfo' of a charger: one for Event.OPEN (if this event is dispatched, so I know that the URL is valid) and one for IOErrorEvent.IO_ERROR (if this event is dispatched, so I know that the URL is not valid).
But the problem is that by using event handler functions, I leave the main Tester URL function and am unable to return a value from it. The way I thought to get around this was to set a variable for returnValue, which the return value of both the event handler works and then just go "return returnValue; But I do not know how to return a value from a function handler events, and even if I did I still couldn't do it this way, because it takes time to send events and the variable 'returnValue' would be undefined at the point where I try to return it.
I hope you understood what I tried to explain above. Here is some code to illustrate this better (it is not valid, that it's just so that you understand my problem):

private void testUrl(url:String):void {}
var returnValue:Boolean;
var loader: Loader = new Loader();
returnValue = loader.contentLoaderInfo.addEventListener (Event.OPEN, onGoodUrl);
It is a global variable which I assigned the value of "loader" so that I can farm onGoodUrl
_testLoader = loader;
returnValue = loader.contentLoaderInfo.addEventListener (IOErrorEvent.IO_ERROR, onBadUrl);
Loader.Load (new URLRequest (url));
Even if I knew how to do an event handler that returns a value, I still have to wait for loading to start, and I couldn't return the value here:
return returnValue;
}

private void onGoodUrl(event:Event):Boolean {}
_testLoader.close ();
// ???
Returns true;
}

private void onBadUrl(event:IOErrorEvent):Boolean {}
// ???
Returns false;
}



You know a way around this problem? Or, for that matter, you know another way to test a valid URL?

Thank you for your time!

You should test the httpStatus of the URLLoader. Streaming content is undergoing a specific process at entry into Flash. The only problem with httpStatus, is that it does not work for all browsers, especially systems based on Linux and any programs on the evolutionary food chain. I didn't have problems with IE or NS/FF on Vista at this stage.

1. send the request

2. receive the HTTP (HTTPStatusEvent.HTTP_STATUS) status

3A. good condition - Begin Load (Event.OPEN)
3 b. bad condition - 404 or protected classified (IOErrorEvent.IO_ERROR)

4 receive files - download (ProgressEvent.PROGRESS)

5 DOWNLOAD Complete (Event.COMPLETE)

Tags: Adobe Animate

Similar Questions

  • How to test an external URL to determine the return value

    Hello

    I would like to create a page in my apex-application for external monitoring of different URLS.
    When one of the external sites is affordable I show a green spot on my apex page for that URL. And when he is not available, it should show a red spot.

    Right now I use a URL-region with the source 'http://...:8888/test.html '. The value of which is to give back to the my apex-page is "oke", because that's what index.html.

    But when the site isn't here it returns "Not Found. Test1.html requested URL was not found on this server. »

    My question is how can I check the value of the URL area?

    Reg.
    Chris

    Using UTL_HTTP package try.
    You can read the page www inside the oracle, if error return request, you can assign red spot another Green site.

  • How to get the current URL to run in actionscript

    Hi all
    I try to get implementation actioscript URL,
    Please give me a way to do it.

    Thanks in advance,
    Prashant Shelke.

    You can use stage.loaderInfo.loaderURL to get the URL from which the SWF file has been loaded.

  • How to test DTMF to the unit

    How to test the sequience DTMF #X #2 in the unit. I have personal assistant on the system and when I send voive mail it says "I don't recognize that as a valid entry" unit is integrated with Domino.

    If you're component unit, pending so that he could respond and then entering DTMF? OK, so you don't need the leader ' # ' in your string to it. Assuming you get the opening greeting with your call, you can simply dial the extension of the user followed by #2 on turn the transfer rule.

    You can check what DTMF is entered and how the conversation flies with the Port status monitor tool that you will find in the depot of tools on your desktop - it must be reasonably obvious how the flow goes in looking at the output from that on a test call.

  • How to test my application of ADF mobile browser on Android emulator?

    Hello

    I created a Mobile browser app. Could someone tell me please how to test on the Android emulator?

    I read the information on downloading and configuring (Blackberry) simulators and emulators (Microsoft Windows) to browser Mobile ADF in 'Running Mobile Device simulators with JDeveloper and ADF Mobile'. However they mention no details on downloading and configuring "* Android emulators." Could someone help me please in the present.

    Concerning
    Raja

    If you want to test the browser applications Mobile ADF (those built with components of the Trinity) - then you run your application in the JDev, copy the URL and open in the browser, which is part of the Android emulator.

    If you want to test ADF Mobile apps - you deploy to the emulator, and then start the application like this:
    http://docs.Oracle.com/CD/E18941_01/tutorials/MobileTutorial/jdtut_11r2_54_2.html

  • Why, in the address bar in the url no but "go to website"? How can I see the url in the address bar?

    Why the address bar is not URL, but the "go on the web site? How can I see the URL in the address bar?

    Here's a few addons that other users have reported to cause the same problem in the past: Gom player, Ask Toolbar, DivX Web Player, RealPlayer Plugin browser Record (more)...

    in case you have one of them is present, try to disable/remove it - otherwise you could disable all extensions of your & re-enable each (a browser restart may be required after each step) until find you the culprit.

  • How to test the USB on Satellite Pro C870 speed?

    Hello

    Please I have connect WD item 10 B 8 USB drive to plug 750Go BLUE.
    Please how can test if USB3 uses full speed or lower connection USB2 bus?
    Brand of disk Crystal 3.03 said 31 MB/s reading and writing! (too low for USB3!)

    Thank you

    Hello

    You can use some freeware like tools
    -H2testw
    -Drive the speed Test 3.2
    I used the H2testw to SD card check and test USB memory stick and I was satisfied.

  • URL combo box: how to add or remove URLS?

    How to add or remove URLS in the URL drop-down list box?

    You cannot add entries to that drop-down list yourself, those that are managed automatically by giving bonuses visit (frecency algorithm).

    You can remove an entry highlighted by pressing the DELETE (SHIFT + DELETE on the Mac) key, unless they have a star and are my favorites.

    • Click on the (empty) input field on the web page to open the drop-down list
    • Select an entry in the drop-down list
    • Press the DELETE key (on a Mac: shift + delete) to remove it.
  • How can I correct the URL in the address bar?

    I tried to copy/cut a link of my address bar, and I must have hit some really obscure keyboard shortcuts and messed up how sees the Web page URL address bar. Now, he shows them on the right instead of the left. Here is a picture of what it looks like:

    http://oi51.Tinypic.com/123w8yf.jpg

    What bothers me absolutely and I want my URL to be to the left. How can I fix it? What weird command CTRL or CTRL + SHIFT I hit?

    You can change the orientation of the text bidi with Shift + Ctrl + X

    You can get this combination by accident while text cut with Ctrl + X or slipped into otherwise.

  • How to test a motherboard for fualts?

    Looking for means test a Toshiba Satellite L20/L25 for fualts. How to test to see if it has a graphics chip fail or its ram reading high because it sounds like the RAM fail if I go out and if I put it in it beeps once like it wants to start

    As far as I know that it can be tested using diagnostic tools special but these tools are not for public use and are designed by Toshiba to only service providers.

    Have you tested different RAM modules?

  • How to test the audio and the video on Android

    How to test audio and video on Android?

    How it is checked when installing Skype on Android?

    What I'm asking, is available in the desktop version to Tools-> Options-> Audio settings, and Tools-> Options-> video settings. And is checked during the installation of Skype for desktop PC as Configure Skype / check your audio and video files.

    (Of course I searched the whole Skype app and found no.) I have the echo service by my microphone is weak, I am lost.)

    Thank you.

    Sign in to your ID on Skype desktop and call your android phone to test

    It's something is broken, there is not that you can do, other than downgrading to an older version. There are also a couple of settings to activate the camera and photo qualityin settings in some versions.

  • How to test profibus is set up correctly?

    I profibus card installed in a PC.

    the pc is not installed LabVIEW. only testStand.

    purpose of this PC is like test panel for the execution of the TestStand test scenarios and this PC will be connected to the IO.

    How can test the profibus if there is no installed Labview?

    The vendor of your device must provide you with the GSD file. Each peripheral support profibus usually come with a GSD file.

  • "NaN" - how to test in VBAI <>- BT?

    I use VBAI to measure the length of a line.

    I use LabVIEW as the custom interface.

    In VBAI, I use "Update of Inspection" to send the data of length to LV

    How can I check in vi, that this figure is "NaN? This will happen when the line is not found.

    I tried to use ' NaN/path/RefNum"of the LV, but it simply doesn't.

    Help please...

    I don't know how you test this. I tried it and it works fine. Make sure the update of Inspection stage has the flag to 'Run the VI after update of the indicators'.

    If she still doesn't for you, let me know and I can send you a simple example (if you need an example, let me know what version of the VBAI you are using).

    Thank you

    Brad

  • How to test if the pc is connected to the TCP/IP protocol?

    Hello

    I have a VI how should the data received from another PC, using a TCP/IP connection.

    My VI could connect, receive data, but if I lose the connection im not able to reconnect, because I do not know how to test if my pc is connected to the other.

    Thank you for your help,

    Best regards

    salim_mjs wrote:

    Hey,.

    I was checking for error 66, I think that it check if the connection has been closed in order to reconnect

    do you not think that the error 56 or 60 are better?

    with respect,

    56 is the time-out. This will depend on your remote service if this should be considered as error or ignored. If it is a server application, it should certainly be able to respond within the time limit. But if your host application is the server and the remote application is the client it is very common to receive a time-out error when querying the client if it has new data to send.

    Order the examples mentioned previously, they really give you a good idea on how TCP/IP network communication must all work, even if there is still a lot to improve to create a truly reliable connection. But start from there come back if you get into trouble.

    Rolf Kalbermatter

  • How to test the domain controller security policy works or not?

    How to test the domain controller security policy works or not?

    So far, I put a security policy in the domain controller security policy, however, I do not affect client computers joined to the domain controller. and so far, if I apply the domain security policy work.

    LiuAlex

    Server must wonder about the Technet site.  http://social.technet.Microsoft.com/forums/en-us/home

Maybe you are looking for