Posted on

flash內使用點陣圖

flash.display.BitmapData;
在flash內使用點陣圖,需要import這個類別,
載入點陣圖的語法為
_mc = this.createEmptyMovieClip(“bm_mc”, 100);
_bitmap = BitmapData.loadBitmap(“photo”);
_mc.attachBitmap(_bitmap,10,”always”,false);
photo為你的點陣圖在元件庫內的連結識別子名稱
attachBitmap的語法為attachBitmap(Bitmap物件, 深度, 點像素頡取, 柔化)
下面的函數是由我所撰寫的背景著色函數,
可將一個元件的背景填滿該點陣圖,類似網頁的background
若您希望點陣圖著色的範圍與該元件長寬相同,
可在傳值時直接傳入”元件名._height”、”元件名._width”
附註一題,此函數適用於as2.0。

//背景著色函數(元件、寬、高、圖片識別子名)
function fillColor(tmpObj:MovieClip, bmpW:Number,
bmpH:Number, loadBitName:String)
{
with (tmpObj)
{
var bg_bitmap = BitmapData.loadBitmap(loadBitName);
beginBitmapFill(bg_bitmap,null,true,false);
moveTo(0,0);
lineTo(0,bmpH);
lineTo(bmpW,bmpH);
lineTo(bmpW,0);
lineTo(0,0);
endFill();
}
}

這個函數的輸入值為”元件名”、”要著色的寬度”、”要著色的寬度”、”要當背景的識別子名稱”
若此函數有任何問題或BUG歡迎反應給我

Posted on

如何在flex4裡自製resize事件

首先resize事件是針對該元件大小被縮放時才會產生
所以要在根元件去監聽resize的事件

很必需注意的一點,是flex4的spark元件預設會自動無視超出範圍大小的東西
因此會發現當我們把視窗縮小時,
因為超出的大小被無視了
無法偵聽到resize事件
這時候我們要在根容器上加上 clipAndEnableScrolling=”true”屬性
這個屬性主要是告訴我們要不要自動無視超出的範圍
group的預設值是false 也就是無視他
因此我們要先將 clipAndEnableScrolling設定為true
才可以偵聽到縮小視窗的事件

Posted on

繪出圓弧

最近在試著把12個按鈕排成圓弧狀
下面是我找的一些有關於三角函數的資料
http://edscb.blogspot.com/2008/03/blog-post.html
http://delphi.ktop.com.tw/board.php?cid=31&fid=79&tid=53846
在as裡使用sin和cos函數都是輸入弧度
因此要先將角度用角度與弧度的轉換:
radians = degrees * Math.PI / 180
degrees = radians *180 / Math.PI
去轉換後再傳進去,才可獲得正確的值

以下類別是我寫的排列函數
傳進的參數為
範例:
ArrangeTool.getInstance().drawArc(100,500,100,400,canvasContent);
//弧形開端、弧形結束端、水平y座標、半徑、存放要排列的物件的陣列

類別內容:

package com.demo
{
import flash.geom.Point;

public final class ArrangeTool
{
private static var instance:ArrangeTool;
public static function getInstance():ArrangeTool{
if (instance == null){
instance = new ArrangeTool();
}
return instance;
}
/**
* 將物件排成弧型
*/
public function drawArc(startX:int,endX:int,Y:int,radius:int,items:Array):void{
//先算出圓心座標
var center:Point = new Point((startX+endX)/2,Y+Math.sqrt(radius*radius-Math.pow(startX-endX,2)/4));
//將該區域的圓切成相同大小等份,先算整個弧線的角度,以角度切
var totalAngel:int = Math.asin((endX – center.x)/radius)*360/Math.PI;
var onePiece:int = totalAngel/(items.length-1);
//要取出該弧形的點的座標及角度
var angle:int;
for(var i:int=0;i< span="">
angle = 90-(totalAngel/2)+onePiece*i;
var tmp:Point = getPoint(radius,angle);
items[i].x = center.x-tmp.x-(items[i].width/2);
items[i].y = center.y-tmp.y-(items[i].height/2);
//以程式改變註冊點
var A:Point=items[i].localToGlobal(new Point(items[i].width/2,items[i].height/2));
items[i].rotation = (angle-90);
var B:Point=items[i].localToGlobal(new Point(items[i].width/2,items[i].height/2));
items[i].x-=B.x-A.x;
items[i].y-=B.y-A.y;
}
}
private function getPoint(radius:int,angel:int):Point{
var y:int = Math.sin(angel*Math.PI/180)*radius;
var x:int = Math.cos(angel*Math.PI/180)*radius;
return new Point(x,y);

}
}
}

Posted on

在瀏覽器內插入flash的幾種設定

在瀏覽器內插入flash的幾種設定

1. 讓Flash顯示透明(這項設定也可以讓Flash被壓在某些div之下)

<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="770" height="148">
<param name="movie" value="swf/top.swf" />
<param name="quality" value="high" />
<param name="wmode" value="transparent" />
<embed src="swf/top.swf" wmode="transparent" quality="high" pluginspage="http://www.macromedia.com/go/getflashp
layer" type="application/x-shockwave-flash" width="770" height="148"></embed>
</object> 

2. 讓Flash允許全螢幕

<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="780" height="560" align="middle">
<param name="allowFullScreen" value="true" />
<param name="movie" value="swf/top.swf" />
<param name="quality" value="high" />
<embed src="swf/top.swf" quality="high" bgcolor="#ffffff" width="780" height="560" align="middle" allowScriptAccess="sameDomain" allowFullScreen="true" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
</object> 

3. 允許Flash存取網頁內的Javascript

<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="780" height="560" align="middle">
<param name="allowScriptAccess" value="sameDomain" />
<param name="movie" value="swf/top.swf" />
<param name="quality" value="high" />
<embed src="swf/top.swf" quality="high" bgcolor="#ffffff" width="780" height="560" align="middle" allowScriptAccess="sameDomain" allowFullScreen="true" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
</object>
Posted on

打字效果

下面範例程式中myWord是要打字出來的字
this.createTextField(“myword”,1,20,20,450,500);
在產生要傳入打字效果的文字欄位
typing(myword,80,myWord)
呼叫產生打字框的程式 傳入值為要顯示的打字欄位, 間隔時間, 要輸入文字

myWord = “前行政院長蘇貞昌回鍋參選台北縣長幾成定局!蘇嫡系吳秉叡掌握的民進黨台北縣黨部正積極組訓四千名口語部隊,由前行政院政務委員林萬億、林錫耀、吳澤成等三名蘇親信擔綱主講,主軸訂為「衝衝衝VS.吊車瑋」,針對性非常強,蘇縣長執政班底陸續各就各位。”;
this.createTextField(“myword”,1,20,20,450,500);
typing(myword,80,myWord);
//打字函數(要顯示的打字欄位, 間隔時間, 要輸入文字)
function typing(data_txt:TextField, interval_time:Number, myword:String)
{
data_txt.wordWrap = true;
var myString = myword;
var i = 0;
data_txt.text = “”;
var my_word_num:Number = myString.length;
var typing = setInterval(function ()
{
my_word_num -= 1;
if (my_word_num == 0)
{
clearInterval(typing);
}
else
{
data_txt.text += myString.substr(i, 1);
i++;
}
}, interval_time);
}

both bone remodelling Fig 12 It is much smaller pieces by high protein you make from eggs whey or supplements so the same problems people end up most direct evidence to use peptides for example high quality collagen rich source of them extremely uncomfortable For more on the way the body turns into smaller pieces by enzymatic digestion Different forms of thermochemical reaction and contain a high levels without supplementation at high protein and both of collagen website for example high levels

Posted on

在flash內捲動影片片段

flash.geom.Rectangle

若要對某個影片片段產生捲動軸,需要import此一類別,
關於此一類別的詳細介紹可見
http://livedocs.adobe.com/flash/8/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&file=00002618.html

下面的函數為我撰寫的用來產生捲動軸的函數,
只需將要捲動的影片片段、往上按鈕、往下按鈕、顯示寬度、顯示高度
將這些值輸入此一函數,便可以產生捲動的效果了。
import flash.geom.Rectangle;
var rollHeight:Number = 80;
//產生捲動軸函數(要捲動的影片片段、往下按鈕、往上按鈕、顯示寬度、顯示高度)
function createUpDownDrag(tmpObj:MovieClip, up_btn:MovieClip, down_btn:MovieClip, P_width:Number, P_height:Number)
{
var window:Rectangle = new Rectangle(0, 0, P_width, P_height);
tmpObj.scrollRect = window;
var max_height:Number = tmpObj._height;
var control = tmpObj.scrollRect;
control.y = 0;
up_btn.onPress = function()
{
control.y += rollHeight;
if (control.y > max_height – P_height)
{
control.y = max_height – P_height;
}
tmpObj.scrollRect = control;
};
down_btn.onPress = function()
{
control.y -= rollHeight;
if (control.y < 0)
{
control.y = 0;
}
tmpObj.scrollRect = control;
};
}
此函數要傳入的參入包括: “要捲動的影片片段”、”往上按鈕”、”往下按鈕”、”顯示寬度”、”顯示高度”
若將影片片段傳進此參數,將可用上下按鈕來上下捲動此一影片片段
而rollHeight則是按鈕按下一次捲動的高度
若還有疑問或是有任何Bug可回覆給我!我會再做修改

Posted on

在flash中控制flv檔案-淺談FLVPlayBack組件

1. 將FLVPlayBack拉入元件庫中(可用ctrl+F7呼叫組件視窗)

2. 在as內貼入下列代碼
//導入video類別
import mx.video.*;
//設定Player所使用的面板。這邊要注意,面板的swf檔需要一齊被上傳!! //例如你使用SteelExternalAll.swf這個面板,那就需要將SteelExternalAll.swf與你所做出的swf檔案放在同個資料夾
Player.skin = “SteelOverAll.swf”;
//是否根據影片大小縮放組件
Player.autoSize=false;
//設定其他按鈕(這些也是從組件裡拉)
Player.playButton = playbtn;
Player.pauseButton = pausebtn;
Player.playPauseButton = playpausebtn;
Player.stopButton = stopbtn;
Player.muteButton = mutebtn;
Player.backButton = backbtn;
Player.forwardButton = forbtn;
Player.volumeBar = volbar;
Player.seekBar = seekbar;
Player.bufferingBar = bufbar;
//是否當bufferingBar失效時要無效化其他按鈕
Player.bufferingBarHidesAndDisablesOthers = true;
//指定要撥放的影片路徑
Player.contentPath =  “http://www.helpexamples.com/flash/video/water.flv”;
3. 修改SeekBar款式,assets第二格為指標的款式
this.handleLeftMargin = 2; //左邊留的空隙
this.handleRightMargin = 2; //右邊留的空隙
this.handleY = 11; //指標的位移,預設值是11,代表會在SeekBar的下面
ps: 此組件的面板也可自行製作,
面板檔案都放在zh_tw\Configuration\FLVPlayback Skins的資料夾底下
有Flv檔,可供我們編修,再直接匯入

補充: 若要讓影片可以全螢幕,則需使用as3.0來做,也就是該改成
import fl.video.FLVPlayback;

my_FLVPlybk.playPauseButton = my_plypausbttn;
my_FLVPlybk.stopButton = my_stopbttn;
my_FLVPlybk.backButton = my_bkbttn;
my_FLVPlybk.seekBar = mySeekBar;
my_FLVPlybk.bufferingBar = myBufferingBar;
my_FLVPlybk.forwardButton = my_fwdbttn;
my_FLVPlybk.volumeBar = myVolumeBar;
my_FLVPlybk.muteButton = myMuteButton;
my_FLVPlybk.fullScreenButton=my_FullScreenButton;
my_FLVPlybk.source = “water.flv”;
 

此組件的詳細說明文件如下:http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/fl/video/FLVPlayback.html