Skip to main content
Known Participant
Sep 6, 2011 11:02 PM UTC
Question

How to make sure that all inline graphics have been downloaded?

Hello there,

For some specific reasons I need to get reliable indication that the status of all inline graphic elements is 'ready'.

I use the 'StatusChangeEvent' and listen to the 'ready' status. 

The problem is that for some reasons the number of dispatched events is not consistent - the number of events with status 'loading' may be more than the final number of events with status 'ready'. Thus I can't reliably get the overall status of inline graphics.

What event would be reliable indication that all inline graphic elements are ready for display?

Or how I could get the number of graphic elements contained in the source xml so that I could count on that?

Thanks,

Igor Borodin

This topic is closed to new replies. Start a new post to keep the conversation going.

5 replies

Adobe Employee
Sep 8, 2011 6:18 AM UTC

The code scrap as follows is a testcase to wait an ILG to be ready. But it's only for one ILG, not for all in the textflow.

public function loadGraphics():void
        {
                var img:InlineGraphicElement = textFlow.getFirstLeaf() as InlineGraphicElement;//Any way to find the target ILG

                if(img.status != InlineGraphicElementStatus.READY)
                {
                    textFlow.addEventListener(StatusChangeEvent.INLINE_GRAPHIC_STATUS_CHANGE,addAsync(loadGraphics,2500,null),false,0,true);
                }
                else
                {
                    //What you want to do after it is ready
                }
            }
        }

addAsync is a function in flexunit.framework.TestCase. I think you may want to implement a similiar function.

And you can get all ILGs in the textflow by

1.textFlow.getFirstLeaf()

2.leaf.getNextLeaf();

3.if(leaf is InlineGraphicElement)

Translate
FTQuestAuthor
Known Participant
Sep 8, 2011 5:18 PM UTC

Hello Jin-Huang,

Your hint did help.

Going sequentially through all FlowLeafElements proved to work: I first determine leaf's type, and if it is 'img', proceed to checking its InlineGraphicElementStatus; if the leaf is not 'img', I go to the next.

On a side note I ran into one strange thing:

If I check the leaf type by 'typeName' it gives consistent results; on the contrary, checking like this:

if (leaf is InlineGraphicElement)

{// do so and so}

sometimes returns just a 'span' instead of 'img'.

Once again,

thank you for your help,

IB

Translate
Adobe Employee
Sep 9, 2011 3:01 AM UTC

Did you say that some of ILGs are treated as SpanElements? Can you give me the code scrap that can reproduce the case?

Translate