| This is NOT the official website of AvantBiz Consulting Limitd but just some casual discussions about various topics. Please visit www.avantbiz.com if you need our professional services. |
Dynamically loading bitmaps with smoothing in Flash Player 8 March 11, 2009
Posted by eddie in : Computer 電腦,Flash , add a commentFunction
import flash.display.*;
function loadBitmapSmoothed(url:String, target:MovieClip) {
// Create a movie clip which will contain our unsmoothed bitmap
var bmc:MovieClip = target.createEmptyMovieClip(“bmc”,target.getNextHighestDepth());
// Create a listener which will notify us when the bitmap loaded successfully
var listener:Object = new Object();
// Track the target
listener.tmc = target;
// If the bitmap loaded successfully we redraw the movie into
// a BitmapData object and then attach that BitmapData to the target
// movie clip with the smoothing flag turned on.
listener.onLoadInit = function(mc:MovieClip) {
mc._visible = false;
var bitmap:BitmapData = new BitmapData(mc._width, mc._height, true);
this.tmc.attachBitmap(bitmap, this.tmc.getNextHighestDepth(),”auto”, true);
bitmap.draw(mc);
};
// Do it, load the bitmap now
var loader:MovieClipLoader = new MovieClipLoader();
loader.addListener(listener);
loader.loadClip(url, bmc);
}
To use this snippet simple paste the function into your code and then load a bitmap this way f.ex.:
loadBitmapSmoothed(“flash.png”, mc1.mc);
Display Html parm in Flash movie January 16, 2008
Posted by eddie in : Flash , add a commenthttp://kb.adobe.com/selfservice/viewContent.do?externalId=tn_14808&sliceId=2~
Unicode show in Flash
Posted by eddie in : Flash , add a comment1.System.useCodepage = false;
2.XML convert to Unicode
3.Choose “use device fonts” in flash text box
more details show in the following link
http://www.adobe.com/support/flash/languages/unicode_in_flmx/unicode_in_flmx11.html
Flash Player 各版本的使用率 April 4, 2007
Posted by eddie in : Computer 電腦,Flash , add a commentMacromedia Flash content reaches 97.6% of Internet viewers
http://www.macromedia.com/software/player_census/flashplayer/
Worldwide Ubiquity of Macromedia Flash by Version
http://www.macromedia.com/software/player_census/flashplayer/version_penetration.html
Understanding the changes in the display API in ActionScript 3.0
Posted by eddie in : Computer 電腦,Flash , add a comment官網的一篇基礎教學:
http://www.adobe.com/devnet/actionscript/articles/display_api.html
針對 display 在 AS2 與 AS3 之間的改變。
要注意的重點在於:
1. 以前我們觀念中都是對 MovieClip 在作事情,現在要想像 所做的事情 都是發生在 記憶體 中,然後 必須 將做出來的東西 加到 某個 Container 中,才會顯示在 Stage 上。
2. 以前的 MovieClip,現在已經被重構其繼承架構,所以若是你要做的事情不是太複雜,不需要真的產生一個完整的 MC 的話,其實可以考慮建立其父類別的物件,譬如 Sprite。
3. 繪圖 API,也不再是直接透過 MovieClip 進行,而要透過 graphics 達到,這點,知道一下即可。
4. 事件處理程序,你必須越來越習慣 addEventListener,知道一下即可。
How to Fix IE 7 Flash bug January 25, 2007
Posted by eddie in : Computer 電腦,Flash,Web 網頁 , add a commentAdobe’s Developer Center has tackled this issue:
http://www.adobe.com/devnet/activecontent/
http://blog.deconcept.com/flashobject/
ActionScript 3 QuickTip #2: The Timer Class December 19, 2006
Posted by eddie in : Computer 電腦,Flash , add a commentIn previous version of ActionScript there were a couple of different ways to trigger events based on time. The setInterval() and setTimeout() functions were the two most commonly used ways of calling a function after a specified amount of time had lapsed. In ActionScript 3 we now have the Timer class which lives in the flash.utils package. This class contains all the functionality that you will ever need for time-based applications. In order to use the class, you first must import the flash.utils package as seen is the example below. The Timer constructor expects one argument that represents the desired delay in milliseconds between function calls. An optional seconds argument determines the number of times to call the function. The default for this value is 0, which means that it will call the function indefinitely. If you wanted to replicate the functionality of the deprecated setTimeout() function, you can simply pass 1 as the value for this parameter.
In my example below I am creating a Timer that will fire twice a second, but I haven’t yet told it what function to call every time the delay has passed. To do this we need to respond to the timer event of the Timer class and give it the name of the function that will handle the event. At this point our Timer will be setup for use but we still need to call the Timer.start() method in order to get things started. In my implementation below I am simply doing a trace() to the output window every time the Timer fires showing how many times it has fired. To get this value I am reading the Timer.currentCount property.
-
// We need to import the utils package
-
import flash.utils.*;
-
// Create a new Timer object with a delay of 500 ms
-
var myTimer:Timer = new Timer(500);
-
myTimer.addEventListener(“timer”, timedFunction);
-
// Start the timer
-
myTimer.start();
-
// Function will be called every 500 milliseconds
-
function timedFunction(eventArgs:TimerEvent)
-
{
-
trace(“Timer fired ” + myTimer.currentCount + ” times.”);
-
}
Check out the AS 3 docs to see all of the available properties and methods of this great new class.
ActionScript 3 QuickTip #1: Dynamic Frame Rates December 14, 2006
Posted by eddie in : Computer 電腦,Flash , add a commentActionScript 3 QuickTip #1: Dynamic Frame Rates
This is a *very* cool new feature in ActionScript 3. We now have the ability to dynamically change the SWF frame rate at runtime using ActionScript. In the example below I have a somewhat creepy clown who is animating from side-to-side on the screen. You can use the slider to change the frame rate from 0 to 800 and something. There are a lot of applications for this such as lowering the frame rate for slower machines dynamically. The AS 3 code from the example is posted below:
-
this.stage.frameRate = 0;
-
rate.text = “0 fps”;
-
thumb.addEventListener(MouseEvent.MOUSE_DOWN, starter);
-
thumb.addEventListener(MouseEvent.MOUSE_UP, stopper);
-
thumb.addEventListener(MouseEvent.MOUSE_OUT, stopper);
-
thumb.addEventListener(MouseEvent.MOUSE_MOVE, mover);
-
function starter(args:Event)
-
{
-
thumb.startDrag(false, new Rectangle(track.x, thumb.y, track.width, 0));
-
}
-
function stopper(args:Event)
-
{
-
thumb.stopDrag();
-
}
-
function mover(args:Event)
-
{
-
var dist:Number = (thumb.x – track.x) / (track.width + track.x);
-
this.stage.frameRate = Math.round(dist*1000);
-
rate.text = Math.round(dist*1000).toString() + ” fps”;
-
}