0 Replies Latest reply on Mar 5, 2008 7:27 AM by _Cedric_


    _Cedric_ Level 1
      I'm doing some layout on an image.
      I let flex scale the image and keep aspect ratio and then i calculate how to center the image

      the width and heigth of the scaled image are available in contentWidth and contentHeigth.
      and these attributes are only available afther updateComplete, but this events get fired all the time when i debug so my app becomes really slow

      I only need to do the placement of the image once (when it is loaded)
      is there a better soluation? (i could also calculate the aspect ratio in actionscript if there is no solution)

      (mm can't find any 'attach code button')
      private function creationCompleteHandler(event:FlexEvent):void{
      imgLogo.source = this._logoPad;
      imgLogo.addEventListener(FlexEvent.UPDATE_COMPLETE, logoUpdateCompleteHandler);
      if (this.width > this.height){
      this._landscape = true;
      //vierkant gebied aanmaken, groote is afhankelijk van wat gebruiker opgeeft
      imgLogo.height = this.height * this._logoGrootte/100;
      imgLogo.width = imgLogo.height;


      private function logoUpdateCompleteHandler(event:FlexEvent){
      trace("image control");
      trace(imgLogo.width + " x " + imgLogo.height);

      trace("scaled image");
      trace(imgLogo.contentWidth + " x " + imgLogo.contentHeight);

      if (this._logoPositie == LINKS && this._landscape){
      var spatie:Number = (this.height - imgLogo.contentHeight)/2;
      imgLogo.y = spatie;
      imgLogo.x = spatie;