tigomark
12-11-2007, 08:37 PM
I am having problems understanding how states work with a Tile List.
If I separate out the two states I get my desired output of info but
if I try to keep them all contained onto one panel I get the initial
state of a log in screen but once the panel changes then I get no info.
Also I get a script error for the timer. I think it is because I initiate it at start up but I'm not sure.
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" backgroundGradientAlphas="[1.0, 0.75]" backgroundGradientColors="[#040404, #040404]"
initialize="getDaysUntil()" >
<mx:XML id="tempXML" source="http://mysite.net/interface.php?username=admin&password=pass&custome r=63&action=showopen&operation=defects&format=xml& critcal=both" />
<mx:Image source="@Embed('../images/title.jpg')" width="210" height="65" top="4" left="15"/>
<mx:Image source="@Embed('../images/title1.jpg')" id="image1" horizontalAlign="right" verticalAlign="top" right="0" scaleContent="true" y="0"/>
<mx:states>
<mx:State name="Logged In" >
<mx:SetProperty target="{panel1}" name="width" value="98%"/>
<mx:SetProperty target="{panel1}" name="height" value="433"/>
<mx:RemoveChild target="{password}"/>
<mx:RemoveChild target="{customer}"/>
<mx:RemoveChild target="{username}"/>
<mx:RemoveChild target="{customerlbl}"/>
<mx:RemoveChild target="{label1}"/>
<mx:RemoveChild target="{Submit}"/>
<mx:RemoveChild target="{label2}"/>
<mx:SetProperty target="{panel1}" name="title" value="Current Red Board Information" />
<mx:AddChild relativeTo="{panel1}" position="lastChild">
<mx:TileList dataProvider="{tempXML.defect.asset}"
width="100%" backgroundColor="#000000" color="#ff0000" fontSize="27" borderColor="#000000" columnWidth="300" rowHeight="50" themeColor="#808080" fontWeight="bold" allowMultipleSelection="true" />
<mx:XMLListCollection id="defectXMLList" source="{tempXML.defect}" />
</mx:AddChild>
<mx:AddChild relativeTo="{panel1}" position="lastChild">
<mx:Script>
<![CDATA[
private function getDaysUntil():void {
// creates a new five-minute Timer
var minuteTimer:Timer = new Timer(1000, 300);
// designates listeners for the interval and completion events
minuteTimer.addEventListener(TimerEvent.TIMER, onTick);
minuteTimer.addEventListener(TimerEvent.TIMER_COMP LETE, onTimerComplete);
// starts the timer ticking
minuteTimer.start();
}
public function onTick(evt:TimerEvent):void {
var minuteTimer:Timer = evt.target as Timer;
var lvSecondsRemaining:int = minuteTimer.repeatCount - minuteTimer.currentCount;
var lvMinutes:int = lvSecondsRemaining / 60;
var lvSeconds:int = lvSecondsRemaining - ( lvMinutes * 60 );
var lvSecondsText:String = lvSeconds.toString();
if( lvSeconds < 10 ) lvSecondsText = "0" + lvSecondsText;
lblTimeUntil.text = lvMinutes.toString() + ":" + lvSecondsText;
} // onTick
public function onTimerComplete(evt:TimerEvent):void
{
var minuteTimer:Timer = evt.target as Timer;
minuteTimer.reset();
minuteTimer.start();
}
]]>
</mx:Script>
<mx:HBox horizontalGap="4" width="800" y="347" x="10">
<mx:Label id="lblTimeUntilRefresh" text="Time Till Refresh:" color="#ff0000" fontSize="19" fontWeight="bold" />
<mx:Label id="lblTimeUntil" color="#ff0000" fontSize="22" fontWeight="bold" toolTip="Page refreshes every 5 minutes" fontFamily="Arial" width="300"/>
</mx:HBox>
</mx:AddChild>
<mx:SetStyle target="{panel1}" name="verticalCenter" value="26"/>
</mx:State>
</mx:states>
<mx:HTTPService id="login_user" result="checkLogin(event)" showBusyCursor="true" method="GET" url="https://mysite.net/interface.php" >
<mx:request xmlns="">
<customer>
{customer.text}
</customer>
<username>
{username.text}
</username>
<password>
{password.text}
</password>
</mx:request>
</mx:HTTPService>
<mx:Panel resizeEffect="Resize" width="582" height="354" layout="absolute" title="Red Board Login" horizontalCenter="0" verticalCenter="-2" id="panel1" color="#FF0000" backgroundColor="#191919" cornerRadius="15" themeColor="#FFA800" borderColor="#9FA7B7">
<mx:Label x="10" y="14" text="Customer Number" id="customerlbl" fontSize="20" width="542" textAlign="center"/>
<mx:TextInput x="10" y="61" id="customer" width="542" borderColor="#F90404" backgroundColor="#D5D1D1" themeColor="#FFA800" color="#050505"/>
<mx:Label x="10" y="91" text="Username" id="label1" fontSize="20" width="542" textAlign="center"/>
<mx:TextInput x="10" y="138" id="username" width="542" borderColor="#F90404" backgroundColor="#D5D1D1" themeColor="#FFA800" color="#050505"/>
<mx:Label x="10" y="175" text="Password" id="label2" fontSize="20" width="542" textAlign="center"/>
<mx:TextInput x="11" y="217" id="password" displayAsPassword="true" width="542" borderColor="#F90404" backgroundColor="#D5D1D1" themeColor="#FFA800" color="#050505"/>
<mx:Button x="10" y="282" label="Login" id="Submit" click="login_user.send();" fontSize="14" themeColor="#FFA800" borderColor="#FA0202"/>
</mx:Panel>
</mx:Application>
Any help would be great.
Thanks
If I separate out the two states I get my desired output of info but
if I try to keep them all contained onto one panel I get the initial
state of a log in screen but once the panel changes then I get no info.
Also I get a script error for the timer. I think it is because I initiate it at start up but I'm not sure.
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" backgroundGradientAlphas="[1.0, 0.75]" backgroundGradientColors="[#040404, #040404]"
initialize="getDaysUntil()" >
<mx:XML id="tempXML" source="http://mysite.net/interface.php?username=admin&password=pass&custome r=63&action=showopen&operation=defects&format=xml& critcal=both" />
<mx:Image source="@Embed('../images/title.jpg')" width="210" height="65" top="4" left="15"/>
<mx:Image source="@Embed('../images/title1.jpg')" id="image1" horizontalAlign="right" verticalAlign="top" right="0" scaleContent="true" y="0"/>
<mx:states>
<mx:State name="Logged In" >
<mx:SetProperty target="{panel1}" name="width" value="98%"/>
<mx:SetProperty target="{panel1}" name="height" value="433"/>
<mx:RemoveChild target="{password}"/>
<mx:RemoveChild target="{customer}"/>
<mx:RemoveChild target="{username}"/>
<mx:RemoveChild target="{customerlbl}"/>
<mx:RemoveChild target="{label1}"/>
<mx:RemoveChild target="{Submit}"/>
<mx:RemoveChild target="{label2}"/>
<mx:SetProperty target="{panel1}" name="title" value="Current Red Board Information" />
<mx:AddChild relativeTo="{panel1}" position="lastChild">
<mx:TileList dataProvider="{tempXML.defect.asset}"
width="100%" backgroundColor="#000000" color="#ff0000" fontSize="27" borderColor="#000000" columnWidth="300" rowHeight="50" themeColor="#808080" fontWeight="bold" allowMultipleSelection="true" />
<mx:XMLListCollection id="defectXMLList" source="{tempXML.defect}" />
</mx:AddChild>
<mx:AddChild relativeTo="{panel1}" position="lastChild">
<mx:Script>
<![CDATA[
private function getDaysUntil():void {
// creates a new five-minute Timer
var minuteTimer:Timer = new Timer(1000, 300);
// designates listeners for the interval and completion events
minuteTimer.addEventListener(TimerEvent.TIMER, onTick);
minuteTimer.addEventListener(TimerEvent.TIMER_COMP LETE, onTimerComplete);
// starts the timer ticking
minuteTimer.start();
}
public function onTick(evt:TimerEvent):void {
var minuteTimer:Timer = evt.target as Timer;
var lvSecondsRemaining:int = minuteTimer.repeatCount - minuteTimer.currentCount;
var lvMinutes:int = lvSecondsRemaining / 60;
var lvSeconds:int = lvSecondsRemaining - ( lvMinutes * 60 );
var lvSecondsText:String = lvSeconds.toString();
if( lvSeconds < 10 ) lvSecondsText = "0" + lvSecondsText;
lblTimeUntil.text = lvMinutes.toString() + ":" + lvSecondsText;
} // onTick
public function onTimerComplete(evt:TimerEvent):void
{
var minuteTimer:Timer = evt.target as Timer;
minuteTimer.reset();
minuteTimer.start();
}
]]>
</mx:Script>
<mx:HBox horizontalGap="4" width="800" y="347" x="10">
<mx:Label id="lblTimeUntilRefresh" text="Time Till Refresh:" color="#ff0000" fontSize="19" fontWeight="bold" />
<mx:Label id="lblTimeUntil" color="#ff0000" fontSize="22" fontWeight="bold" toolTip="Page refreshes every 5 minutes" fontFamily="Arial" width="300"/>
</mx:HBox>
</mx:AddChild>
<mx:SetStyle target="{panel1}" name="verticalCenter" value="26"/>
</mx:State>
</mx:states>
<mx:HTTPService id="login_user" result="checkLogin(event)" showBusyCursor="true" method="GET" url="https://mysite.net/interface.php" >
<mx:request xmlns="">
<customer>
{customer.text}
</customer>
<username>
{username.text}
</username>
<password>
{password.text}
</password>
</mx:request>
</mx:HTTPService>
<mx:Panel resizeEffect="Resize" width="582" height="354" layout="absolute" title="Red Board Login" horizontalCenter="0" verticalCenter="-2" id="panel1" color="#FF0000" backgroundColor="#191919" cornerRadius="15" themeColor="#FFA800" borderColor="#9FA7B7">
<mx:Label x="10" y="14" text="Customer Number" id="customerlbl" fontSize="20" width="542" textAlign="center"/>
<mx:TextInput x="10" y="61" id="customer" width="542" borderColor="#F90404" backgroundColor="#D5D1D1" themeColor="#FFA800" color="#050505"/>
<mx:Label x="10" y="91" text="Username" id="label1" fontSize="20" width="542" textAlign="center"/>
<mx:TextInput x="10" y="138" id="username" width="542" borderColor="#F90404" backgroundColor="#D5D1D1" themeColor="#FFA800" color="#050505"/>
<mx:Label x="10" y="175" text="Password" id="label2" fontSize="20" width="542" textAlign="center"/>
<mx:TextInput x="11" y="217" id="password" displayAsPassword="true" width="542" borderColor="#F90404" backgroundColor="#D5D1D1" themeColor="#FFA800" color="#050505"/>
<mx:Button x="10" y="282" label="Login" id="Submit" click="login_user.send();" fontSize="14" themeColor="#FFA800" borderColor="#FA0202"/>
</mx:Panel>
</mx:Application>
Any help would be great.
Thanks