actionscript 3 - add Loader to stage from class -


Stage seems to be unattainable in my class .. almost seems that it can not be scaled up. I do not know what is going wrong, this is the same class as I am now:

  package {import flash.events *; Import flash.display. *; Import Flash.net *; Public class gallery Sprite (private var imgPath: String = 'images /'; private var imgCurrent: int = 0; personal animosity Images: Arre = new Arre (); personal animosity iLoader: Loader; Function Gallery () {ThiskaddEventListener ( Event.ADDED_TO_STAGE, on add Torej);} added private function Gyastostej (e: Event): void {it KremoveEventListener (event. on ADDED_TO_STAGE, Adedtaotej); SayStage ();} public function says Staj (): void { Trace (this.stage);} public function setImgs (val: Array): zero {for (var index: string in value) {images ndex] = val [index];}} public function GetImgs (): void {(var index: string images) {trace (index + ':' + Pictures [index] + ";");}} public function loadImg (): void {iLoader = new loader (); ILoader.contentLoaderInfo.addEventListener (Prgtipradrshn. progress, Prgtisthl); ILoader.contentLoaderInfo.addEventListener (Event. Comple, Onloder Reedi); Var file request: URLRequest = new URLRequest (ImgPath + 'testimg.JPG'); iLoader.load (fileRequest); } Public work on progress status (E: progress event) {Tres (E. Byte Loaded, E. Bietstall); } Public Function Onloader Readie (E: Event) {stage.addChild (iLoader); // Error! } Public work updateImgCurrent (val: int): zero {imgCurrent = imgCurrent + val; } Public event getImgCurrent (): int {return (imgCurrent); }}   

}

And it is my Svif file:

  var gal: gallery = new gallery (); Var Image Gallery: Array = New Array (); ImagesGallery.push ('testimg.JPG'); ImagesGallery.push ('img2.JPG'); ImagesGallery.push ('img3.JPG'); Gal.setImgs (imagesGallery); Gal.loadImg ();   

The problem is adding iLoader to the forum when I do this, I get an error:

  TypeError: Error # 1009: An empty object Can not access the reference property or method. RD / on Gallery / Onloader   

Why can not I go to the stage? Or is it wrong that what I am trying to achieve and should I see the stage in another way? I really hope that you can help me in many ways in advance! If the display object is not added to the Display list, its Stage property is empty

.
Once you add it to the display list, then this platform will be set in context of the object. Try it:
  var gal: gallery = new gallery (); AddChild (gal); // This will speed up the ADDED_TO_STAGE event and will start the properties of the stage Image Gallery: Array = new Array (); ImagesGallery.push ('testimg.JPG'); ImagesGallery.push ('img2.JPG'); ImagesGallery.push ('img3.JPG'); Gal.setImgs (imagesGallery); Gal.loadImg ();    

Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

github - Teamcity & Git - PR merge builds - anyway to get HEAD commit hash? -

ios - Replace text in UITextView run slowly -