Skip to main content
Known Participant
Feb 24, 2009 6:46 PM UTC
Answered

InlineGraphicElement sizing bug

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 is closed to new replies. Start a new post to keep the conversation going.
rdermerCorrect answer
Inspiring
Feb 26, 2009 9:29 PM UTC
I've submitted a fix to the auto size problem. It will be in build 381 and later.

Thanks again for the sample code.

11 replies

Known Participant
Feb 26, 2009 9:50 PM UTC
Awesome, thanks!
Translate
rdermerCorrect answer
Inspiring
Feb 26, 2009 9:29 PM UTC
I've submitted a fix to the auto size problem. It will be in build 381 and later.

Thanks again for the sample code.
Translate
Known Participant
May 11, 2009 4:42 PM UTC

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

Translate
Participant
May 11, 2009 5:19 PM UTC

Hi

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

Charl

Translate
Inspiring
Feb 24, 2009 9:18 PM UTC
Doesn't reproduce. What's the size of your swf? Below is the InlineGraphic example using auto width/height on a non-square image.
Translate
Known Participant
Feb 24, 2009 9:40 PM UTC
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.
Translate