开发者

Add Child immediately in Flex 3

I'm having a problem similar to FLEX: dialog not display immediately . Code follows:

private function saveBitmap(event:ContextMenuEvent):void
{
    loadingScreen.visible = true;
    loadingScreen.appLoadingText.text = "Preparing bitmap...";
    addChild(loadingScreen);

    validateNow();

    var bmpd:BitmapData = new BitmapData(canv.width, canv.height);
    bmpd.draw(canv);

    var fr:FileReference = new FileReference();
    fr.addEventListener(DataEvent.UPLOAD_COMPLETE_DATA, removeLoadingScreen);
    fr.addEvent开发者_JS百科Listener(Event.CANCEL, removeLoadingScreen);
    var png:PNGEncoder = new PNGEncoder();
    var iba:ByteArray = png.encode(bmpd);
    fr.save(iba, "export.png"); 
}

Basically, bmpd.draw and/or png.encode are dog slow, so I'd like to have a nice "please hold while we prepare your png" dialog to appear. I can't use callLater() because of the FileReference.

And just for good measure, the loading screen appears at the same time the save dialog appears from the call to fr.save().

Any ideas?

Cheers!


You're adding the child in this function. Are you doing any other work to the loadingScreen, such as sizing it? Or positioning it? Most commonly this is done in updateDisplayList(). What container are you using?

Are you sure the Z-order of your two children is correct? You can swap children with the swapChildren method

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜