Question
AS3: Replacing a loaded image..?
I'm stuck with an button-event that load an image into a
container.
( the code: mb1.button.addEventListener(MouseEvent.CLICK,ClickEvent1);
function ClickEvent1(myEvent:MouseEvent):void
{
var pynt:URLRequest = new URLRequest("icon01.png");
var pyntLoader1:Loader = new Loader();
var pyntLoader2:Loader = new Loader();
pyntLoader1.load(pynt);
pyntLoader2.load(pynt);
p1.addChild(pyntLoader1);
p2.addChild(pyntLoader2);
}
)
At this stage there's no problem loading the image.
But when hitting another button created I want the image to be removed from the containers and replaced with a new image ( icon02.png).
It's easy, right? Wrong!!
By using removeChild() i should be able to remove the image in the containers... But it won't work.
At one point it removes the image but I'm unable to load a new image.
Do I also have to remove/unload other functions/events?
I've tried to use unload() but I'm getting an error saying that unload() is not a function...
When learning the basics of coding you need to understand the logic behind the bolts and nuts. With AS3 I get the feeling that the logic within the codes is well hidden. Isn't that like moving in the wrong direction?
Anyway, I really hope I can get some help with this... I'm about to invest the rest of my money in the biggest sledgehammer in the world... And then it's bye, bye my computer... !!
( the code: mb1.button.addEventListener(MouseEvent.CLICK,ClickEvent1);
function ClickEvent1(myEvent:MouseEvent):void
{
var pynt:URLRequest = new URLRequest("icon01.png");
var pyntLoader1:Loader = new Loader();
var pyntLoader2:Loader = new Loader();
pyntLoader1.load(pynt);
pyntLoader2.load(pynt);
p1.addChild(pyntLoader1);
p2.addChild(pyntLoader2);
}
)
At this stage there's no problem loading the image.
But when hitting another button created I want the image to be removed from the containers and replaced with a new image ( icon02.png).
It's easy, right? Wrong!!
By using removeChild() i should be able to remove the image in the containers... But it won't work.
At one point it removes the image but I'm unable to load a new image.
Do I also have to remove/unload other functions/events?
I've tried to use unload() but I'm getting an error saying that unload() is not a function...
When learning the basics of coding you need to understand the logic behind the bolts and nuts. With AS3 I get the feeling that the logic within the codes is well hidden. Isn't that like moving in the wrong direction?
Anyway, I really hope I can get some help with this... I'm about to invest the rest of my money in the biggest sledgehammer in the world... And then it's bye, bye my computer... !!