Hi, I am new to classes and object. I have just written a class file and I need an expert opinion about my class, so that I could learn more. I would like to know if we can make some improvement in the coding or whether the class is well encapsulated etc.
package {
import flash.display.*;
import flash.events.*;
import flash.net.*;
public class ShowCompletePic extends MovieClip {
private var imageLoader:Loader = new Loader();
private var loadPic_mc:MovieClip = new MovieClip();
private var url:String;
public function ShowCompletePic(path:String) {
url=path;
addChild(loadPic_mc);
imageLoader.load(new URLRequest(url));
loadPic_mc.addChild(imageLoader);
imageLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, imageLoading);
imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, imageLoaded);
}
private function imageLoaded(e:Event):void {
loadPic_mc.addChild(imageLoader);
loadPic_mc.x=(stage.stageWidth/2)-(loadPic_mc.width/2);
loadPic_mc.y=(stage.stageHeight/2)-(loadPic_mc.height/2);
stage.addEventListener(MouseEvent.MOUSE_MOVE,movePicture);
function movePicture(event:MouseEvent):void {
if (loadPic_mc.width>stage.stageWidth) {
loadPic_mc.x=-(loadPic_mc.width-stage.stageWidth)*parent.mouseX/stage.stageWidth;
}
if (loadPic_mc.height>stage.stageHeight) {
loadPic_mc.y=-(loadPic_mc.height-stage.stageHeight)*parent.mouseY/stage.stageHeight;
}
}
}
private function imageLoading(e:ProgressEvent):void {
trace((e.bytesLoaded / e.bytesTotal) * 100);
}
}
}
Thanks in advance