topical media & game development
mashup-rmx-07-Chapter7-Exercise4-Chapter7-Exercise4.mx
mashup-rmx-07-Chapter7-Exercise4-Chapter7-Exercise4.mx
(swf
)
[ flash
]
flex
<?xml version="1.0" encoding="utf-8"?>
<mx:Application
xmlns:mx="http://www.adobe.com/2006/mxml"
horizontalAlign="left"
applicationComplete="initSWFAddress()"
currentStateChange="setSWFAddress()">
<mx:Script>
<![CDATA[
import com.asual.swfaddress.SWFAddress;
private function toTitleCase(str:String):String {
return str.substr(0,1).toUpperCase() +
str.substr(1).toLowerCase();
}
private function handleSWFAddress():void {
var value:String = SWFAddress.getValue();
value = toTitleCase(value.replace(/\//g, ''));
if (currentState != value) {
currentState = value;
}
var title:String = 'SWFAddress Application';
if (currentState != '') {
title += ' ยป ' + currentState;
}
SWFAddress.setTitle(title);
}
private function setSWFAddress():void {
var value:String = '';
if (currentState != '') {
value = '/' + currentState.toLowerCase() + '/';
}
if (value != SWFAddress.getValue()) {
SWFAddress.setValue(value);
}
}
private function initSWFAddress():void {
SWFAddress.onChange = handleSWFAddress;
}
]]>
</mx:Script>
<mx:states>
<mx:State name="File">
<mx:SetProperty target="{contentText}" name="text"
value="File content." />
</mx:State>
<mx:State name="Edit">
<mx:SetProperty target="{contentText}" name="text"
value="Edit content." />
</mx:State>
<mx:State name="View">
<mx:SetProperty target="{contentText}" name="text"
value="View content." />
</mx:State>
</mx:states>
<mx:LinkButton id="contentHead" label="SWFAddress Application"
click="currentState=''" fontSize="24" />
<mx:ApplicationControlBar width="100%">
<mx:LinkBar dataProvider="{['File','Edit','View']}"
itemClick="{currentState=event.label}" />
</mx:ApplicationControlBar>
<mx:Box width="100%" height="100%" paddingTop="10"
paddingRight="10" paddingBottom="10" paddingLeft="10">
<mx:Box backgroundColor="0xFFFFFF" width="100%" height="100%"
paddingTop="5" paddingRight="5" paddingBottom="5" paddingLeft="5">
<mx:Text id="contentText" width="100%" height="100%"
text="Welcome content." />
</mx:Box>
</mx:Box>
</mx:Application>
(C) Æliens
18/6/2009
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.