actionscript1.0与2.0和3.0他们之间有何区别? 40

 我来答
围观网民请理智点
2007-12-01 · TA获得超过1831个赞
知道小有建树答主
回答量:375
采纳率:0%
帮助的人:243万
展开全部
关于ActionScript 1.0、ActionScript 2.0、java的区别与联系——基于一个实例的讨论 :
问题:创建两个位置大小颜色各不同的可拖拽的矩形。

方法一:method1.fla //ActionScript 1.0
//Flash Player 6(含)以上
//ActionScript 1.0或ActionScript 2.0均可

createEmptyMovieClip ("rectangle1_mc", 1);
rectangle1_mc._x = 10;
rectangle1_mc._y = 10;
with (rectangle1_mc) {
beginFill (0xff0000, 100);
moveTo (0, 0);
lineTo (200, 0);
lineTo (200, 200);
lineTo (0, 200);
endFill ();
}
rectangle1_mc.onPress = startDrag;
rectangle1_mc.onRelease = rectangle1_mc.onReleaseOutside = stopDrag;
//
createEmptyMovieClip ("rectangle2_mc", 2);
rectangle2_mc._x = 50;
rectangle2_mc._y = 50;
with (rectangle2_mc) {
beginFill (0xffcc00, 100);
moveTo (0, 0);
lineTo (400, 0);
lineTo (400, 100);
lineTo (0, 100);
endFill ();
}
rectangle2_mc.onPress = startDrag;
rectangle2_mc.onRelease = rectangle2_mc.onReleaseOutside = stopDrag;
方法二:method2.fla //ActionScript 2.0
//Flash Player 6(含)以上
//必须为ActionScript 2.0

var rect1:Rectangle = new Rectangle (this, 10, 10, 200, 200, 0xff0000, 1);
var rect2:Rectangle = new Rectangle (this, 50, 50, 400, 100, 0xffcc00, 2);
delete rect1;
delete rect2;
delete Rectangle;
此方法必须得有一个Rectangle.as与之同路径。Rectangle.as内容如下:

class Rectangle extends MovieClip {
private var rectangle_mc:MovieClip;
public function Rectangle (target:MovieClip, x:Number, y:Number, w:Number,
h:Number, color:Number, depth:Number) {
rectangle_mc = target.createEmptyMovieClip ("rectangle_mc" + depth, depth);
rectangle_mc._x = x;
rectangle_mc._y = y;
with (rectangle_mc) {
beginFill (color, 100);
moveTo (0, 0);
lineTo (w, 0);
lineTo (w, h);
lineTo (0, h);
endFill ();
}
rectangle_mc.onPress = startDrag;
rectangle_mc.onRelease = rectangle_mc.onReleaseOutside = stopDrag;
}
}
方法三:method3.java //如果.java也可以直接编译.swf的话

public class method3{
public static void main(String[] args){
Rectangle rect1 = new Rectangle (this, 10, 10, 200, 200, 0xff0000, 1);
Rectangle rect2 = new Rectangle (this, 50, 50, 400, 100, 0xffcc00, 2);
//这里就不需要手动delete了,因为java有垃圾回收器,它会自动清除。
}
}
class Rectangle extends MovieClip {
private MovieClip rectangle_mc;
public Rectangle (MovieClip target, Double x, Double y, Double w, Double h,
Double color, Double depth) {
rectangle_mc = target.createEmptyMovieClip ("rectangle_mc" + depth, depth);
rectangle_mc._x = x;
rectangle_mc._y = y;
with (rectangle_mc) {
beginFill (color, 100);
moveTo (0, 0);
lineTo (w, 0);
lineTo (w, h);
lineTo (0, h);
endFill ();
}
rectangle_mc.onPress = startDrag;
rectangle_mc.onRelease = rectangle_mc.onReleaseOutside = stopDrag;
}
}
通过比较不难发现,ActionScript 1.0最灵活、最简单、最容易理解。但重复类似的操作时也会最繁琐。如果要画1000个位置大小颜色各不同的矩形的话,不累死也会被笑死! ActionScript 2.0则非常系统,单独用Rectangle.as定义了一个矩形类,使用时new即可,爽!有点小小的遗憾的是有几行delete,当然你也可以不加,让它永远霸占你的内存。再看看java,看完了又看,看完了再看,呵呵! 啥也不说了,谁老大肯定有人知道。

参考资料: http://blog.5d.cn/user9/Mars817/200510/173973.html

已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式