Skip to main content
Known Participant
February 24, 2009
Answered

InlineGraphicElement sizing bug

  • February 24, 2009
  • 3 replies
  • 2540 views
When InlineGraphicElements width or height are set to 'auto', swfs have an unexpected aspect ratio. It looks like they try to be square, instead of using the DisplayObject's width and height.

var graphic:DisplayObject = new MyEmbeddedSwf();
var ige:InlineGraphicElement = new InlineGraphicElement();
ige.source = graphic;
This topic has been closed for replies.
Correct answer rdermer
I've submitted a fix to the auto size problem. It will be in build 381 and later.

Thanks again for the sample code.

3 replies

Known Participant
February 26, 2009
Awesome, thanks!
rdermerCorrect answer
Adobe Employee
February 26, 2009
I've submitted a fix to the auto size problem. It will be in build 381 and later.

Thanks again for the sample code.
Known Participant
May 11, 2009

HI ,

Can any one tell me why in attached source do i get incorrect actualWidth & actualHeight , I am using build 4.0.0.5156.

In case you dont want to bother downloading the attachment here the same

package

{

import flash.display.Sprite;

import flashx.textLayout.container.DisplayObjectContainerController;

import flashx.textLayout.conversion.TextFilter;

import flashx.textLayout.edit.EditManager;

import flashx.textLayout.edit.UndoManager;

import flashx.textLayout.elements.Configuration;

import flashx.textLayout.elements.InlineGraphicElement;

import flashx.textLayout.elements.InlineGraphicElementStatus;

import flashx.textLayout.elements.TextFlow;

import flashx.textLayout.events.CompositionCompletionEvent;

import flashx.textLayout.events.StatusChangeEvent;

public class TextLayoutFormatBackgroundColor extends Sprite

{

public function TextLayoutFormatBackgroundColor()

{

var s:Sprite = new Sprite()

s.x = 10

s.y = 10

s.graphics.lineStyle(1,0,1)

s.graphics.drawRect(0,0,400,400)

this.addChild(s)

var tfMarku:String = '<TextFlow paddingLeft="inherit" paddingTop="inherit" paddingRight="inherit" paddingBottom="inherit" verticalAlign="inherit" lineBreak="inherit" whiteSpaceCollapse="preserve" xmlns="http://ns.adobe.com/textLayout/2008">' +

'<p>' +

'<span>No bg .....</span>' +

'<img source="aaa" />' +

'<span backgroundColor="16711680" backgroundAlpha="1">asd asd asd asd sad asd</span>' +

'<span>No bg .....</span>' +

'</p>' +

'</TextFlow>'

var tf:TextFlow = TextFilter.importToFlow(tfMarku,TextFilter.TEXT_LAYOUT_FORMAT,new Configuration())

tf.addEventListener(StatusChangeEvent.INLINE_GRAPHIC_STATUS_CHANGED,statusChangeEventHandler)

tf.interactionManager = new EditManager(new UndoManager())

var d:DisplayObjectContainerController = new DisplayObjectContainerController(s,s.width,s.height)

tf.flowComposer.addController(d)

tf.flowComposer.updateAllContainers()

}

private var i:InlineGraphicElement

private function statusChangeEventHandler(statusChangeEvent:StatusChangeEvent):void{

//trace(statusChangeEvent.status)

i = InlineGraphicElement(statusChangeEvent.element)

if(statusChangeEvent.status == InlineGraphicElementStatus.ERROR){

i.width = InlineGraphicElementStatus.SIZE_PENDING

//i.width = 'auto'

//i.height = 'auto'

var s:Sprite = new Sprite()

s.graphics.lineStyle(1,0,1)

s.graphics.drawRect(0,0,20,40)

i.source = s

i.getTextFlow().flowComposer.updateAllContainers()

}

if(statusChangeEvent.status == InlineGraphicElementStatus.READY){

i.getTextFlow().addEventListener(CompositionCompletionEvent.COMPOSITION_COMPLETE,compositionCompletionEventHandler)

i.getTextFlow().flowComposer.updateAllContainers()

}

}

private function compositionCompletionEventHandler(compositionCompletionEvent:CompositionCompletionEvent):void{

trace(compositionCompletionEvent.currentTarget)

trace(i.width+" : "+i.height)

trace(i.actualWidth+" : "+i.actualHeight)

trace(i.measuredWidth+" : "+i.measuredWidth)

}

}

}

Thanks

Raf

Participant
May 11, 2009

Hi

Is this for me-i requested assistance to do editing on a PDF on a flash application?

Charl

Adobe Employee
February 24, 2009
Doesn't reproduce. What's the size of your swf? Below is the InlineGraphic example using auto width/height on a non-square image.
Known Participant
February 24, 2009
I think the fact that I'm using a swf, and the fact that it's embedded are important. For this you need a rectangle.swf with a ShortRectangle embedded. Mine is just a MovieClip with a simple rectangle in it.