문제

I'm using the following code to display an advertisement in a mobile game that I'm working on. It works fine but I don't know what to put in the clickStart function to remove the advertisement from the stage before the game plays. I've been playing around with removeChild but can't seem to get it to work.

stop();
startButton.addEventListener(MouseEvent.CLICK,clickStart);

function clickStart(event:MouseEvent) {
gotoAndStop("play");
}


var request:URLRequest = new URLRequest("http://soma.smaato.com/oapi/reqAd.jsp");
var variables:URLVariables = new URLVariables();
variables.adspace = "0";
variables.pub = "0";

variables.devip = "127.0.0.1";
variables.format = "IMG";
variables.adcount = "1";
variables.response = "XML";
request.data = variables;
var loader:URLLoader = new URLLoader();

loader.addEventListener(Event.COMPLETE, onComplete);
loader.load(request);


function onComplete(e:Event):void
{
var data:XML = new XML(loader.data as String);
var status:String = data.*::status.toString();
    if(status == "success")
    {
    var ad:XMLList = data.*::ads.*::ad;
    var link:String = ad.*::link.toString();

    var l:Loader = new Loader();
    l.load(new URLRequest(link));
    addChild(l);
l.x = 135;
l.y = 265;
    var clickurl:String = ad.*::action.@target.toString();
    l.addEventListener(MouseEvent.CLICK, onAdClick);

    function onAdClick(e:MouseEvent):void
    {
    var request:URLRequest = new URLRequest(clickurl);
    navigateToURL(request);
    }

  }
}

올바른 솔루션이 없습니다

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top