将旧版 as1/2 代码转换为 as3
我有一个在互联网上下载的 .swf 文件,它是一个动画,我非常希望将它放在我的 .swf 中,但是,当我加载它并尝试控制 .swf 时,我收到错误代码。 TypeError:错误 #1034:类型强制失败:无法将 flash.display::AVM1Movie@10d52701 转换为 flash.display.MovieClip。
我在网上搜索了这个错误,这是因为 .swf 是在 as1/2 中编译的,因此我无法获取它的“对象”并控制它。
我还反编译了.swf并阅读了代码,但代码大部分是在as1/2中完成的,我不知道它是做什么的,因为我刚刚开始学习as3,并且从未接触过as1/2。
有人知道我能做什么吗?下面是反编译的代码,据我了解,它用于“移动”动画的各个部分。这是“鱼”身体的一部分,创造出非常流畅的游泳动作。我尝试将其转换为 as3 代码,但出现找不到变量的错误。
function corps(objet)
{
i = 0;
for (;;)
{
if (i >= 8)
{
return;
}
tourne = Math.cos(i + getTimer() / (400 - m)) * 9;
objet["p" + i]._rotation = (0 - tourne) / 2;
objet.p5["p" + i]._rotation = 0 - tourne;
objet.p5.p4["p" + i]._rotation = 0 - tourne;
objet.p5.p4.p3["p" + i]._rotation = 0 - tourne;
objet.p5.p4.p3.p2["p" + i]._rotation = 0 - tourne;
objet.p5.p4.p3.p2.p1["p" + i]._rotation = (0 - tourne) / 2;
++i;
}
}
function fish(objeti)
{
if (objeti._x && objeti._y)
{
corps(objeti);
}
}
var j = Math.random(20) * 7 - 5;
var m = Math.random(50) * 2;
j = 4;
m = 4;
k = 0;
u = 0;
v = 1;
this.poisson.s = 1;
this.poisson.vari = this.poisson._width / 10 + this.poisson._height / 10;
this.onEnterFrame = function ()
{
fish(this.poisson);
}
;
i have a .swf which i have downloaded on the internet it is a animation that i would very much like to have it in my .swf however, when i am loading it and trying to control the .swf i get a error code.
TypeError: Error #1034: Type Coercion failed: cannot convert flash.display::AVM1Movie@10d52701 to flash.display.MovieClip.
i searched the net for this error and it is because the .swf is compiled in as1/2 therefore i am unable to get it's "object" and control it.
i have also decompiled the .swf and read the codes, but the codes are mostly done in as1/2 and i have no clue what it does, as i just started learning as3 , and have never touched as1/2.
anyone have any idea what can i do?the below is the code decompiled, from what i understand it is used to "shift" the parts of the animation. which is a "fish" body part, to create a very smooth, swimming action. i have tried converting it to as3 code but i get errors where it cant find the variables.
function corps(objet)
{
i = 0;
for (;;)
{
if (i >= 8)
{
return;
}
tourne = Math.cos(i + getTimer() / (400 - m)) * 9;
objet["p" + i]._rotation = (0 - tourne) / 2;
objet.p5["p" + i]._rotation = 0 - tourne;
objet.p5.p4["p" + i]._rotation = 0 - tourne;
objet.p5.p4.p3["p" + i]._rotation = 0 - tourne;
objet.p5.p4.p3.p2["p" + i]._rotation = 0 - tourne;
objet.p5.p4.p3.p2.p1["p" + i]._rotation = (0 - tourne) / 2;
++i;
}
}
function fish(objeti)
{
if (objeti._x && objeti._y)
{
corps(objeti);
}
}
var j = Math.random(20) * 7 - 5;
var m = Math.random(50) * 2;
j = 4;
m = 4;
k = 0;
u = 0;
v = 1;
this.poisson.s = 1;
this.poisson.vari = this.poisson._width / 10 + this.poisson._height / 10;
this.onEnterFrame = function ()
{
fish(this.poisson);
}
;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
看起来您需要将一个
poisson
实例放置在舞台上并命名。是在图书馆吗?请务必将实例命名为poisson
。Looks like you need an instance of
poisson
to be placed on the Stage and named. Is it in the library? Be sure to name the instancepoisson
.您需要将所有以
_
开头的属性更改为其相应的 AS3 属性。即_width
应该是width
并且_rotation
应该是rotation
,对_width、_height、_x 执行此操作,_y,_旋转
。You need to change all the properties that begin with an
_
to it's corresponding AS3 property. I.e._width
should bewidth
and_rotation
should berotation
, do this for_width, _height, _x, _y, _rotation
.