Trouble moving externally loaded image
I'm new to AS3 and I'm having a problem moving an externally loaded image within a Class. I'm just not sure how to move the externally loaded image. I thought of creating a Sprite and then moving an added child Sprite, to which I would then load the image. But I'm getting this error:
1119: Access of possibly undefined property spHolder through a reference with static type flash.display:Sprite.
I commented below where the error is being triggered:
==========================================
package {
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.events.Event;
import flash.display.Loader;
import flash.net.URLRequest;
public class SnapShot extends MovieClip {
public var strLink:String;
public var strImage:String;
private var spPolaroid:Sprite = new Sprite();
private var ldPhoto:Loader;
function SnapShot(strImg:String,strURL:String):void {
strLink = strURL;
strImage = strImg;
trace("New SnapShot");
spPolaroid.graphics.beginFill(0xCCCCCC);
spPolaroid.graphics.drawRect(0,0,120,140);
addChild(spPolaroid);
var spHolder:Sprite = new Sprite();
spHolder.x = 10;
spHolder.y = 10;
spPolaroid.addChild(spHolder);
loadImage(strImage);
};
private function loadImage(strUrl:String):void {
ldPhoto = new Loader();
ldPhoto.load(new URLRequest(strUrl));
ldPhoto.contentLoaderInfo.addEventListener(Event.COMPLETE, imageLoaded);
};
private function imageLoaded(evt:Event):void {
spPolaroid.spHolder.addChild(ldPhoto); // Here's where the error is hitting
};
};
};
==========================================