Skip to main content
Inspiring
December 11, 2011
Question

how to get loder content width???

  • December 11, 2011
  • 1 reply
  • 672 views

hi i have tried to get width of my thumbnail, it is loading and showing jpg image, I stuck to find it's width.

   ld=new Loader()

                              ld.load(new URLRequest(obj.@thumb))

                              addChild(ld)

                              ld.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS,preload)

private function preload(event:ProgressEvent):void{

     var gbt:int=event.bytesLoaded

     var gbl:int=event.bytesTotal

     var tl:int=Math.round((gbl/gbt)*100)

     if(TL==100){

          trace(ld.content.width)<<< return Null

          var mc:MovieClip=MovieClip(ld.content)

          trace(mc.width)

     }

}

This topic has been closed for replies.

1 reply

Ned Murphy
Legend
December 11, 2011

tl does not equal TL, so see if fixing that helps.  If not, assign a COMPLETE listener for the loaderContentInfo and use its event handler function to get the width after loading is complete

Inspiring
December 11, 2011

oops by mistake i type here wrong but in real code i wrote it tl.