<?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/mx"
minWidth="955" minHeight="600"
xmlns:cairngorm="http://ns.adobe.com/cairngorm" xmlns:samples="samples.*"
creationComplete="application1_creationCompleteHandler(event)">
<s:layout>
<s:VerticalLayout/>
</s:layout>
<fx:Script>
<![CDATA[
import mx.events.FlexEvent;
[Bindable]
public var showPopup1:Boolean;
[Bindable]
public var showPopup2:Boolean;
private var timer:Timer;
private var count:uint;
[Bindable]
private var timerRunning:Boolean;
private function openPopups():void
{
count=0;
showPopup1 = false;
showPopup2 = false;
timer.reset();
timer.start();
timerRunning = true;
}
private function timerHandler(event:TimerEvent):void
{
if(count==0)
{
showPopup1 = true;
}
else if(count==1)
{
showPopup2 = true;
timer.stop();
timerRunning = false;
}
count++;
}
protected function application1_creationCompleteHandler(event:FlexEvent):void
{
timer=new Timer(1500,2);
timer.addEventListener(TimerEvent.TIMER, timerHandler );
}
]]>
</fx:Script>
<fx:Declarations>
<cairngorm:PopUpWrapper id="popup1" open="{ showPopup1 }" modal="true">
<s:TitleWindow backgroundColor="#FF0000" width="300" height="200" />
</cairngorm:PopUpWrapper>
<cairngorm:PopUpWrapper id="popup2" open="{ showPopup2 }" modal="true">
<s:TitleWindow backgroundColor="#00FF00" width="300" height="200" />
</cairngorm:PopUpWrapper>
</fx:Declarations>
<s:Button label="Trigger popups opening" click="openPopups()" enabled="{ !timerRunning }" />
</s:Application>