Đang chuẩn bị liên kết để tải về tài liệu:
Essential ActionScript 3.0 PHẦN 10

Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ

Vị trí của tài sản (hình ảnh, tập tin swf, hoặc biểu tượng movie clip) để nhúng vào lĩnh vực văn bản chiều rộng tùy chọn của tài sản được nhúng Chiều cao tùy chọn của tài sản được nhúng vào tùy chọn liên kết ngang của tài sản được nhúng vào | When using getDefinition we must be sure the .swf file instance has initialized before we attempt to access its symbols or classes. To do so we register with the embedded asset object s Loaderinfo object for Event.INIT events. Depending on how the .swf file was embedded we access Loaderinfo in different ways. If the .swf file was embedded directly at the variable level we use the following code to register for Event.INIT events Instantiate the asset object var embeddedInstance MovieClipLoaderAsset new ClassName Register for Event.INIT Loader embeddedInstance.getChildAt 0 .contentLoaderInfo.addEventListener Event.INIT initListener In the preceding code ClassName is the variable that refers to the class representing the embedded .swf file embeddedInstance is an instance of ClassName and initListener is a reference to the function that will execute when the instance is initialized. On the other hand if the .swf file was embedded as binary data we use the following code to register for Event.INIT event notification Instantiate the asset object var binarydata ByteArrayAsset new BinaryData Generate a display object representing the .swf file var loader Loader new Loader loader.loadBytes binarydata addChild loader Register for Event.INIT loader.contentLoaderInfo.addEventListener Event.INIT initListener where BinaryData is the variable that refers to the class representing the embedded .swf file s binary data binarydata is an instance of BinaryData and initListener is once again a reference to the function that will execute when the .swf file instance is initialized. The following code shows an example Event.INIT event listener that retrieves a reference to a movie-clip symbol s class named Ball. The code also creates an instance of the Ball symbol and adds it to the initListener s class s display hierarchy. private function initListener e Event void Obtain a reference to the Ball symbol from the embedded .swf file var BallSymbol Class .