Mixi/アプリ開発/flash
提供: 初心者エンジニアの簡易メモ
Flashアプリを作る
mixi.xml
<?xml version="1.0" encoding="UTF-8" ?>
<Module>
<ModulePrefs title="mixiapp for flash" author="author1">
<Require feature="flash"/>
</ModulePrefs>
<Content type="html">
<![CDATA[
<div id="target">
<p>mixi app</p>
</div>
<script type="text/javascript">
function init() {
gadgets.flash.embedFlash(
"http://www.example/test/app.swf", "target", "6",
{
id : "appswf",
name : "appswf",
width : 400,
height : 400,
quality : 'high',
wmode : 'transparent',
allowScriptAccess : 'always'
}
);
}
gadgets.util.registerOnLoadHandler(init);
</script>
]]>
</Content>
</Module>
FlashアプリでJavascriptを利用
featureの部分をflashでなくopensocialを利用しないとなりません。
以下はスコア送信Javascriptつきタグ mixi.xml
<?xml version="1.0" encoding="UTF-8" ?> <Module> <ModulePrefs title="mixiapp for flash" author="author1"> <Require feature="opensocial-0.8"/> </ModulePrefs> <Content type="html"> <![CDATA[ <div id="targetswf" style="margin:0;padding:0"> <p>mixi app</p> </div> <script src="http://ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js"></script> <script type="text/javascript"> function init() { swfobject.embedSWF( "http://example.com/test.swf", "targetswf", "550", "400", "6.0.0", undefined, {}, { id : "appswf", name : "appswf", quality : 'high', wmode : 'transparent', allowScriptAccess : 'always' }, { id : "appswf" } // attributes ); } // スコア送信(独自関数 function setscore(score) { var params = {}; params[opensocial.Activity.Field.TITLE] ="スコアは" + score + "です"; var activity = opensocial.newActivity(params); opensocial.requestCreateActivity( activity, opensocial.CreateActivityPriority.HIGH, function(response) { if (response.hadError()) { var code = response.getErrorCode(); // do something... } else { // do something... } }); } gadgets.util.registerOnLoadHandler(init); </script> ]]> </Content> </Module>
fla側
- as2
//ExternalInterfaceクラスが使用できるようにインポート
import flash.external.*;
//ExternalInterface.クラスのcallメソッドを使って
//JavaScript側の関数を呼び出す
ExternalInterface.call("setscore", escape("12点"));
- as1
_root.getURL("javascript:setscore(\""+escape(score)+"\")", "_self");
右メニューでのガジェットアプリ表示時は画像を出す
<Content type="html" view="home, profile"><![CDATA[
<div style="border:none;margin:0px;text-align:center;width:100%;height:100%;">
<a href="http://mixi.jp/run_appli.pl?id=12345" target="_blank"><img style="border:none;" src="http://example.com/aaa.jpg" /></a>
</div>
<script type="text/javascript">
setTimeout(adjustHeight,1000);
function adjustHeight() {
gadgets.window.adjustHeight();
}
</script>
]]>
</Content>
<Content type="html" view="canvas"><![CDATA[
<div>Hello!ここはキャンバス</div>
]]>
</Content>
制作時の注意
- ieでの表示は必須なので確認すること。
- flashのjsのパラメータ配列の最後に,があるとieで動かない
公開申請時の注意
- mixiなんとかというアプリ名は×
- 既にほかで公開しているアプリは×
- 申請が棄却されると10日間再申請できなくなる
- カテゴリ掲載申請ガイドラインを熟読しておく(http://developer.mixi.co.jp/appli/policies/apps/guidelines/
