Search code examples
actionscript-3adobe

Error Responce When Pinging A Website In Adobe Animate


i am trying to ping a website in Adobe Animate and i'm not sure where I have mixed up. The current code I have is below- Any help is appreciated <3

What is is meant to do: ping a website on the click of a button with the instance name HotelA (I have already got the crossdomain xml file)

Thank You -Regards, A.

HotelA.addEventListener(MouseEvent.CLICK, doThePing);


var ldr:URLLoader = new URLLoader();
ldr.addEventListener(HTTPStatusEvent.HTTP_STATUS, ldrStatus);

var url:String = "www.google.com.au";


function doThePing():void
{
    ldr.load(new URLRequest(url));
}

function ldrStatus(evt:*):void
{
    if(evt.status == 200)
    {
        doRedirect();
    }
    else
    {
        // there is an internet connection but the server returns something else (probably something is wrong with the server)
        doFailedRedirect();
    }
}
function doRedirect():void
{   
    gotoAndStop(1);
}

function doFailedRedirect():void
{   
    gotoAndStop(7);
}

The Error In "Output" I Am Seeing Is:

ArgumentError: Error #1063: Argument count mismatch on AssignTask_Working_fla::MainTimeline/doThePing(). Expected 0, got 1.

Solution

  • Add an input variable four your event listener function:

    ...
    function doThePing(event:MouseEvent):void
    {
        ldr.load(new URLRequest(url));
    }
    ...