You Are Here:

Community: Wiki

This page was last modified on 6 June 2008, at 10:33.

バッテリーインジケータを作成する方法

From Forum Nokia Wiki


原文(英語): How to make a battery indicator

対象となるバージョン: Flash Lite: 1.1, 2.x

Contents

バッテリーインジケータの作成

  • 新しくムービークリップを作成します。
  • ムービークリップ中で、2つ以上のレイヤーを作成します。
    • ActionScript: このレイヤーでは、表示する必要があるレベル分(この例では8レベル選択する)のキーフレームを作成します。
    • Level: 最初のフレームにおいて、最下位レベルに対応したレベルのバーを作成します。最後のフレームでキーフレームを作成し、最上位レベルに向けてレベルのバーを伸ばします。そして、モーショントゥイーンを追加します。
    • Background: 全ての静的コンテンツを配置するためのレイヤーを追加します。
    • タイムラインは、次のようになります。Image:Timeline_battery.jpg
  • ActionScriptレイヤーの最初のキーフレームで、以下のコードを追加します。
levelsNumber=8;
batMax = fscommand2("GetMaxBatteryLevel");
batLevel = fscommand2("GetBatteryLevel");
batSource = fscommand2("GetPowerSource");
batLevel2 = Math.ceil(batLevel*levelsNumber/batMax);
 
if (batSource == 0) { //If charger is not plugged
gotoAndPlay(batLevel2);
}
/* If charger is plugged, it will go to nextframe,
so the battery indicator will be animated.*/
  • その他の全てのキーフレームで、以下のコードを追加します。
call(1);
  • このムービークリップを、シーン上に配置します。


パーセント表示インジケータを追加する

テキストインジケータを追加する必要がある場合

  • 新たにレイヤーを作成し、ダイナミックテキストを追加します。
  • 変数フィールドに入力し、それを変数にリンクします。(この例の場合batTextとする)
  • このコードをActionScriptレイヤーの最初のキーフレーム、ifステートメントの直前に追加します。
batText = "Battery Level: " add math.ceil(batLevel*100/batMax) add "%";


Flash Lite 2.xで推奨するコードの改善

  • call(1): このアクションは、function ステートメントのために廃止されました。
  • [...]Level: " add Math.c[...]: Adobeは、+オペレータの使用を推奨しています。


ダウンロード

この例題は、下記サイトからダウンロードできます。
バッテリーインジケータ 240*320 (swf + fla)
Image:Example_battery.jpg

Related Wiki Articles

No related wiki articles found

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia