Hello everyone,
I have a Flash file that I use to load in transparent PNG's (line-drawings), and use Flash to allow the user to select the color of drawing, and instantly change the color.
This is all working like it should be. I am using the UILoader component to load in the image that I recieve through flashvars, and then change the color if needed.
The only thing, that the image sometimes appears not very smooth. I have seen various articles where people talk about using smoothing=true on a bitmap. But I am not quiet sure where to set this, or how this works.
I am new to Flash and ActionScript, can anybody help me? Below is my code (main.as). I left out the changeColor() and getFlashvars() function, and the import lines. because I don't think it is relevant here, and to keep everything as simple and short as possible.
Thanks alot for any help and or pointer you can give me!
package {
public class Main extends MovieClip {
public function Main() {
init();
if(getFlashvars().img != undefined) {
if(getFlashvars().clr != undefined) {
loadImage(getFlashvars().img, getFlashvars().clr);
} else {
loadImage(getFlashvars().img);
}
} else {
loadImage('example.png', 'FFFFFF');
}
}
private function init() {
ExternalInterface.addCallback('changeColor', this.changeColor);
progressBar.visible = false;
progressBar.mode = 'manual';
progressBar.source = uiLoader;
uiLoader.scaleContent = true;
uiLoader.addEventListener(ProgressEvent.PROGRESS, eventImageProgress);
uiLoader.addEventListener(Event.COMPLETE, eventImageLoaded);
}
/**
* Load a new image from the given url. Replace the color in it with newColor
*/
public function loadImage(url:String, newColor:String='') {
//progressBar.visible = true;
uiLoader.load(new URLRequest(url));
if(newColor.length > 0) {
changeColor(newColor);
}
}
}