-
quality in flash8
In flashplayer 7 the action
_quality="BEST"
was used to set the movie to very high rendering quality, which made all the jpegs, dynamically imported or not, look very smooth.
As far as imported to library images are concerned, the allow smoothing option is enough. But what about the dynamically loaded (external files)?
According to flash8 help Bitmaps are smoothed based on the smoothing parameter used in MovieClip.attachBitmap(). But, attachBitmap is only used for images with linkage in the library.
What about the external ones?
This is necessary if I have to resize the loaded images, since they become pixelated, in contrast with flashplayer7, where _quality="BEST" was enough.
Any suggestions?
-
Flash Gordon
I ran over the same problem...
You have to draw the loaded Image into a Bitmap Data Object, and attach it
to a movieClip again..
See BitmapData.draw()
I did me a class to do that job, which i have unfortunatly @ work ..
My letters on the F1 key have faded, how are yours today?
-
Can you please give an example for loading an image (lets say test.jpg) with a scale of 200% smoothed?
-
Flash Gordon
Well here is my Loading Class:
Code:
import flash.display.BitmapData;
/**
* @author McUsher - Torsten Ascher
*/
class ImageLoader {
private var loader:MovieClipLoader;
private var loadListener:Object = new Object();
private var alignLeft:String;
private var alignTop:String;
private var imgUrl:String;
private var imgHolder:MovieClip;
private var holder:MovieClip;
private var bm : BitmapData;
function ImageLoader(img:String, where:MovieClip)
{
holder = where;
imgUrl = img;
}
public function execute():Void
{
/*
* Check if image hasen't been loaded yet
*/
if (!holder["img"])
{
imgHolder = holder.createEmptyMovieClip("img",1);
}
if(imgUrl != holder["imgurl"]){
/*
* load the image
*/
loader = new MovieClipLoader();
var self:ImageLoader = this;
loadListener["onLoadInit"] = function (target_mc:MovieClip){
self.loadingDone(target_mc);
};
loadListener["onLoadError"] = function (target_mc:MovieClip){
self.imgUrl = "flash/img404.swf";;
self.execute();
};
loader.addListener(loadListener);
loader.loadClip(imgUrl,imgHolder);
holder["imgurl"] = imgUrl;
}
}
private function imgRef(obj:MovieClip, item:ContextMenuItem):Void
{
getURL(item["imgUrl"],"_blank");
}
private function loadingDone(target_mc:MovieClip):Void
{
/*
* redraw the loaded Image for better quality
*/
bm = new BitmapData(target_mc._width, target_mc._height, true , 0x00000000);
bm.draw(target_mc);
imgHolder = holder.createEmptyMovieClip("img",1);
target_mc = imgHolder;
imgHolder.attachBitmap(bm,1,"always",true);
delete bm;
/*
* Add img path to context Menu
*/
var self:ImageLoader = this;
var imgLink:ContextMenu = new ContextMenu();
var menuItem_cmi:ContextMenuItem = new ContextMenuItem(imgUrl, imgRef);
menuItem_cmi["imgUrl"] = imgUrl;
imgLink.customItems.push(menuItem_cmi);
imgHolder.menu = imgLink;
}
}
usage is:
new ImageLoader("blabla.jpg",loadIntoMC).execute();
the important redraw part is marked in bold
HF with it
Last edited by McUsher; 01-24-2006 at 07:55 AM.
My letters on the F1 key have faded, how are yours today?
-
Since I have never worked with classes, could you please give a hint of how to use this code?
Thank you in advance.
-
Flash Gordon
ok,
1) create a new ActionScript file
2) paste my code in there
3) Save it in the same directory where your Fla is, name: ImageLoader.as
4) in your fla to load an image with that class:
new ImageLoader("blabla.jpg",loadIntoMC).execute();
where "blabla.jpg" is the path to the image like in loadMovie
and loadIntoMC is a reference to a MovieClip.. (not a String)
My letters on the F1 key have faded, how are yours today?
-
-
One last question:
What about the images dynamically loaded on text boxes like this one:
http://www.hitech.gr/data/archive.html
?
-
Flash Gordon
Well you would put the text box into a container MC, and draw that
into a BitmapData Object, but then you will loose functionality...
Basically the better idea would be not scaling the content in this case,
if possible. As at 100% width/height you won't see a difference between
a loaded Image and it beeing redrawn with the high quality setting.
My letters on the F1 key have faded, how are yours today?
-
I think you are right. The only reason I used scaled images in this site was to avoid constracting two sizes.
Thank you very much once again.
>>Nice avatar
-
Flash Gordon
7 Posts to go for your avatar
My letters on the F1 key have faded, how are yours today?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|