Skip to main content
Known Participant
September 6, 2011
Question

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

  • September 6, 2011
  • 1 reply
  • 1190 views

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 has been closed for replies.

1 reply

Adobe Employee
September 8, 2011

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)

FTQuestAuthor
Known Participant
September 8, 2011

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

Adobe Employee
September 9, 2011

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