blog.Ring.idv.tw

2007 May

手動下載「天空部落」影音

手動下載「mp3」

請參考「手動下載「天空部落」音樂」。

手動下載「flv」

下載「flv」比較麻煩一點,需要分為二個步驟~

首先我們以「楊宗緯-人質」為例。

點選此連結進去後,開啟檢視網頁原始碼~接著試著搜尋「flvplayer.swf」,會找到如下圖的資訊:

接著必須重新組合URL,如:http://mymedia.yam.com/api/m/?pID=1221862

重點一:http://mymedia.yam.com/api/m/

重點二:pID 參數

接著再點選進去之後,會發現一長串的字串,這些字串其實是會被載入至Flash~

最後試著搜尋「furl」,答案就呼之欲出了~

2007-05-18 10:50:39 | Comments (2)

手動下載「YouTube」影片

想從YouTube下載影音檔,其實目前有相當多的工具~

Vixy.netGooTube FLV RetrieverYouTube Video Downloader等…

所以這篇的重點是以「手動下載」為主!

我們暫且以「百萬大富翁」這個YouTube分享影片來作為這次的範例。

直接點上述的影片連結進去之後,開啟檢視網頁原始碼~接著試著搜尋「player2.swf」,會找到如下圖的資訊:

現在的重點就在於URL的重新組合,將上圖紅色框框的部份重新組合成:

http://www.youtube.com/get_video?video_id=iQ3AD4dRn6s&t=OEgsToPDskIijLVsqhVh6eFdy28Xvj6W

重點一:http://www.youtube.com/get_video

重點二:video_id 參數

重點三:t 參數 (類似一個session值,做個簡單的防護)

掌握這三點就能隨意下載YouTube的影音檔囉~你也可以自行寫一個全自動的下載器~

由於YouTube是採用Flash Video(FLV)的影音格式,這也有免費的播放器可供下載:FLV Player

2007-05-18 09:27:56 | Add Comment

在「onClipEvent」事件中的「this」處理

我們來看一下簡單的例子~

假設我們放一個MovieClip在Stage上,並在此MovieClip下點程式,讓它能夠隨著播放時進行旋轉~

以下均發佈成Flash Player 8 & ActionScript 2.0的swf file

程式一

onClipEvent (enterFrame)
{
    this._rotation += 5;
}

程式一ActionCode

onClipEvent (enterFrame)
{
	ActionConstantPool "this" "_rotation"
	ActionPush "this"
	ActionGetVariable
	ActionPush "_rotation" "this"
	ActionGetVariable
	ActionPush "_rotation"
	ActionGetMember
	ActionPush 5
	ActionAdd2
	ActionSetMember
	ActionEndFlag
}

程式一的ActionCode是最多的一個,我們再試著將「this」移掉試試:

程式二

onClipEvent (enterFrame)
{
    _rotation += 5;
}

程式二ActionCode

onClipEvent (enterFrame)
{
	ActionConstantPool ""
	ActionPush "" 10 "" 10
	ActionGetProperty
	ActionPush 5
	ActionAdd2
	ActionSetProperty
	ActionEndFlag
}

從上述的ActionCode可以發現精簡了不少,其實我們可以發現它相當於如下列的程式:

onClipEvent (enterFrame)
{
    setProperty("", _rotation, _rotation + 5);
}

最後我們再試著將「this」取代「double-quote」,如程式三:

程式三

onClipEvent (enterFrame)
{
    setProperty(this, _rotation, _rotation + 5);
}

程式三ActionCode

onClipEvent (enterFrame)
{
	ActionPush "this"
	ActionGetVariable
	ActionPush 10 "" 10
	ActionGetProperty
	ActionPush 5
	ActionAdd2
	ActionSetProperty
	ActionEndFlag
}

從上述三個程式的ActionCode數量來看~ 若是硬要雞蛋裡挑骨頭的話,程式二在執行上應該是有較佳的效率,純屬從結果上來推論~

2007-05-14 18:14:18 | Add Comment

ActionScript 3.0 & Flex 2 Framework Posters

2007-05-09 22:56:26 | Add Comment

Loading XML for AS 3.0

以往要載入一個外部的XML檔案的話,我們可以簡化成下列的作法:

Loading XML

var externalXML:XML = new XML();
externalXML.onLoad = function(success)
{
    trace(externalXML);
};
externalXML.load("myxml.xml");

從載入方式到Callback Event的處理,完全交由「XML」類別來孤軍奮戰~

然而ActionScript 3.0,它終於多了幾位幫手來協助它了~ 不僅減輕它的負擔,也能夠各司其職~

Loading XML for AS 3.0

var externalXML:XML;
var loader:URLLoader = new URLLoader();
var request:URLRequest = new URLRequest("myxml.xml");
loader.load(request);
loader.addEventListener(Event.COMPLETE, onComplete);
loader.addEventListener(ProgressEvent.PROGRESS, onProgress);

function onComplete(event:Event):void
{
	externalXML = new XML(event.target.data);
	trace(externalXML.toXMLString());
}
function onProgress(event:ProgressEvent):void
{	
	trace(event.bytesLoaded);
	trace(event.bytesTotal);
}

我們可以發現載入方式完全交由「URLLoader」去處理,Callback Event也委託「IEventDispatcher」來負責,最重要的是~ 這樣的作法才符合 High Cohesion and Low Coupling,大大地增強其彈性~

而且ActionScript 3.0是以ECMAScript for XML (E4X) specification (ECMA-357 edition 2)為基礎來處理XML資料,不僅更容易使用也更簡化操作~ 順便看一下例子:

var myXML:XML =
<order>
	<item id='1'>
		<menuName>burger</menuName>
		<price>3.95</price>
	</item>
	<item id='2'>
		<menuName>fries</menuName>
		<price>1.45</price>
	</item>
</order>

trace(myXML.item[0].menuName); // Output: burger
trace(myXML.item.(@id==2).menuName); // Output: fries
trace(myXML.item.(menuName=="burger").price); // Output: 3.95

果然夠簡化與方便!!!

2007-05-09 22:18:01 | Add Comment

Next Posts~:::~Previous Posts
Copyright (C) Ching-Shen Chen. All rights reserved.

::: 搜尋 :::

::: 分類 :::

::: 最新文章 :::

::: 最新回應 :::

::: 訂閱 :::

Atom feed
Atom Comment