开发者

Strange Behavior of AS2 swf breaking when loaded into AS3 swf can any one explain as to why this is?

开发者 https://www.devze.com 2022-12-19 10:48 出处:网络
The ide i am using is flash cs3. the as2 swf contains a tween code using mx transitions. when i remove this tween code and hard code it on the enterframe there seems to be no problem.

The ide i am using is flash cs3. the as2 swf contains a tween code using mx transitions. when i remove this tween code and hard code it on the enterframe there seems to be no problem. afaik avm2 should fully supports the as2 and as1 code. so i am unable to understand why this disparity when coding a simple tween in as2 swf. i had made a post in the actionscript forums hoping to gain some light on the issue. with a very simple attachment illustrating the issue http://www.actionscript.org/forums/showthread.php3?t=229901 p.s the 2 swf do not interact with each other. the code in as2 file

//~~~~~~~~~~~~~~~~~~~~~~~ with tween 开发者_开发问答class
import mx.transitions.*;
import mx.transitions.easing.*;

function tweenMe(mc, target) {
myTween = new Tween(mc, "_x", Regular.easeOut, mc._x, target, 2, true);
}
tweenMe(mc, 700);

//~~~~~~~~~~~~~~~~~~~~~~~ Simple Hard coded control

/*this.onEnterFrame = function() {
    mc._x += (700-mc._x)/10;
};
*/


I don't think you can use _x while using AS3 Tween Class. Your Actionscript-2 swf will be treated as AVM1Movie object (descendants of DisplayObject). And in ActionScript-3, DisplayObject doesn't have property _x. So Try using:

function tweenMe(mc, target) {
myTween = new Tween(mc, "x", Regular.easeOut, mc.x, target, 2, true);
}
tweenMe(mc, 700);
ActionScript-3 Documentation says this: The AVM1Movie object can use methods and properties inherited from the DisplayObject class (such as x, y, width, and so on). However, no interoperability (such as calling methods or using parameters) between the AVM1Movie object and AVM2 objects is allowed.


the only convincing answer i had come across regarding this problem was this

http://www.actionscript.org/forums/showpost.php3?p=968206&postcount=9

depending upon situation it might be easier to just re-code the trouble code bit.

0

精彩评论

暂无评论...
验证码 换一张
取 消