当前位置:首页 > 设计在线 > 平面动画 > Flash > flash8编程经典个案

flash8编程经典个案

点击次数:33 次 发布日期:2008-11-21 23:31:02 作者:源代码网
源代码网推荐

step 1: 打开flash8,新建一个项目,保存名为:helloworld.flp,这时在你的目录下有: helloworld.flp,helloworld.flp为flash项目文件。
step 2: 新建一个Flash ActionScript文件,以后我们称ActionScript为AS文件,保存名为:helloworld.as。在flash8时已经可以把AS另存一个文件了!好了,在你的文件中写入以下代码:

/*
原创:[url]http://www.oiasoft.com/[/url]
作者:korpton [email]korpton@163.com[/email]
日期:2006/10/13
*/
class helloworld{              
       public function sayHello(fWord:String):String{
              var hello:String = "Hello, " + fWord;
              return hello;
       }
}

保存。
step 3: 新建一个flash 文件,保存名为:helloworld.fla 文件,打开菜单: 窗口 -> 组件, 找到 User Interface 里面的 Label 组件,拖入场景中。选中刚才拖入的组件,在属性面板中,把刚才的Label 实例名输入: hello_lab。
step 4: 在你的时间轴上写下如下代码:

/*
原创:[url]http://www.oiasoft.com/[/url]
作者:korpton [email]korpton@163.com[/email]
日期:2006/10/13
*/
var myhello:helloworld = new helloworld();
hello_lab.text = myhello.sayHello("World");

step 5: helloworld.flas 和 helloworld.as 两个文件加入到项目中!打开项目窗口,菜单为:窗口->项目 快捷键为: shift+F8。在项目窗口中点选调试器 -> 添加文件 -> 加入刚才的两个文件即可完成加入项目。
step 6: 点选测试项目,按钮即可进行测试 helloworld 项目。注:第一次测试时直接选helloworld.fla文件即可。完成,over!

总结:在这个小的项目中你可以学到:
1. 如何进行一个项目的使用。
2. flash 中的 OOP 编程。
3. Label组件的使用。
4. Flash ActionScript 注释

原创: oiasoft.com !(联系:korpton@163.com)

helloworld.rar

源代码网供稿.
网友评论 (0)
会员中心
设计在线
本站推荐
设计在线之精华