Welcome, Have a Nice Friday
change photo form colour to b&w with swishcsript
Learn how to change the colours of an image using swishscript.
First Of All
You will need you own image or one without a copyright, and the latest version of swishmax.
open swishmax set your movie size to fit your image
.
IMPORTANT! DO NOT USE COPYRIGHTED MATERIAL IMAGAGES
Step.1
import your image into swishmax
then group it as a sprite and name it image.
On Scene_1 add the following code
normal=true;
btext="";
}
onEnterFrame() {
if(normal==true){
btext="Change To B&W";
}else if(normal==false){
btext="Change To Colour"
}
}
Code Explained:
onloade() This Event Handler Function is called once when the movie loads
normal=true this is our event handler for checking if the image is colour if so true is yes and flase is no.
btext=""; this event handler is used to clear our button text we do not want any text in the button to start with.
onEnterFrame() { This Event Handler Function is called at the start of each frame of display
if(normal==true){
btext="Change To B&W"; checks to see if the image is showing colour and if so sets the button text to display Change To B&W.
else if(normal==false){
btext="Change To Colour" this basicaly means if the text contained in the normal event handler does not say true it changes the button text to say Change To colour.
Step.2
Create a button of your style and choice, add a dynamic text box to the top of the button shape or image and name the text box btext when you are happy with how your button looks group it together as a button and name it change.
Add the following code to the button.
if(normal==true){
myFilter = new flash.filters.ColorMatrixFilter ();
myFilter.matrix = new Array
(0.333, 0.333, 0.333, 0, 0,
0.333, 0.333, 0.333, 0, 0,
0.333, 0.333, 0.333, 0, 0,
0, 0, 0, 1, 0);
image.filters = [myFilter];
normal=false;
}else if(normal==false){
myFilter = new flash.filters.ColorMatrixFilter ();
myFilter.matrix = new Array
(1, 0, 0, 0, 0,
0, 1, 0, 0, 0,
0, 0, 1, 0, 0,
0, 0, 0, 1, 0);
image.filters = [myFilter];
normal=true
}
}
The Above codes sets the RGB colour codes that determine how the image looks using the ColorMatrixFilter.
Now Press Ctrl+T to test your movie in the flash player to see if it works.
Idea
this is ok if you wish to add it to a rollover function like the demonstration below.
Just rolloover the image and then rollout of the image to see the changes.
Thank you for reading have fun!..................................
MY LINKS
Site Statistics
TOTAL: 11825
UNIQUE: 51341916
TODAY: 2030
About You
IP: 38.107.179.218
Town: Glendora
Country: US - United States
38.107.179.218
Flag:





