Triggering effects when a container is resized

by Peter deHaan on September 23, 2007

The following example uses a resizeEffect effect along with a Resize tween effect (<mx:Resize />) to create a smooth tween effect whenever the panel is resized.

Full code after the jump.

View MXML

<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2007/09/23/triggering-effects-when-a-container-is-resized/ -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white">

    <mx:Script>
        <![CDATA[
            private function sizePanel(w:uint, h:uint):void {
                panel.width = w;
                panel.height = h;
            }
        ]]>
    </mx:Script>

    <mx:Resize id="resize" />

    <mx:ApplicationControlBar dock="true">
        <mx:Button label="160x160"
                click="sizePanel(160, 160);" />
        <mx:Button label="240x160"
                click="sizePanel(240, 160);" />
        <mx:Button label="160x240"
                click="sizePanel(160, 240);" />
        <mx:Button label="320x240"
                click="sizePanel(320, 240);" />

        <mx:Spacer width="100%" />

        <mx:Label text="w:{panel.width}, h:{panel.height}" />
    </mx:ApplicationControlBar>

    <mx:Panel id="panel"
            title="title"
            status="status"
            width="320"
            height="240"
            resizeEffect="{resize}">
        <mx:Accordion id="accordion"
                historyManagementEnabled="false"
                width="100%"
                height="100%">
            <mx:VBox label="Shipping Information" />
            <mx:VBox label="Billing Information" />
        </mx:Accordion>
        <mx:ControlBar id="cb">
            <mx:Button />
        </mx:ControlBar>
    </mx:Panel>

</mx:Application>

View source is enabled in the following example.

{ 4 comments… read them below or add one }

alpesh vaghasiya December 15, 2007 at 12:12 am

i love it.

Reply

Cris September 19, 2008 at 9:17 pm

impressive

Reply

chary1112004 August 7, 2009 at 2:13 am

Thanks much!
Iam finding it too! Great website and blog!

- chary -

Reply

Hashim August 30, 2010 at 10:29 am

Good Job Peter..

Reply

Leave a Comment

Sorry, this blog is terrible at eating HTML comments.
If you're pasting any HTML/XML/MXML code, you need to convert your < characters to &lt; and your > characters to &gt; .

Anti-Spam Protection by WP-SpamFree

Previous post:

Next post: