I know exactly what this function is doing, however I don't know how to change it so that the 3 symbols only ever add once and only the bitmaps change. Thank you for your help! It's probably something simple, but I can't seem to figure it out, I am an intermediate as3 programmer but still have some holes in my knowledge.
var randCount:int = 3
function loadImage():void
{
for(var i:int = 0; i<randCount; i++)
{
var imgLoader:Loader = new Loader();
var imgRequest:URLRequest = new URLRequest();
imgRequest.url = "../img/planet" + int(2*Math.random()) +".png";
trace(imgRequest.url);
imgLoader.load(imgRequest);
imgLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoadedImg);
}
}
function onLoadedImg(e:Event):void
{
e.currentTarget.removeEventListener(Event.COMPLETE, onLoadedImg);
var bmp:Bitmap = e.currentTarget.content;
bmp.x = 600;
bmp.y = Math.random() * 520;
bmp.width = 80;
bmp.height = 80;
addChild(bmp);
}
button.addEventListener(MouseEvent.CLICK, changeBitmap);
function changeBitmap(event:MouseEvent):void {
loadImage();
}
guessing you ask the question that way because you are just adding more bitmap on top of the previous ones and by "change bitmap" you mean adding new ones.
You need to remove the ones you added previously and then you can add new ones. For example a simple change: