MXコンポーネント用のものは見つかりましたが、sparkコンポーネントで動作することはできません。
現在の日付と日付をラベルに表示したいだけです。
これを試しましたが(コードを参照)、関数Function(){}しか返されません。
<?xml version="1.0" encoding="utf-8"?>
<s:View xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
currentState="login" tabBarVisible="{currentState!='login'}">
<s:states>
<s:State name="login"/>
<s:State name="planner"/>
</s:states>
<fx:Script>
<![CDATA[
import mx.rpc.events.ResultEvent;
//private function login() :void
//{
//loginservice.send();
//}
private function checkLogin(evt:ResultEvent):void
{
if(loginservice.lastResult.loginsuccess == "yes")
{
currentState = "planner";
}
if(evt.result.loginsuccess == "no")
{
statusLabel.text = "Incorrect. (Try user/password)";
}
}
protected function submit_clickHandler(event:MouseEvent):void
{
// TODO Auto-generated method stub
}
public function displayDate():void {
var now:Date = new Date();
var day_int:int = now.getDate(); //gets day of the month
var month_int:int = (now.getMonth()+1); // gets month. Months are given from 0 to 11, so you need to do +1 here
var year_int:int = now.getFullYear(); // gets year
var day_string:String;
//display always 2 digits for a month, so '02' instead of just '2' for February
if (day_int < 10) {
day_string = "0" + day_int.toString();
}
else {
day_string = day_int.toString();
}
var month_string:String;
//display always 2 digits for a day, so '02' instead of just '2'
if (month_int < 10) {
month_string = "0" + month_int.toString();
}
else {
month_string = month_int.toString();
}
var year_string:String = year_int.toString();
// note: this is displaying the date in the DD/MM/YYYY format, this same format is also set for the Datefield below!
//DateSelect.text = day_string + "/" + month_string + "/" + year_string;
}
]]>
</fx:Script>
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
<s:HTTPService id="loginservice"
method="GET"
url="http://localhost:8888/MenuPlannerApp/services/login4.php"
useProxy="false"
result="checkLogin(event)">
<s:request xmlns="">
<email>{email.text}</email>
<password>{password.text}</password>
</s:request>
</s:HTTPService>
</fx:Declarations>
<s:BorderContainer includeIn="login" width="100%" height="100%" >
<s:Label id="statusLabel" />
<s:TextInput id="email" y="192" left="15" right="15" text="email"/>
<s:TextInput id="password" y="247" left="15" right="15" text="password" displayAsPassword="true"/>
<s:Button id="submit" y="306" right="15" width="100" height="30"
label="Login" click="loginservice.send()"/>
<s:Button id="LoginCreate" y="306" left="15" width="100" height="30"
label="Create"/>
<s:Label x="166" y="39" width="113" height="101" fontSize="30"
text="Menu
Planner"/>
</s:BorderContainer>
<s:BorderContainer includeIn="planner" width="100%" height="100%">
<s:Label text="{displayDate}" />
<s:HGroup y="10" width="320" height="46" horizontalAlign="center"
textAlign="center">
</s:HGroup>
<s:VGroup includeIn="planner" >
</s:VGroup>
</s:BorderContainer>
</s:View>