我真的好奇为什么会这样.我创建了两个对象.一个是另一个孩子.我在事件监听器ADDED_TO_STAGE中注册了两个.classB中的onAdded方法执行两次.
为什么会发生这种情况?如何防止这种行为?
thanx回答
public class ClassA extends Sprite
{
public function ClassA ()
{
this.addEventListener(Event.ADDED_TO_STAGE, onAdded);
}
private function onAdded(e:Event):void
{
trace("ON ADDED 1");
var classB : ClassB = new ClassB();
addChild(classB);
}
}
public class ClassB extends Sprite
{
public function ClassB ()
{
this.addEventListener(Event.ADDED_TO_STAGE, onAdded);
}
private function onAdded(e:Event):void
{
trace("ON ADDED 2");
}
}
Run Code Online (Sandbox Code Playgroud)
OUTPUT:ON ADDED 1 ON ADDED 2 ON ADDED 2
我有与服务器通信的Flash游戏.如果出现问题,我想显示弹出窗口.有什么东西被按下确定按钮刷新游戏.
btnHolder.addEventListener(MouseEvent.CLICK, refreshPage);
private function refreshPage(e:MouseEvent):void
{
...
}
Run Code Online (Sandbox Code Playgroud)
我怎样才能做到这一点 ?这甚至可能吗?或者我可以做的最多只是弹出文本"刷新浏览器".
我创建了哈希.比我在控制台上打印它.复制哈希值并将其放入代码进行比较.但它产生的不一样.
String input = "Hello";
String key = "Key";
Byte[] hashKey = Encoding.UTF8.GetBytes(key);
HMACSHA1 hmac = new HMACSHA1(hashKey);
Byte[] computedHash = hmac.ComputeHash(Encoding.UTF8.GetBytes(input));
String computedHashString = Encoding.UTF8.GetString(computedHash);
Console.WriteLine("Hash value of your input: .{0}.", computedHashString);
if ("?:????W?u$YLR;???T?j" == computedHashString)
{
Console.WriteLine("They are same!");
}
else
{
Console.WriteLine("They are NOT same!");
}
Console.ReadLine();
Run Code Online (Sandbox Code Playgroud)

先感谢您