This is just a small experiment on Flash bitmap smoothing in ActionScript 3. A small piece of codes can be sometimes too hard if one does not know how to write it properly. You may try the below sample and adapt it for your own Flash projects.
View Sample SWF File or Download Flash Source File (Adobe Flash CS3 is required to open it)
Actionscript:
-
var flashmo_bm:Bitmap = new Bitmap();
-
var flashmo_mc:MovieClip = new MovieClip();
-
var pic_request:URLRequest = new URLRequest(“flashmo_400×300_02.jpg”);
-
var pic_loader:Loader = new Loader();pic_loader.load(pic_request);
-
pic_loader.contentLoaderInfo.addEventListener(Event.COMPLETE, on_loaded);
-
pic_loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, on_progress);
-
flashmo_info.text = “”;function on_loaded(e:Event):void
-
{
-
flashmo_bm = Bitmap(pic_loader.content);
-
flashmo_bm.x = - flashmo_bm.width * 0.5;
-
flashmo_bm.y = - flashmo_bm.height * 0.5;
-
flashmo_bm.smoothing = true;
-
-
flashmo_mc.addChild(flashmo_bm);
-
flashmo_mc.x = stage.stageWidth * 0.5;
-
flashmo_mc.y = stage.stageHeight * 0.5;
-
flashmo_mc.buttonMode = true;
-
stage.addChild(flashmo_mc);
-
-
flashmo_info.text = “Bitmap smoothing is “ + flashmo_bm.smoothing;
-
flashmo_mc.addEventListener( MouseEvent.MOUSE_DOWN, activate );
-
flashmo_mc.addEventListener( MouseEvent.CLICK, deactivate );
-
toggle_button.addEventListener( MouseEvent.CLICK, toggle_smoothing );
-
}
-
function on_progress(e:ProgressEvent):void
-
{
-
var percent:Number = Math.round(e.bytesLoaded / e.bytesTotal * 100);
-
flashmo_info.text = “Loading… “ + percent + “%”;
-
}
-
function activate(e:MouseEvent):void
-
{
-
this.addEventListener( Event.ENTER_FRAME, moving );
-
}
-
function deactivate(e:MouseEvent):void
-
{
-
this.removeEventListener( Event.ENTER_FRAME, moving );
-
}
-
function moving(e:Event):void
-
{
-
flashmo_mc.rotation = mouseX + stage.stageWidth;
-
flashmo_mc.x = mouseX;
-
flashmo_mc.y = mouseY;
-
flashmo_mc.scaleX = flashmo_mc.scaleY = 0.003 * mouseY + 0.2;
-
}
-
function toggle_smoothing(e:MouseEvent):void
-
{
-
if( flashmo_bm.smoothing == true )
-
flashmo_bm.smoothing = false;
-
else
-
flashmo_bm.smoothing = true;
-
flashmo_info.text = “Bitmap smoothing is “ + flashmo_bm.smoothing;
-
}

1 response so far ↓
1 sugandha // Sep 1, 2008 at 5:37 pm
Hi, in one of ur blog comments I read
“Liam, links will not work in your computer due to Flash Player security policy. Link will be working if you run on your web server or Local Host”
I assume you are talking about links inside externally loaded swfs.
As I am having the same problem , it works on my local system but not when deployed.
Can you tell me how to fix this? kindly mail me:)
Leave a Comment