View Full Version : Why is my image disappearing when I add another one to the stage...

10-13-2009, 04:33 PM
Hi, not completely sure on best title for this but whats happen is I have tried everything i've come across and read and still my image is disappearing.

Problem is. I add to a movieClip a number of images from an array, to be thumbnails using a Loader object, then into a bitmap Object, then into a movieClip object. The movieClip objects are added to a movieClip on the stage and resized and also eventListeners are added. This works fine.

Next when I click on a thumbnail movieClip, I make a new main movieClip which is to store a bitmap. The bitmap I get from the same array as I got all the previous images (in the correct array position using a variable). This is then added to another movieClip which is on the stage. This all works fine but (and he's the teaser) for the life of me I cannot see why when the main movieClip is added to the stage movieClip, the thumbnail one disappears!

I have no removeChilds, nothing is covering it, no unload();, so I must assume its just getting removed from the displayList for some weird reason. I've even tried using two Loader's and ton's of bitmap to movieClip to an array to try to get two copies of it but to no avail.

please see my code below and offer any help, many thanks in advance.

private function buildThumbArray()
for(thumbArray = 0; thumbArray < loadImage.array.length; thumbArray++) // takes each image in array and puts on sliderbar
thumbImageStore = new Loader();
thumbImageStore = loadImage.array[thumbArray]; // load next image into temporary image storage
thumbImage = thumbImageStore.content; // stores as a bitmap
bigImage = thumbImageStore.content; // store as another bitmap
bigImageArray[thumbArray] = bigImage; // store in an array
var thumbnail:MovieClip = new MovieClip(); // make new MovieClip to display bitmap in
thumbnail.addChild(thumbImage); // add thumbImage bitmap to thumbnail Movieclip
getImage.maskedSprite.addChild(thumbnail); // add image as child of maskedSprite
thumbnail.name = thumbArray; // give MovieClip a name as not sure how to rename from instance29,28, etc
thumbnail.width = thumbnail.width *0.3; // resize thumbnail
thumbnail.height = thumbnail.height *0.3; // resize thumbnail
if (thumbArray == 0) // if first time through move to better x position to give a space to side
thumbnail.x = thumbnail.x + 10; // move MovieClip to better position
thumbnail.x = thumbnail.x + spaceBetween + tempImageSizeW; // this image x pos (=0) + sets up space between + previous image size and its x postion)
tempImageSizeW = thumbnail.x + thumbnail.width; // this stores the images x pos added to its width
tempImageSizeH = thumbnail.height; // store movieClips height for later
thumbnail.y = (heightOfSlider - thumbnail.height) / 2 ; // this centre's the images on the horizontal. 100-90 = 10. 10/2 = 5 which is space to move y down.

thumbnail.addEventListener(MouseEvent.MOUSE_DOWN, clicked); // add event to for click on thumbnail movieclip

private function clicked(event:MouseEvent):void
removeImage(); // this removes previous full size image from stage (works ok)
store = event.target.name; // variable to store which thumbnail mc was clicked
var bigImage_mc:MovieClip = new MovieClip; // make yet another mc to try to store image in
bigImageMovieClip = bigImage_mc; // used to store so can get round unique production of bigImage_mc on every run
bigImage_mc.addChild(bigImageArray[store]); // add correct image from array to bigImage_mc
imageW = bigImage_mc.width; // store width
imageH = bigImage_mc.height; // store height
clearPicBackGnd_mc.addChild(picBackGnd_mc); // picBackGnd is graphic used to give a resizing border (works ok)
picBackGnd_mc.x = 0;
picBackGnd_mc.y = 0;
//picBackGnd_mc.width = 420; // can be used to set initial size
resizePicBackGnd(); // run picBackgnd resize function (works ok)

private function addImage() // this function runs when resizePicBackGnd has finished resizing
if(picBackGnd_mc.height == (imageH + 10) && picBackGnd_mc.width == (imageW + 10)) // says if picBackGnd graphic is right size run this code
clearPicBackGnd_mc.addChild(bigImageMovieClip); // add as a child my full size image
bigImageMovieClip.x = xCentrePos - (bigImageMovieClip.width / 2); // used to centre
bigImageMovieClip.y = yCentrePos - (bigImageMovieClip.height / 2); // used to centre

10-13-2009, 07:08 PM
Unfortnately without seeing all of our code it is hard to pin point the problem. Usually things disappear because they are either removed or replaced. Do you use the same movieClip to store anything in 2 different locations? The same var to store 2 different instances of the image somewhere along the line?

10-14-2009, 12:41 PM
OK, the code in my ImageLoader class maybe helpful as its the only code missing. I'll upload it later. Thanks