<?xml version="1.0" encoding="utf-8"?>
<s:Group xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" width="100%" height="60"
xmlns:wizard="net.anirudh.wizard.*"
>
<fx:Script>
<![CDATA[
import net.anirudh.wizard.vo.WizardStepVO;
import mx.collections.ArrayCollection;
[Bindable]public var views:ArrayCollection;
[Bindable]public var steps:uint = 0;
[Bindable]private var progwidth:uint = 0;
public function initStep():void
{
if ( views.length > 0 )
{
var wvo:WizardStepVO = views.getItemAt(0) as WizardStepVO;
if ( wvo )
{
progwidth = wvo.width;
resizeProgress();
}
}
}
private function resizeProgress():void
{
if ( progresize.isPlaying )
{
progresize.end();
}
progresize.widthFrom = pbar.width;
progresize.widthTo = progwidth;
progresize.play();
}
private function updateProgress():void
{
var len:int = views.length;
var actlen:int = len;
var tempwidth:int = 0;
if ( steps <= len )
{
len = steps + 1;
}
else
len = 0;
if ( len > 0 )
{
for ( var i:int = 0; i < len; i++ )
{
if ( i < actlen )
{
var wvo:WizardStepVO = views.getItemAt(i) as WizardStepVO;
if ( wvo )
{
tempwidth += wvo.width;
}
}
else
{
tempwidth += finishButton.width;
finishButton.currentState = 'selected';
}
}
progwidth = tempwidth;
resizeProgress();
}
}
public function nextStep():void
{
steps++;
if ( steps >= 0 && steps < views.length )
{
var wvo:WizardStepVO = views.getItemAt(steps) as WizardStepVO;
if ( wvo )
{
wvo.state = "selected";
}
}
updateProgress();
}
public function previousStep():void
{
if ( steps < views.length )
{
var wvo:WizardStepVO = views.getItemAt(steps) as WizardStepVO;
if ( wvo )
{
wvo.state = "normal";
}
}
else if ( steps == views.length )
{
finishButton.currentState = "normal";
}
steps--;
var wvo1:WizardStepVO = views.getItemAt(steps) as WizardStepVO;
if ( wvo1 )
{
wvo1.state = "selected";
}
updateProgress();
}
]]>
</fx:Script>
<fx:Declarations>
<s:Resize id="progresize" target="{pbar}" duration="800" />
</fx:Declarations>
<s:DataGroup
id="wizardSteps"
dataProvider="{views}"
itemRenderer="net.anirudh.wizard.WizardItemRenderer"
>
<s:layout>
<s:HorizontalLayout
gap="0"
/>
</s:layout>
</s:DataGroup>
<wizard:StepLabel
id="finishButton"
right="0" label="FINISH"
height="34" width="{this.width - wizardSteps.width}"/>
<s:Line id="eraseLineRight" top="0" height="34" right="0">
<s:stroke>
<s:SolidColorStroke weight="1" color="0xFFFFFF" />
</s:stroke>
</s:Line>
<mx:ProgressBar
id="pbar"
indeterminate="true" left="0"
top="0"
bottom="0"
label=""
width="0"
alpha="0.1"
mouseEnabled="false">
</mx:ProgressBar>
<s:Line id="eraseLineLeft" top="0" height="33" left="0" >
<s:stroke>
<s:SolidColorStroke weight="1" color="0xFFFFFF"
/>
</s:stroke>
</s:Line>
<s:Line id="eraseLineLeft1" top="0" height="33" left="0" alpha="0.2">
<s:stroke>
<s:SolidColorStroke weight="2" color="0x000066"
/>
</s:stroke>
</s:Line>
<s:Line
left="0" right="0">
<s:stroke>
<s:Stroke color="0x404040" weight="1"/>
</s:stroke>
</s:Line>
</s:Group>