/ Published in: ActionScript 3
Two different loading methods for external files.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
package { import flash.display.Sprite; import flash.display.Loader;//Allows you to load an external file import flash.net.URLRequest;//This is used to reference the external file import flash.filters.DropShadowFilter; public class LoadingMethods extends Sprite { public function LoadingMethods(){ init(); } private function init():void { /** Loading */ var loader:Loader = new Loader(); loader.load(new URLRequest("kitten.jpg")); addChild(loader); loader.x = 150; loader.y = 150; //For the loaded var ds2:DropShadowFilter = new DropShadowFilter(10, 45, 0x00ff00,1,3,2); var filterArray2:Array = [ds2]; loader.filters = filterArray2; /** Embedding **/ //This is from importing the image into the lib and exporting for AS. var myImage:Kitten = new Kitten(); addChild(myImage); //For the embed var ds:DropShadowFilter = new DropShadowFilter(10, 45, 0xff0000,1,3,2); var filterArray:Array = [ds]; myImage.filters = filterArray; } } }