• notice
  • Congratulations on the launch of the Sought Tech site

AdobeAIRFlex: Dynamically change the width of a VGroup

We have an Adobe??e AIR desktop application.In the viewport there is a top bar with some buttons.Thecenterbutton always opens a drop-down popup in the horizontalcenterof the screen.Previously, there were no scroll bars, and the top bar and popovers were always aligned horizontally.But now we have introduced horizontal and vertical scrollbars, so when the viewport is resized, the top bar is not in thecenterof the active viewport, so it doesn't align with the popup.

Please check the picture.Top Bar-

Adobe AIR Flex: Dynamically change the width of a VGroup

Popup-

Adobe AIR Flex: Dynamically change the width of a VGroup

If the viewport is maximized on the horizontal side, the top bar is aligned with the popover.

now mxml code-

public function showMainMenu():void
        {
            log.debug("Menu button clicked.");
            if(animatingMenu)
            {
                log.debug("Suppressing showing of menu.Animation already in progress.");
                return;
            }
            animatingMenu=true;
            menuButton.visible=true;
            mainMenu.visible=true;
            PopUpManager.addPopUp(mainMenu, FlexGlobals.topLevelApplication as DisplayObject, true);
            PopUpManager.centerPopUp(mainMenu);
            mainMenu.y=-mainMenu.height menuButton.height;
            mainMenu.refresh();
            showMenuEffect.play();
            menuButton.visible=false;
        }


<fx:Declarations>
    <menu:MainMenu id="mainMenu"/>
    <s:Move id="showMenuEffect" target=" {mainMenu}" yFrom="{-mainMenu.height menuButton.height}" yTo="-5 " effectEnd="menuShowed(event)" duration="1200"/>
    <s:Move id="hideMenuEffect" target=" {mainMenu}" yFrom="-5" yTo="{-mainMenu.height menuButton.height} " effectEnd="menuHided(event)" duration="600"/>
</fx:Declarations>

<s:HGroup width="100%">
    <s:VGroup horizontalAlign="center" width="100%"  paddingLeft="{this.width/2-menuButton.width/2}">
        <s:Button id="menuButton" automationName="menuButtonShow" click="showMainMenu()" styleName="mainMenuButton" height="40" width="200"/>
    </s:VGroup>
    
    <s:HGroup horizontalAlign="right" width="100%"  paddingRight="48" paddingTop="10">
        <desktop:LocaleSelector id="localeSelector"/>
        <desktop:ButtonCorner id="buttonCorner"/>
    </s:HGroup>
    
    <s:VGroup paddingRight="24" paddingTop="25" horizontalAlign="right">
        <s:Button id="closeScreenButton" visible="false" styleName="closeScreenButton" width="29" height="35"/>
    </s:VGroup>
</s:HGroup>

What should be changed? How can I always position the top bar in thecenterof the screen.Should I create a css file to handle this situation?

uj5u.com enthusiastic netizens replied:

This is the default behavior.When you show a popup, you tell it where to place it in.y and.x.When you scroll or resize, you effectively change the "center" of the viewport, but you never notify it that it has changed.

I would try adding a listener to resize the viewport and onChangeRecenterpopup.

Sample code (untested, but should work):

var widthWatch:ChangeWatcher=ChangeWatcher.watch(this, 'widht', resizeHandler);
private var resizeExecuting:Boolean=false;

//this should run as soon as your app does (in most cases I do that in creationComplete or initialize())
private function onCreationComplete(event:Event):void span>
{
    widthWatch=ChangeWatcher.watch(this,'width',onSizeChange);
}
//this checks if the resize stopped before actually moving the popup.Alternatively you can move your popup.centercode here
private function onSizeChange(event:Event):void span>
{
    if(!resizeExecuting)
    callLater(handleResize);
    resizeExecuting=true;
}
  
private function handleResize():void
{
    PopUpManager.centerPopUp(mainMenu);
    resizeExecuting=false;
}

Tags

Technical otaku

Sought technology together

Related Topic

1 Comments

author

atorvastatin 40mg without preion & lt;a href="https://lipiws.top/"& gt;buy lipitor 20mg online& lt;/a& gt; oral lipitor

Biumma

2024-03-08

Leave a Reply

+