Created
August 22, 2011 21:05
-
-
Save sfdesigner/1163565 to your computer and use it in GitHub Desktop.
Removing children Loader instances from inside a MovieClip
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
- A MovieClip is instantiated on the stage. In this example it is called removeMe | |
- A Loader class is created that loads a resource. The Loader class instance is added to the display stack within the removeMe MovieClip instance | |
- Another MovieClip is instantiated on the stage. This example names it clickMe. This MovieClip has an event listener attached to it listening for MouseEvent.CLICK, which then executes a callback function removeLoader() | |
- The removeLoader() event callback removes the Loader class instance from the display stack within the removeMe MovieClip instance | |
/* | |
import flash.display.Loader; | |
import flash.net.URLRequest; | |
import flash.events.MouseEvent; | |
var myLoader:Loader = new Loader(); | |
var myLoaderContent:URLRequest = new URLRequest("http://www.helpexamples.com/flash/images/image1.jpg"); | |
myLoader.load(myLoaderContent); | |
var removeMe:RemoveMe = new RemoveMe(); | |
stage.addChild(removeMe); | |
removeMe.x = 25; | |
removeMe.y = 25; | |
removeMe.addChild(myLoader); | |
var clickMe:ClickMe = new ClickMe(); | |
clickMe.x = 475; | |
clickMe.y = 25; | |
clickMe.addEventListener(MouseEvent.CLICK, removeLoader); | |
stage.addChild(clickMe); | |
function removeLoader(e:MouseEvent):void | |
{ | |
removeMe.removeChild(myLoader); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment