If a display object is not added to the display list, its stage property is set to null
(source).
Once you add it to the display list, it will be set to a reference to the stage object.
Try this:
var gal:gallery = new gallery();
addChild(gal); // this will trigger ADDED_TO_STAGE event and initialize stage property
var imagesGallery:Array = new Array();
imagesGallery.push('testimg.JPG');
imagesGallery.push('img2.JPG');
imagesGallery.push('img3.JPG');
gal.setImgs(imagesGallery);
gal.loadImg();