Wednesday, June 13, 2012

[Action Script] Problem removing child June,2012

I'm having a problem removing an image that it is called up externally. Here is the code on the first frame:

Code: stop();

import flash.net.URLRequest;
import flash.display.Loader;

var myFileRequest = new URLRequest("SampleImage.jpeg");
var myFileLoader:Loader = new Loader();

home.addEventListener(MouseEvent.CLICK, goToHome);

function goToHome(event:MouseEvent):void
{
        SoundMixer.stopAll();
        gotoAndStop("home");
        if (contains(myFileLoader))
        {
                removeChild(myFileLoader);
        }
}


about.addEventListener(MouseEvent.CLICK, goToAbout);

function goToAbout(event:MouseEvent):void
{
        SoundMixer.stopAll();
        gotoAndStop("about");
}

animation.addEventListener(MouseEvent.CLICK, goToAni);

function goToAni(event:MouseEvent):void
{
        gotoAndStop("boat");
        if (contains(myFileLoader))
        {
                removeChild(myFileLoader);
        }
}I call the image up on the 6th frame by clicking the about button, here is the code:

Code: myFileLoader.load(myFileRequest);
addChild(myFileLoader);
trace(myFileLoader.numChildren);

myFileLoader.scaleX = 0.5;
myFileLoader.scaleY = 0.5;
myFileLoader.x = 200;
myFileLoader.y = 150;When I click on the home button it does not get rid of the image, please help.
Problem removing child

Related Post



0 comments: