as3里 undefined与"undefined"的区别

很明显,undefined是as3的关键字,"undefined"是一个字符串,两者完全不同。但是在使用的时候有可能会弄糊涂

比如,在网页里嵌入flash


<embed width="400" height="300" flashvars="p2=undefined" src=" ./Test.swf" type="application/x-shockwave-flash" wmode="opaque" allowfullscreen="true" allowscriptaccess="always">

as3代码


package

{

import flash.display.Sprite;

import flash.events.Event;

import flash.external.ExternalInterface;

public class Test extends Sprite

{

public function Test()

{

stage ? init() : this.addEventListener(Event.ADDED_TO_STAGE, onAddedToStage);

}

private function onAddedToStage(evt:Event):void

{

this.removeEventListener(Event.ADDED_TO_STAGE, onAddedToStage);

init();

}

private function init():void

{

var parameters:Object = stage.loaderInfo.parameters;

ExternalInterface.call("console.log", parameters.p1 == undefined);

ExternalInterface.call("console.log", (parameters.p2 == undefined) + " : " + typeof(parameters.p2));

}

}

}

输出结果(在浏览器控制台看):

true

false : string

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容