swf 内部库如下

Chat影片剪辑内有三个组建,TextArea,TextInput,Button,实例名非别是:textAtea,textInput,sendButton
Main.as
package
{
import flash.display.Loader;
import flash.display.LoaderInfo;
import flash.display.MovieClip;
import flash.events.Event;
import flash.net.URLRequest;
public class Main extends MovieClip
{
public function Main()
{
var swfLoader:Loader = new Loader();
var urlRequest:URLRequest = new URLRequest("asset.swf");
swfLoader.contentLoaderInfo.addEventListener(Event.COMPLETE,onComplete);
swfLoader.load(urlRequest);
}
private function onComplete(e:Event):void{
var l:LoaderInfo = e.target as LoaderInfo;
var Chat:Class = l.applicationDomain.getDefinition("Chat") as Class;
var chat:MovieClip = new Chat() as MovieClip;
var sendButton:* = chat.getChildByName("sendButton");
var textArea:* = chat.getChildByName("textArea");
var textInput:* = chat.getChildByName("textInput");
sendButton.label = "send";
chat.x = 100;
chat.y = 50;
this.addChild(chat);
}
}
}
本文介绍如何在AS3中加载外部SWF文件,并详细说明了加载的SWF内部包含的Chat影片剪辑,其中含有TextArea、TextInput和Button三个组件,实例名分别为textArea、textInput和sendButton。
4685

被折叠的 条评论
为什么被折叠?



