Sunday, August 19, 2007

Using SWFObject and the AIR install badge for easy deployment

One of the topics I spoke on at 360|Flex was how to add an "Install Now" button to a page, using the AIR install badge from Adobe. This is very easy to do, even though this post is long-ish. Explaining what is happening takes longer than the dozen lines of JavaScript required to get this to work.

I have an example "Install Now" button for DryerFox in the blog sidebar. This button will provide a one-click install experience for your users.

Quick-n-dirty summary for adding an "Install Now" button.

Copy foo.air to your web folder. This is your app's AIR application bundle.

Create a 215 x 100 image of your app, and save it as foo_badge.jpg in your web folder.

Copy swfobject.js to your web folder. Thanks to Geoff Stearns for the fabulous SWFObject.

Copy badge.swf to your web folder.

Add the following HTML snippet to your page:

<script type="text/javascript" src="swfobject.js"></script>

<div id="foo_flashcontent">
Whoa. You need to install <a href="http://www.adobe.com/go/flashplayer">Adobe Flash Player</a>.
</div>

<script type="text/javascript">
var so = new SWFObject("badge.swf", "badge", "217", "180", "6.0.65", "#FFFFFF");
so.addVariable( "appname", "Foo" );
so.addVariable( "appurl", "foo.air" );
so.addVariable( "imageurl", "foo_badge.jpg" );
so.addVariable( "airversion", "1.0.M4" );
so.addVariable( "buttoncolor", "008811" );
so.addVariable( "messagecolor", "000000" );
so.write("foo_flashcontent");
</script>

Details - Under the hood

The SWFObject script will replace the <div> section labeled "foo_flashcontent" with the badge SWF, and populate its required Flashvars with your apps resources. Note that it is important to include some sort of fallback text in the <div> in case no Flash player is found.












Flashvar nameDescription
appnameThe name of your app. This name will be displayed by the badge in various messages below the "Install Now" button. Messages like "In order to install FooApp, the AIR runtime will also be installed".
appurlThe URL of your app's AIR bundle. The URL can be relative to the same folder as the page, or can be an absolute URL pointing to some other domain.
imageurlThe URL of the 215 x 100 image (JPG/PNG) to display inside the badge. As with the app URL, this URL can be relative or absolute.
airversionThe version of the AIR runtime required by your app, as specified in Foo-app.xml. For Moxie beta 1, this is "1.0.M4".
buttoncolorThe color of the "Install Now" text in hex RRGGBB format.
messagecolorThe hex RRGGBB color of the message text displayed below the badge.


Clicking the badge will do the following:

Auto-update the Flash player. The user's current Flash player version is examined and the script will update to the latest Flash Player if required. This bootstrap works as far back as Flash player 6.0.65 (released in December 2002), so that gives pretty good coverage. Will a 2002-era computer run a useful AIR app? Hmm. Probably not.

Auto-install the AIR runtime. Verify that the AIR runtime required by your app is installed, and auto-install it when missing. Each AIR app is tied to a specific runtime release, and the install badge knows how to deal with this correctly.

Auto-install your AIR app. This is, of course, what you really wanted to do in the first place.

Security Issues

Just to be clear, all of the above installation operations take place in the context of the active operating system user account. No OS security restrictions are bypassed, so the user will need admin or install privileges to succeed. This is a good thing.

Churn, Churn, Churn

The badge.swf example was added to the Flex SDK as part of the Flex 3 (Moxie) public prerelease, but that version of badge.swf was rather buggy. Adobe quickly released a patch and you will need to use the patch and avoid the one included in the SDK. I'm sure this will be fixed in the next public code drop. For now, avoid the code in INSTALLROOT/sdks/moxie/samples/badge.

Update:
Also make sure your web server is configured to know the mime-type of .air files. (*.air=application/vnd.adobe.apollo-application-installer-package+zip) More detail on the mime type is found in Mike Chamber's post here.

Resources:

Tom Cornilliac's excellent post on the AIR install badge. (It is just missing the SWFObject example)

19 comments:

Ryan Stewart said...

Great post Doug, stuff like this is great to get out there. Hopefully more people use the install badge.

Anonymous said...

Hi Doug. Thanks for the tutorial on how to implement the AIR download badge. I have one question though, I have tried using mine and I get the message "A download error occurred. Try to download again?" I am pretty sure this happens when it tries to connect to Adobe.

Any thoughts?

Anonymous said...

We figured it and thought we should update incase anyone else has the same issue. Be sure the FVAR AIR runtime variable is correct. If it is not, you will get a connection errror.

Doug Schmidt said...

Chris, glad to hear you worked it out, especially before I got a chance to log in and post some suggestions. I am truly a lazy programmer, and I wish more of my bugs could be fixed soley due to my sloth.

Anonymous said...

Have you run into any changes that need to be made to make this work with Flex Beta 2 and the new AIR runtime?

Doug Schmidt said...

I haven't tried it with the just-released Flex Builder 3 (Moxie) Beta 2. It's on my TODO list.

From what I can tell, FB3B2 includes an updated badge installer, so my guess is that you'll need to use that updated badge.swf.

Anonymous said...

Hi Doug,
Thanks for the implementation. But I had observed 2 issues:
1. appurl, I have to give as http://host/air-app-name
If I had given simply the air app name, I am getting the "Installation Error #2032"
2. imageurl? I tried with absolute and relative image url, but no image is displayed.

Please let me know if you have observed the same.

Doug Schmidt said...

@mango

The appurl flash var must resolve to your app's AIR package. It just can't be the app name. The appname var is used to specify the app name.

So you should set appurl="http://yourhost/yourpath/foo.air" and appname="Foo".

I'm not sure why the imageurl isn't working for you, but I've found that the badge installer wants JPEG, not PNG files. Also, AIR beta 2 and AIR beta 3 use slightly different badge installers, so make sure you use the appropriate one.

Anonymous said...

DryerFox is truly amazing, when do you expect to have over 40% market share?

sridhar said...

Hi Doug,
I am using beta2 badge installer and tried with both jpeg and png images for imageurl.

Anonymous said...

ドルチェ&ガッバーナDOLCE & GABBANAドルチェ&ガッバーナ バッグドルチェ&ガッバーナ 財布ドルチェ&ガッバーナ ネックレスドルチェ&ガッバーナ サングラスドルチェ&ガッバーナ リングドルチェ&ガッバーナ 香水ドルチェ&ガッバーナ シューズドルチェ&ガッバーナ アウタードルチェ&ガッバーナ インナードルチェ&ガッバーナ シャツドルチェ&ガッバーナ ジーンズドルチェ&ガッバーナ 時計ドルチェ&ガッバーナ Tシャツグッチgucciグッチ バッググッチ 財布グッチ ネックレスグッチ サングラスグッチ リンググッチ 香水グッチ シューズグッチ アウターグッチ シャツグッチ ジーンズグッチ 時計グッチ Tシャツグッチ アウターグッチ インナーディオールChristian Diorディオール バッグディオール 財布ディオール ネックレスディオール サングラスディオール リングディオール 香水ディオール シューズディオール アウターディオール シャツディオール ジーンズディオール Tシャツディオール 時計ディオール インナーヴィトンLOUIS VUITTONヴィトン バッグヴィトン 財布ヴィトン ネックレスヴィトン サングラスヴィトン リングヴィトン シューズヴィトン アウターヴィトン シャツヴィトン ジーンズヴィトン Tシャツヴィトン 時計シャネルCHANELシャネル バッグシャネル 財布シャネル ネックレスシャネル サングラスシャネル リングシャネル 香水シャネル シューズシャネル アウターシャネル シャツシャネル ジーンズシャネル Tシャツシャネル 時計シャネル インナーシャネル ワンピースプラダpradaプラダ バッグプラダ 財布プラダ ネックレスプラダ サングラスプラダ キーリングプラダ 香水プラダ シューズプラダ アウタープラダ シャツプラダ ジーンズプラダ Tシャツプラダ 時計フェラガモSALVATORE FERRAGAMOフェラガモ バッグフェラガモ 財布フェラガモ ネックレスフェラガモ サングラスフェラガモ キーリングフェラガモ 香水フェラガモ シューズフェラガモ アウターフェラガモ シャツフェラガモ パンツフェラガモ Tシャツフェラガモ 時計セリーヌCELINEセリーヌ バッグセリーヌ 財布セリーヌ ネックレスセリーヌ サングラスセリーヌ リングセリーヌ 香水セリーヌ シューズセリーヌ アウターセリーヌ シャツセリーヌ ジーンズセリーヌ TシャツボッテガBOTTEGA VENETAボッテガ バッグボッテガ 財布ボッテガ ネックレスボッテガ サングラスボッテガ リングボッテガ 香水ボッテガ シューズボッテガ アウターボッテガ シャツボッテガ ジーンズボッテガ TシャツコーチCOACHコーチ バッグコーチ 財布コーチ ネックレスコーチ サングラスコーチ リングコーチ 香水コーチ シューズコーチ アウターコーチ シャツコーチ ジーンズコーチ Tシャツコーチ 時計ダンヒルdunhillダンヒル バッグダンヒル 財布ダンヒル カフスボタンダンヒル サングラスダンヒル リングダンヒル 香水ダンヒル シューズダンヒル アウターダンヒル シャツダンヒル ジーンズダンヒル Tシャツダンヒル 時計ロエベLOEWEロエベ バッグロエベ 財布ロエベ ネックレスロエベ サングラスロエベ キーホルダーロエベ 香水ロエベ シューズロエベ アウターロエベ シャツロエベ ジーンズロエベ TシャツディーゼルDIESELディーゼル バッグディーゼル 財布ディーゼル ネックレスディーゼル サングラスディーゼル リングディーゼル 香水ディーゼル シューズディーゼル アウターディーゼル シャツディーゼル ジーンズディーゼル Tシャツディーゼル 時計ディーゼル インナーデリヘル 大阪仙台 デリヘル仙台 風俗仙台 デリヘル仙台 風俗仙台 デリヘル仙台 風俗家族葬滋賀 賃貸葬儀 費用滋賀県の賃貸滋賀の賃貸アダルト SEO被リンク相互リンク茶道具 買取絵画 買取レザー革小物クレジットカード 現金化現金化ショッピング枠 現金化クレジットカード 現金化現金化ショッピング枠 現金化脱毛 大阪埋没 大阪わきが 大阪オーロラ 大阪クリニックエスニックタウンサーチ探偵 大阪浮気調査 大阪素行調査 大阪別れさせ 大阪吹田 美容室エステ 尼崎メナード 梅田資生堂マックスファクターノエビアSK-IIメナードカネボウアルビオンアナスイイヴサンローランエスティローダーエルメスクリスチャンディオールクロエシャネルジルスチュアートブルガリメイベリンランコムFXFX 比較FX 初心者ブランド通販ヴィヴィアンウエストウッドティファニーディオールドルチェ&ガッバーナダイエットダイエット食品美容ボディケア通販キャッシング大阪 賃貸中古車 販売ルームウェア大阪 マンション賃貸マンション 神戸中古 ゴルフクラブクールビズフィットネスクラブ大阪府 司法書士クレジット 申し込みベビードール矯正歯科 東京ホワイトニング 東京大阪 ラブホテルリサイクルショップ不動産カードローン投資 信託下着即日 キャッシング三井住友銀行神戸市 中央区 税理士FX消費者金融ローン引越し生命保険ジェルネイル人材派遣ネット証券アフィリエイト格安航空券ウィークリーマンションレンタカーSEOオフィス家具合宿免許ペット用品高速バスデリヘルキャバクラ派遣コラーゲン化粧品インテリアウェディング結婚相談投資物件留学貸事務所 大阪経営コンサルティング工芸品高級品自動車保険ホテヘルレストランウェディングバイク買取運転免許ベビーカー外反母趾圧力鍋腕時計フェラガモデリヘルキャバクラセレブプラセンタカルシウム青汁ブルーベリー家具脱毛クリーム除毛クリームコスト削減 大阪弁護士 大阪車買取 大阪バイク買取 大阪エステ 大阪リフォーム 大阪
大阪 歯科派遣 大阪アルバイト 大阪転職 大阪大阪 住宅大阪 専門学校グルメ 大阪ホテル 大阪一戸建て 大阪大阪 宿泊大阪 マンションデリヘル 大阪印刷 大阪不動産 大阪賃貸 大阪ブライダル 大阪リサイクルアダルト SEO賃貸SEO 大阪イベント コンパニオン 大阪転職 大阪大阪 ラブホペット ショップ 大阪豆腐京都 不動産運転免許 合宿ヘアアイロンダイエットダイエットデリヘルキャバクラシャンパン老人ホーム精力剤大阪 ラブホテルブランド品 買取ワイン京都 不動産ペットリサイクルショップ歯科求人結婚式場バイク便動物病院美容整形外科エルメスダイエットダイエット食品腕時計ヘアアイロンクレイツアイビルa
アドストバッグネイルアクセンツヘアアイロンクレイツシャンプーアイビルジェルネイル育毛剤ドライヤーアゲハ嬢ダイエットサプリリサイクルショップ 大阪リサイクルショップ 東京リサイクルショップ 名古屋fx 口座開設fx 資料請求FX 比較大阪 不動産不動産 投資不動産 比較投資 信託 大阪投資 信託 初心者下着 女性下着 男性下着 ブログ消費者金融 審査消費者金融 ランキング消費者金融 大阪ローン 比較ローン 自動車ローン 金利引っ越し 比較引っ越し 口コミ引っ越し 挨拶保険 資料請求保険 比較保険 ランキングジェルネイル やり方ジェルネイル デザインジェルネイル 激安人材派遣 関西人材派遣 仕組みネット証券 選び方ネット証券 初心者ネット証券 手数料アフィリエイト 初心者アフィリエイト 稼ぐアフィリエイト 比較国内格安航空券格安航空券 海外格安航空券 沖縄ウィークリーマンション 東京ウィークリーマンション 大阪ウィークリーマンション 福岡レンタカー 格安レンタカー 沖縄レンタカー 東京オフィス家具 中古オフィス家具 激安オフィス家具 買取合宿免許 激安合宿免許 沖縄合宿免許 大型ペット用品 激安ペット用品 犬ペット用品 通販高速バス 時刻表高速バス 名古屋高速バス 大阪デリヘル 仙台デリヘル 大阪デリヘル 東京キャバクラ 求人キャバクラ 東京キャバクラ 大阪圧力鍋 歴史圧力鍋 構造圧力鍋 ランキングフェラガモ バッグフェラガモ 靴フェラガモ 財布セレブ 海外セレブ ファションセレブ ゴシップ青汁 ランキング青汁 効果青汁 口コミブルーベリー 栽培ブルーベリー 利用ブルーベリー 生産家具 イケア家具 ニトリ家具 イームズ脱毛クリーム 永久脱毛クリーム 男性脱毛クリーム 比較除毛クリーム ランキング除毛クリーム 男性除毛クリーム トラブル弁護士 大阪 制度弁護士 大阪 費用弁護士 大阪 トラブル車買取 大阪 相場車買取 大阪 査定車買取 大阪 比較エステ 大阪 フェイシャルエステ 大阪 求人エステ 大阪 メンズリフォーム 大阪 キッチンリフォーム 大阪 マンションリフォーム 大阪 外壁大阪 歯医者 ランキング大阪 歯医者 料金大阪 歯医者 矯正派遣 大阪 求人派遣 大阪 短期派遣 大阪 ランキングアルバイト 大阪 検索アルバイト 大阪 短期アルバイト 大阪 口コミ転職 大阪 求人転職 大阪 ランキング転職 大阪 女性大阪 住宅 検索大阪 住宅 ローン大阪 住宅 中古専門学校 大阪 美容専門学校 大阪 看護専門学校 大阪 調理大阪 グルメ カフェ大阪 グルメ お好み焼き大阪 グルメ たこ焼きホテル 大阪 シティホテルホテル 大阪 ビジネスホテルホテル 大阪 モーテル大阪 一戸建て 検索大阪 一戸建て 口コミ大阪 一戸建て ランキング大阪 宿泊 格安大阪 宿泊 高級大阪 宿泊 口コミ大阪 マンション 新築大阪 マンション 中古大阪 マンション 賃貸大阪 デリヘル 人妻大阪 デリヘル OL大阪 デリヘル 3P印刷 大阪 チラシ印刷 大阪 名刺印刷 大阪 格安大阪 不動産 検索大阪 不動産 分譲大阪 不動産 比較大阪 賃貸 学生大阪 賃貸 格安大阪 賃貸 マンションブライダル 大阪 ホテルブライダル 大阪 ヘアブライダル 大阪 プランナーリサイクルショップ 東京リサイクルショップ 大阪リサイクルショップ 比較アダルト SEO 方法アダルト SEO 大阪アダルト SEO 口コミ賃貸 検索賃貸 大阪賃貸 学生リサイクルショップ 大阪リサイクルショップ 東京リサイクルショップ 名古屋ホワイトニング 東京 料金ホワイトニング 東京 口コミホワイトニング 東京 格安ベビードール 子供ベビードール 通販ベビードール 大阪大阪 司法書士 試験大阪 司法書士 年収大阪 司法書士 求人フィットネスクラブ 大阪フィットネスクラブ 仙台フィットネスクラブ 滋賀

Name Badges said...

Really I found many great and use full information from your posts. this is helpful for us.

jimmychooshoes said...

Christian Louboutin Lima 120 sandals
Christian Louboutin Luly 140 leather sandals
Christian Louboutin Marilou woven sandals
Christian Louboutin Marpoil platform sandals
Christian Louboutin Mary Jane Slide
Christian Louboutin Mauresmo chiffon slingback
Christian Louboutin Mauresmo chiffon slingbacks
Christian Louboutin Metallic Romaine sandals
Christian Louboutin Miss Chief 100 sandals
Christian Louboutin Miss Dina 120 sandals
Christian Louboutin Miss Dina 120 sandals
Christian Louboutin Mount Street Sandals (Noir)
Christian Louboutin Neuron 100 suede sandals

eco travel agency costa rica said...

This information is very interesting, I really enjoyed, I would like get more information about this, because is very beautiful, thanks for sharing!

abercrombiefitch said...

Many people are fond of these information you shared, as they are so helpful, and we are expected to have more materials of these topic.You can also have a look at http://www.abercrombie-fitch-clothes.net

Unknown said...

Nike Air Max 2011
Nike Air Max Shoes
Nike Air Max
Nike Air Max Wildwood Supreme
Nike Air Max Turbulence
Nike Air Max Skyline
Nike Air Max Goadome
Nike Air Max Fitsole
Nike Air Max Zenyth
Nike Air Max Boots
Nike Air Max Zoom Kobe
Nike Air Max Tn
Nike Air Max Presto
Nike Air Max BW
Nike Air Max 24 7
Nike Air Max 2011
Nike Air Max 2009
Nike Air Max 95
Nike Air Max 91
Nike Air Max 87
Nike Air Max 180
Nike Air Max Griffey Max 1
Nike Air Max 90
Nike Air Max 1
Abercrombie and Fitch London
Abercrombie & Fitch Clothes
Vibram Shoes

クレジットカード現金化 said...

クレジットカードのショッピング枠を現金化
クレジットカード 現金化
ショッピング枠 現金化
クレジットカード 現金化
クレジットカード 現金化
クレジットカード 現金化
クレジットカード 現金化
クレジットカード 現金化
ショッピング枠 現金化
クレジットカード 現金化
クレジットカード 現金化
クレジットカード 現金化
クレジットカード 現金化

iwasaki said...

クレジットカード現金化 比較
お金に困った時の現金化の裏技較
カード現金化の裏技 口コミ
クレジットカード現金化体験談
カード現金化の口コミ体験談

Phuwadon said...

สล็อตทำเงิน joker gaming slot jokerslot.ninja ไม่ว่าจะเป็นรางวัลโบนัสที่แตกง่าย ผ่านทางเว็ปสล็อตคาสิโนออนไลน์.