[英]How to load a SWF compiled by Flex into a SWF compiled by Flash CS4
我使用Flex 3.5(还尝试了Flex 4.1)编译了一个简单的AS3项目,以创建一个小的swf,在屏幕上绘制一个简单的红色正方形。 没什么太复杂的,需要特殊的Flashplayer支持(请参见下面的代码)
package
{
import flash.display.Sprite;
/**
* @author John Lindquist
*/
[SWF(width="1024", height="768", frameRate="24")]
public class EasingATimeline extends Sprite
{
private var square:Sprite;
private static const STEP_DURATION:Number = 1;
public function EasingATimeline()
{
square = new Sprite();
square.graphics.beginFill(0xcc0000);
square.graphics.drawRect(0, 0, 50, 50);
square.graphics.endFill();
square.x = 100;
square.y = 50;
addChild(square);
}
}
}
并尝试将其加载到我使用Flash CS4进行编译的AS2 SWF文件中。 但这只是行不通。 加载时我没有收到任何错误,并且AS2 SWF可以加载任何SWF文件,无论是通过Flash在AS2还是AS3中进行编译。
有任何想法吗?
Flex / Flash构建器仅适用于as3。 因此,您无法将其加载到as2 swf中。 但是,您可以在Flash中创建一个新的as3文件,并同时加载as2 swf和flex swf并进行相应定位。 在as3中加载swfs很容易:
var as2:Loader = new Loader();
as2.load(new URLRequest("myAS2Thing.swf"));
as2.addEventListener(Event.COMPLETE, onDoneLoadingAS2);
function onDoneLoadingAS2(e:Event):void{
as2.x = 100;
as2.y = 100;
addChild(as2);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.