我将一个测试swf加载到一个类中。 swf有自己的代码,在单击时加载链接。这工作正常,但我想在单击swf时卸载该类。
如何在点击加载的内容时卸载课程?
我调用了函数“meow”,这是一个简单的随机名称,正如我正在测试的那样。 :)
以下是我所做的不起作用:
package
{
import flash.display.MovieClip;
import flash.events.Event;
import flash.display.Loader;
import flash.events.Event;
import flash.events.ProgressEvent;
import flash.net.URLRequest;
import flash.events.MouseEvent;
public class theAd extends MovieClip
{
public function theAd()
{
var my_loader:Loader = new Loader();
my_loader.load(new URLRequest("http://www.massmediamail.com/testing/Manga.swf"));
my_loader.contentLoaderInfo.addEventListener(Event.COMPLETE, startListener);
function startListener(e:Event):void
{
addChild(my_loader.content);
trace("Content Loaded");
my_loader.content.addEventListener(MouseEvent.CLICK, meow);
}
function meow(e:Event):void
{
//this.parent.parent.removeChild(this);
trace(this.name);
}
}
}
}
答案 0 :(得分:0)
您是否因正确删除loader.content
而遇到麻烦?您应该使用event.target
属性来获取正确的实例。
function meow(e:MouseEvent):void {
var mc:DisplayObject=e.target;
if (!mc) return;
mc.parent.removeChild(mc);
}