+ -
当前位置:首页 → 问答吧 → 大家能不能帮我改一下这个代码,这是AS2.0,改成AS3的代码规范。

大家能不能帮我改一下这个代码,这是AS2.0,改成AS3的代码规范。

时间:2011-03-16

来源:互联网

function createRef(p_source:MovieClip) {
       var bd:BitmapData = new BitmapData(p_source._width, p_source._height, true, 0);
       var mtx:Matrix = new Matrix();
       mtx.d = -1;
       mtx.ty = bd.height;
       bd.draw(p_source, mtx);
       var width:Number = bd.width;
       var height:Number = bd.height;
       mtx = new Matrix();
       mtx.createGradientBox(width, height, Math.PI/2, 0, 0);
       var shape:MovieClip = createEmptyMovieClip("shape", getNextHighestDepth());
       //进行线性填充
       shape.beginGradientFill("linear", [0, 0], [60, 0], [0, 255], mtx);
       shape.lineTo(width, 0);
       shape.lineTo(width, height);
       shape.lineTo(0, height);
       shape.endFill();
       shape._visible = false;
       var mask_bd:BitmapData = new BitmapData(width, height, true, 0);
       mask_bd.draw(shape);
       bd.copyPixels(bd, bd.rectangle, new Point(0, 0), mask_bd, new Point(0, 0), false);
       var refMC:MovieClip = createEmptyMovieClip("refMC", getNextHighestDepth());
       refMC._x = p_source._x;
       refMC._y = p_source._y+p_source._height;
       refMC.attachBitmap(bd, 0, "Auto ", true);
}

包含的错误有:
1180: 调用的方法 createEmptyMovieClip 可能未定义。
1119: 访问可能未定义的属性 rectangle (通过 static 类型 flash.display:BitmapData 引用)。
1180: 调用的方法 createEmptyMovieClip 可能未定义。
1180: 调用的方法 getNextHighestDepth 可能未定义。

作者: futureengineer   发布时间: 2011-03-16

引用:
原帖由 flash023 于 2010-1-27 18:24 发表


楼主不要着急,注册完了就开始学,要不了多久就能实现了。
学习过程中遇到问题了,讨论问题适合发到这个版块
同类型参考帖:
http://flash.9ria.com/thread-40222-1-1.html

http://bbs.blueidea.com/thread-2969547-1-1.html
http://bbs.blueidea.com/thread-2970302-1-1.html
http://space.flash8.net/bbs/thread-397925-1-1.html

作者: flash023   发布时间: 2011-03-16

热门下载

更多