×
Namespaces

Variants
Actions
(Difference between revisions)

Archived:Flash Liteを使用してバッテリー表示Widgetを作成する方法

From Nokia Developer Wiki
Jump to: navigation, search
hamishwillee (Talk | contribs)
m (Hamishwillee - Bot addition of Template:ArticleMetaData)
hamishwillee (Talk | contribs)
m (Hamishwillee - Bot update of Template:ArticleMetaData)
Line 12: Line 12:
 
|id= <!-- Article Id (Knowledge base articles only) -->
 
|id= <!-- Article Id (Knowledge base articles only) -->
 
|language=Lang-Japanese
 
|language=Lang-Japanese
|translated-by= <!-- [[User: XXXXX]] -->
+
|translated-by=[[User:Fnjwikimng]]
|translated-from-title=<!-- Title only -->
+
|translated-from-title=How to create a battery widget using Flash Lite (WRT)
|translated-from-id= <!-- Id of translated revision -->
+
|translated-from-id=94162
 
|review-by=<!-- After re-review: [[User:username]] -->
 
|review-by=<!-- After re-review: [[User:username]] -->
 
|review-timestamp=<!-- After re-review: YYYYMMDD -->
 
|review-timestamp=<!-- After re-review: YYYYMMDD -->
Line 20: Line 20:
 
|update-timestamp=<!-- After significant update: YYYYMMDD -->
 
|update-timestamp=<!-- After significant update: YYYYMMDD -->
 
|creationdate=20080611
 
|creationdate=20080611
|author=[[User:Fnjwikimng]]
+
|author=[[User:Raheal akh]]
 
}}[[Category:Lang-Japanese]][[Category:Flash Lite]][[Category:How To]][[Category:Code Examples]][[Category:Symbian Web Runtime]][[Category:Symbian Web Runtime]]
 
}}[[Category:Lang-Japanese]][[Category:Flash Lite]][[Category:How To]][[Category:Code Examples]][[Category:Symbian Web Runtime]][[Category:Symbian Web Runtime]]
  
原文(英語): [[How to create a battery widget using Flash Lite (WRT)]]
 
  
 
[[Image:Battery.jpg]]
 
[[Image:Battery.jpg]]
Line 130: Line 129:
 
== 参照リンク ==
 
== 参照リンク ==
 
[[How to Package Flash content in a Widget]]
 
[[How to Package Flash content in a Widget]]
 +
<!-- Translation --> [[en:How to create a battery widget using Flash Lite (WRT)]]

Revision as of 05:53, 9 December 2011

Article Metadata
Code ExampleCompatibility
Platform(s):
S60 5th Edition
Article
Translated:
By fnjwikimng
Last edited: hamishwillee (09 Dec 2011)
Battery.jpg

Contents

Flash Lite ActionScriptコード

コード

stop();
var talktime:Number;
 
var standbytime:Number;
device_name_txt = "N95";
 
//Get Instant Battery Check
batteryFunc();
// Monitor Battery level after certain time elapse to
// call the function to show batter status on the screen.
// Set Interval in miliseconds
setInterval(batteryFunc, 5000); //5 Seconds
 
//Battery func fetches the battery level and displays it on the screen
function batteryFunc(){
 
batMax = fscommand2("GetMaxBatteryLevel");
batLevel = fscommand2("GetBatteryLevel");
batSource = fscommand2("GetPowerSource");
 
//Change the battery_lvl_mc height depending on the Battery Level
_root.battery_mc.battery_lvl_mc._height = Math.ceil(batLevel*100/batMax);

バッテリー持ち時間とスタンバイ時間を決定する

バッテリー持ち時間とスタンバイ時間は、ターゲットとなる端末の仕様を取得するだけで、知ることができます。よって、簡単な数式を使って、その結果をすぐに得ることができます。

//Show Battery text
//N95 - standard talk time is 6.5 Hours and Standby time is 220 Hours
battery_Txt = "Battery Level: " add Math.ceil(batLevel*100/batMax) add "%";
Talk_time_Txt = Math.round(batLevel*390/batMax) add " mins" ; //N95 6.5 Hours
stand_by_time_Txt = Math.ceil(batLevel*220/batMax) add " hr"; //N95 220 Hours
 
//Change Display status based on battery source
if (batSource == 0) { //On Battery
_root.battery_mc.gotoAndStop(2);
}
//Change Display status
else if (batSource == 1) { //On Charger
_root.battery_mc.gotoAndStop(3);
}
else { //Unknown
_root.battery_mc.gotoAndStop(1);
}
 
}

いくつかのNokia端末における、通話時間、スタンバイ時間に関する仕様:

//Determine Device talk time and standby time based on the Phone Specifications taken from Nokia Website
statusdevice = fscommand2("GetDevice", "devicename");
switch(devicename) {
case "Nokia N95":
device_name_txt = "N95";
talktime = 390; //6.5 hours
standbytime = 220; //220 Hours
break;
case "Nokia 5300":
device_name_txt = "5300";
talktime = 192; //3.2 hours
standbytime = 223; //220 Hours
break;
case "Nokia 6290":
device_name_txt = "6290";
talktime = 210; //3.5 hours
standbytime = 260; //260 Hours
break;
case "Nokia 6300":
device_name_txt = "6300";
talktime = 210; //3.5 hours
standbytime = 348; //348 Hours
break;
case "Nokia 7390":
device_name_txt = "7390";
talktime = 190; //3 hours
standbytime = 220; //220 Hours
break;
case "Nokia 3250":
device_name_txt = "3250";
talktime = 210; //3.5 hours
standbytime = 245; //245 Hours
break;
}


実行結果例

BatteryFinal.jpg

ダウンロード

ソースコードのダウンロードはこちら: Media:Battery widget240x320.zip

参照リンク

How to Package Flash content in a Widget

63 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×