リモートデスクトップの再起動 [TIPS]

いつも忘れるのでメモ
Ctrl+Alt+End
または
[スタート]ボタン → [Windows セキュリティ]
どちらもタスクマネージャーが起動するので、シャットダウン→再起動。

その他ショートカットはこちらに詳しく。
リモート・デスクトップの便利なショートカット・キー : @IT
posted bymochi categry tags
pagetop

FlashのデータをHTMLに出力 [AS3]

traceCode()メソッドで文字列を渡すと、<div id="trace"></div>の中に値が出力されます。
FlashVarsのデバッグなどに便利。

▽AS
-----
import flash.external.ExternalInterface;
-----

var str:String = "sample";
this.traceCode(str);

public function traceCode(str:String)
{
  ExternalInterface.call('traceCode', str);
}

▽HTML / JavaScript
<script language="javascript">
function traceCode(str)
{
  var trace=  document.getElementById("trace");
  trace.innerHTML += str + "<br/>";
}
<script>

<div id="trace"></div>
posted bymochi categry tags
pagetop

IEのポップアップブロック回避 [AS3]

IEでFlashから_blankでリンクを呼び出すと、ポップアップブロックがかかります。
ブロックを回避するにはExternalInterfaceクラスを使って、JavaScriptのwindow.openメソッドから別ウィンドウを立ち上げるのがよいみたいです。

IEのときのみswfobjectで渡すパラメータに[external:true]を追加して、その有無によって判定する方法で解決しました。

▽JavaScript
<script type="text/javascript">
var flashvars = {};
var params = {wmode:"transparent"};
var attributes = {};
if (window.isGecko || window.ActiveXObject){
  flashvars = {external:true};
  params = {wmode:"transparent", external:true};
}
swfobject.embedSWF("main.swf", "main", "100%", "100%", "9.0.00", "js/expressInstall.swf", flashvars, params, attributes );
</script>
▽AS
private function openWindowHandler(e:Event):void
{
  var params:Object = this.loaderInfo.parameters;
  var url:String = "http://www.google.com";
  if (!params["external"]) {
    navigateToURL(new URLRequest(url),"_blank");
  } else {
    ExternalInterface.call('function(url){window.open(url, "_blank");}', url);
  }
}

FlashからJavascriptを呼べるんだから、ブラウザ判定もFlashでやった方がスマートでは?というお声をいただいたので、次回はFlash側だけで対処するようにしてみます。
こんな感じで出来る気がする..
-----
import flash.external.ExternalInterface;
-----

var agent:String = String(ExternalInterface.call("function getBrowser(){return navigator.userAgent;}"));
var url:String = "http://www.google.com";
if (agent.indexOf("MSIE") != -1) {
  navigateToURL(new URLRequest(url),"_blank");
} else {
  ExternalInterface.call('function(url){window.open(url, "_blank");}', url);
}

▽参考
FlashでnavigateToURLのパラメータに"_blank"を使った際のIEにおけるポップアップブロック問題(10/4/10修正版):戦意
IE、FirefoxでFlashから新規ウィンドウを開く際にポップアップブロックされる件を回避するバッドノウハウ(2008/02/12版)
ActionScript3 ポップアップブロック回避:ゴロゴロな一日
posted bymochi categry tags
pagetop

ブログの全テンプレートに最新記事のリストを出力する[Movable Type]

MTでは、ブログの全ページにブログ全体での最新記事のリストを出力する、ということがなかなか難しいようです。
例えば、月別アーカイブでは該当の月の記事だけが出力対象になってしまい、他のページと内容が異なってしまいます。

全てのブログの中で、最新記事の日付を表示したかったのでこちらのプラグインを使用しました。
idxctx プラグイン
<MTIndexContext></MTIndexContext>
タグで囲われた部分が一時的にインデックステンプレートの振る舞いをしてくれます。
<MTIndexContext>
<mt:Entries include_blogs="children" lastn="1">
<p>LAST UPDATE <$MTEntryDate format="%Y.%m.%d" language="en"$></p>
</mt:Entries>
</MTIndexContext>
これで、全てのブログのどのページでも同じ日付が出力されるようになりました。

また対象のブログが固定であれば、ignore_archive_contextモディファイアを使えばidxctxプラグインと同様に、一時的にアーカイブコンテキストを外すことができました。
<mt:Blogs include_blogs="2" ignore_archive_context="1">
<mt:Categories>
<p><a href="<$MTCategoryArchiveLink$>" title="<$MTCategoryBasename$>"></p> </mt:Categories>
</mt:Blogs>

▽参考
ブログの全ページに最新記事のリストを出力する裏ワザ:The blog of H.Fujimoto
posted bymochi categry tags
pagetop

全てのブログをまとめて再構築するプラグイン[Movable Type]

QuickRebuild プラグイン

管理画面に「全てのブログを再構築」ボタンがでます。
複数ブログを管理するのに便利です。

version 5.02でも動作しました。
posted bymochi categry tags
pagetop

ページ分割プラグイン[Movable Type]

MTではデフォルトでページ分割がないので、過去のエントリーを見たい場合はカテゴリや月別のアーカイブから辿らないといけないのがとても面倒。

MT5でもマニュアル通りに入れるだけで問題なく動きました。
PageBute プラグイン

これを入れたら、ぎゅうぎゅうさんのブログではPVが飛躍的に伸びたとか。
posted bymochi categry tags
pagetop

変数同士を比較する[Movable Type]

全てのエントリーの中で、現在表示されているものと一致するものを取得するサンプル。
<mt:SetVarBlock name="current_entry_id"><$MTEntryID$></mt:SetVarBlock>
<mt:Entries>
<mt:SetVarBlock name="temp_entry_id"><$MTEntryID$></mt:SetVarBlock>
<mt:If name="current_entry_id" eq="$temp_entry_id">
current_entry_idとtemp_entry_idの値が同じ時に出力したい内容
<mt:Else>
current_entry_idとtemp_entry_idの値が違う時に出力したい内容
</mt:If>
</mt:Entries>

MTIfタグ内部では
<mt:If name="current_entry_id" eq="<$MTEntryID$>">
こんな感じでMTタグは使用できないので、一度変数にして
<mt:If name="current_entry_id" eq="$temp_entry_id">
とすると比較できます。
posted bymochi categry tags
pagetop

カスタムフィールドで設定した画像をそのまま表示する [Movable Type]

画像のカスタムフィールドのベースネームをそのまま入れ込むと、「表示」というテキストリンクの先に画像が表示されてしまいます。
<mt:Entries>
<mt:If tag="main_img">
<mt:main_img>
</mt:If>
</mt:Entries>

↓出力されるHTMLソース
<span class="mt-enclosure mt-enclosure-image" style="display: inline;"><a href="http://xxxxxx.jp/photo/dummy.jpg">表示</a></span>

画像をそのまま表示したい場合は[ベースネーム名Asset]というコンテナで括るとカスタムフィールドの値が取得できるようになります。
<mt:Entries>
<mt:If tag="main_img">
<mt:main_imgAsset>
<img src="<mt:AssetURL>" />
</mt:main_imgAsset>
</mt:If>
</mt:Entries>
posted bymochi categry tags
pagetop

カスタムフィールドで設定した値で分岐処理 [Movable Type]

<mt:SetVarBlock name="sample"><mt:カスタムフィールドで設定したベースネーム></mt:SetVarBlock>
<mt:If name="sample" eq="1">
カスタムフィールドの値が1のときに出力したい内容
<mt:ElseIf eq="2">
カスタムフィールドの値が2のときに出力したい内容
<mt:Else>
カスタムフィールドの値が1,2以外ときに出力したい内容
</mt:If>
posted bymochi categry tags
pagetop

for文で連番のクラスを使用する [AS3]

AS2ではライブラリのリンケージから下のような感じでオブジェクトを配置します。
for (var i = 1; i < 5; i++)
{
  this.attachMovie("mcName" + i, "newMC" + i, i);
}

AS3は以下のような書き方でクラス名から呼び出しますが
var obj:MovieClip = new mcName0();

クラスが連番になっていてfor文等でループでクラスを作成する場合はflash.utils.getDefinitionByName()メソッドを使って以下のように書くことが出来ます。
---
import flash.utils.getDefinitionByName;
---

for (var i = 0; i < 3; i++ )
{
  var myClass:Class = getDefinitionByName("mcName" + i) as Class;
  var obj:MovieClip = new myClass();
  this.addChild(obj);
}
posted bymochi categry tags
pagetop
1  2  3  4