A JavaScript Fancier

伟大的javascript技术研究中...

  IT博客 :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理 ::
  304 随笔 :: 0 文章 :: 479 评论 :: 0 Trackbacks


今天看liveDocs学习FLASH AS,看到了Using variables in an application一部分。
有这么一段教程:
 
To compare undefined and defined variables being passed to a function:
Drag a Button component to the Stage from the Components panel.
Open the Property inspector and type bad_button into the Instance Name text box.

Type the following code on Frame 1 of the Timeline.// Does not work
function badClickListener(evt:Object):Void {
    getURL(targetUrl);
    var targetUrl:String = "http://www.adobe.com";
}
bad_button.addEventListener("click", badClickListener);


Select Control > Test Movie, and notice that the button does not work (it doesn't open the web page).

按照示例说明俺就去画瓢了,没想到这瓢还真没那么好话,按下ctrl+enter控制台就报错了:“语句必须出现在 on/onClipEvent 处理函数中”,郁闷了,按照示例去做还能有错?难道adodb的示例没有做过试验就贴出来了?不太可能!
去网上狂搜,找到不少垃圾网页,找到不少不疼不痒的答案,不过经过最后努力还是发现了一个答案:“你把他们写到帧上就可以了”,突然意识到自己可能将as写到了按钮实例上了,检查了一下果真如此,感觉改正,一切正常了。
原来这个flash只有一帧,而且上面有一个按钮组件实例,将按钮拖到舞台后,直接就打开了AS窗口写AS,结果就写到了实例上了,而没有写到帧上。还真是要小心的以后。脚本要写在应该写的地方,FLASH与JS相比,FLASH有很多实实在在的对象,可以摸得着看得见对象,如元件实例,帧等。
posted on 2008-05-22 10:57 Yemoo'S JS Blog 阅读(4995) 评论(0)  编辑 收藏 引用 所属分类: 其它技术文章
只有注册用户登录后才能发表评论。