开发者

Flex 4.5 arrange gui components

I 开发者_C百科am using IFrame and adding it dynamically, and it hides a new Alert.show and a previously made TitleWindow.

How do I arrange it to go back or to make that Alert or window on top of all ?


Unfortunately, you can't, as they are parents of different view heirachy's.

The Popup is managed by the SWF, and is a child of the application's display list. The IFrame is managed by the HTML, and is a child of the DOM.

ie:

 + HTML Page
 |
 |
 +---IFrame
 |
 +---SWF (Flex Application)
      |
      +--- System Manager
      |       |
      |       +---- Popup's // <---- Your Popup is here
      +--- Application     

Unfortunately there's no solution here that I'm aware of, you'll need to either display the popup within the IFrame, or remove the IFrame to show the popup.


I'm guessing you're using the mx:HTML component to display some HTML. I got the same issue in my project, IFrame objects always display on top of everything.

An efficient workaround is to draw the hide the HTML component and display a bitmap snapshot of it instead. That way, the Alert or any popup will display on top of it.

Here's how I did it

    private var _snapshotImage:Bitmap;

    private function toggleSnapshotMode(htmlVisible:Boolean):void
    {
        if(!htmlVisible)
        {
            var bitmapData:BitmapData = new BitmapData(htmlLoader.width,htmlLoader.height,false);
            bitmapData.draw(htmlLoader,null,null,null,null,true);
            _snapshotImage = new Bitmap(bitmapData);
            _snapshotImage.x = htmlLoader.x;
            _snapshotImage.y = htmlLoader.y;
            html.addChildAt(_snapshotImage,0);
        }
        else
        {
            html.removeChild(_snapshotImage);
        }

        html.htmlLoader.visible = htmlVisible;
    }
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜