Skip to content

Instantly share code, notes, and snippets.

@timoxley
Created February 10, 2010 10:32
Show Gist options
  • Save timoxley/300207 to your computer and use it in GitHub Desktop.
Save timoxley/300207 to your computer and use it in GitHub Desktop.
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/halo"
minWidth="1024"
minHeight="768"
creationComplete="clockhand1_creationCompleteHandler(event)">
<fx:Script>
<![CDATA[
import mx.events.FlexEvent;
private var timer:Timer;
[Bindable]
private var isResized:Boolean = false;
private function clockhand1_creationCompleteHandler(event:FlexEvent):void {
timer = new Timer(30);
timer.addEventListener(TimerEvent.TIMER, onTimerTick);
timer.start();
}
private function onTimerTick(event:TimerEvent):void {
windmillBlades.rotation++;
}
private function button1_clickHandler(event:MouseEvent):void {
if (!isResized) {
windmill.width = 100;
windmill.height = 400;
isResized = true;
} else {
windmill.width = 50;
windmill.height = 200;
isResized = false;
}
}
]]>
</fx:Script>
<fx:Declarations>
<!--
When my windmill resizes, I want the blades to resize with it. Please help me.
-->
</fx:Declarations>
<s:Group verticalCenter="0" horizontalCenter="0">
<s:layout>
<s:VerticalLayout horizontalAlign="center" />
</s:layout>
<!--
- windMill -
This is the parent we are going to resize.
-->
<s:Group id="windmill" width="50" height="200">
<s:Rect width="100%" height="100%">
<s:fill>
<s:SolidColor color="0x513D2F" />
</s:fill>
<s:stroke>
<s:SolidColorStroke color="0xBDB793" />
</s:stroke>
</s:Rect>
<!--
- windMillBlades -
I think it's -something- to do with this resizeMode on windMillBlades
my first guess was to put a
width="100%"
height="100%"
in there but that REALLY doesn't work.
HELP!
-->
<s:Group id="windmillBlades" resizeMode="scale" verticalCenter="0" horizontalCenter="0">
<s:Group verticalCenter="0" horizontalCenter="0">
<!-- 'string' attaching blades -->
<s:Rect width="100%" height="100%">
<s:stroke>
<s:SolidColorStroke color="0x000000"
miterLimit="10"
scaleMode="normal"
weight="1"
alpha="0.2"
caps="square" />
</s:stroke>
</s:Rect>
<!--
Don't touch this. Imagine there are 100s of these (generated from Catalyst)
& it's not feasible to update them all to relative sizing.
-->
<s:Line xFrom="0" xTo="140" yFrom="0" yTo="140">
<s:stroke>
<s:SolidColorStroke color="0xBC311E"
miterLimit="10"
scaleMode="normal"
weight="16"
caps="square" />
</s:stroke>
</s:Line>
<s:Line xFrom="0" xTo="140" yFrom="140" yTo="0">
<s:stroke>
<s:SolidColorStroke color="0xBC311E"
miterLimit="10"
scaleMode="normal"
weight="16"
caps="square" />
</s:stroke>
</s:Line>
<s:filters>
<!-- Totally superfluous. -->
<s:DropShadowFilter alpha="0.2" />
</s:filters>
<!--
End no touching
-->
</s:Group>
</s:Group>
</s:Group>
<!-- Resize button -->
<s:Button click="button1_clickHandler(event)" label="{isResized ? 'Take Windmill back' : 'Make Windmill Phat'}" />
</s:Group>
</s:Application>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment