Welcome, Have a Nice Friday
Fruit Machine Reel Emulation Tutorial - Swishmax 2
In this tutorial you are going to learn how to create a fruit machine reel emulation, using your own graphics or photos, if you havent any, do not worry as i have prepares some graphics previously using swishmax 2 ans exported them as *.png files. Blured Reel and Normal Reel, click on the links to save the two images into your project folder.
Preview:
Step.1
Open swishmax and for the sake of this tutorial i have set the movie properties as width 200, height 300 and frame rate 25. see fig.1 below.Step.2
Now insert the blured reel image into your movie you can do this by clicking the following on the toolbar Insert | Import Image. select the reel_blur.png from your project folder and click ok.you should have something looking like fig.2 below.
Step.3
now we need to make thr graphic look like its on a reel, so using the regtangle with black outline and linear gradient set using colours from left to right, #999999, #FFFFFF, #FFFFFF, #999999 tool draw out a rectangle to cover 3 fruits make 1 main in the middle and the top and bittom fruit make it look like it is outside the rectangle see when in place use the fill transform tool
fig.3name the shape reel_mask copy and paste the shape in place and rename the duplicated shape to reel now place them in the ascending order reel_blur.png, reel, reel_mask then group all the 3 shapes together as a movie clip and name the it reel_1 do not forget to put a check in the box that says use bottom object as mask see fig 4 below.
Step.4
Add the following code to the reel_blur.png.Swishscript
onSelfEvent (enterFrame) {
this._y=this._y+25;
if (this._y>-207) {
this._y=-563;
}
}
this._y=this._y+25;
if (this._y>-207) {
this._y=-563;
}
}
Press Ctrl+T you should have something looking like fig.4a below.
fig.4a
now add the following code to Scene_1
Swishscript
onSelfEvent (load) {
spinning=false;
}
onSelfEvent (enterFrame) {
myText1=reel_1.random.myText1;
}
spinning=false;
}
onSelfEvent (enterFrame) {
myText1=reel_1.random.myText1;
}
Step.5
now import the reel_normal.png into the reel_1 movie clip this should import into the same position as the reel_blured.png now on the reel_1 movie clip add the following code.Swishscript
onFrame (1) {
setLabel("start");
}
onFrame (4) {
stop();
}
onFrame (5) {
setLabel("spinning");
}
onFrame (10) {
stop();
}
onFrame (11) {
setLabel("seven");
}
onFrame (13) {
playSound("ReelStop.mp3",false,30);
}
onFrame (25) {
playSound("ReelStop.mp3",false,30);
}
onFrame (37) {
playSound("ReelStop.mp3",false,30);
}
onFrame (49) {
playSound("ReelStop.mp3",false,30);
}
onFrame (61) {
playSound("ReelStop.mp3",false,30);
}
onFrame (73) {
playSound("ReelStop.mp3",false,30);
}
onFrame (22) {
stop();
}
onFrame (23) {
setLabel("orange");
}
onFrame (34) {
stop();
}
onFrame (35) {
setLabel("cherry");
}
onFrame (46) {
stop();
}
onFrame (47) {
setLabel("bannana");
}
onFrame (58) {
stop();
}
onFrame (59) {
setLabel("pear");
}
onFrame (70) {
stop();
}
onFrame (71) {
setLabel("bar");
}
onFrame (82) {
stop();
}
onFrame (21) {
_root.spinning=false;
_parent.start.out.gotoAndPlay("out");
}
onFrame (33) {
_root.spinning=false;
_parent.start.out.gotoAndPlay("out");
}
onFrame (45) {
_root.spinning=false;
_parent.start.out.gotoAndPlay("out");
}
onFrame (57) {
_root.spinning=false;
_parent.start.out.gotoAndPlay("out");
}
onFrame (69) {
_root.spinning=false;
_parent.start.out.gotoAndPlay("out");
}
onFrame (81) {
_root.spinning=false;
_parent.start.out.gotoAndPlay("out");
}
setLabel("start");
}
onFrame (4) {
stop();
}
onFrame (5) {
setLabel("spinning");
}
onFrame (10) {
stop();
}
onFrame (11) {
setLabel("seven");
}
onFrame (13) {
playSound("ReelStop.mp3",false,30);
}
onFrame (25) {
playSound("ReelStop.mp3",false,30);
}
onFrame (37) {
playSound("ReelStop.mp3",false,30);
}
onFrame (49) {
playSound("ReelStop.mp3",false,30);
}
onFrame (61) {
playSound("ReelStop.mp3",false,30);
}
onFrame (73) {
playSound("ReelStop.mp3",false,30);
}
onFrame (22) {
stop();
}
onFrame (23) {
setLabel("orange");
}
onFrame (34) {
stop();
}
onFrame (35) {
setLabel("cherry");
}
onFrame (46) {
stop();
}
onFrame (47) {
setLabel("bannana");
}
onFrame (58) {
stop();
}
onFrame (59) {
setLabel("pear");
}
onFrame (70) {
stop();
}
onFrame (71) {
setLabel("bar");
}
onFrame (82) {
stop();
}
onFrame (21) {
_root.spinning=false;
_parent.start.out.gotoAndPlay("out");
}
onFrame (33) {
_root.spinning=false;
_parent.start.out.gotoAndPlay("out");
}
onFrame (45) {
_root.spinning=false;
_parent.start.out.gotoAndPlay("out");
}
onFrame (57) {
_root.spinning=false;
_parent.start.out.gotoAndPlay("out");
}
onFrame (69) {
_root.spinning=false;
_parent.start.out.gotoAndPlay("out");
}
onFrame (81) {
_root.spinning=false;
_parent.start.out.gotoAndPlay("out");
}
now we have set the labels for our fruits we need to add the animation i will explain and demonstrate on one then follow the same suit for all the other fruits, fisrt of all on frame 1 of reel_1 add a remove action for the reel_blured.png and place action for the reel_normal.png then on frame 5 of reel_1 add a place action for reel_blured.png and a remove action for reel_normal.png see fig.5 below.
now on the seven label we need to add a place action for reel_normal.png and a remove action for reel_blured.png now add amove action over the next 6 frames for reel_normal.png with this highlighted move the seven down just over middle view line aka "win line" now add a move action over 4 frames, and with the frames highlighted move you seven back up into the win line view, this will give the reel the bounce action as it stops on the seven, repeat this for every other symbol, move it down untill the representing symbol is just past the middle view then back up to the view, see fig 6 below.
fig.6Step.6
whenn you have completed the animation for all the symbols you need to add a new movie clip, name it random and add the following code to it.
Swishscript
function changeNumber() {
myRange = 5;
myNumber = Math.round(Math.random()*myRange);
myText1 = myNumber;
}
onSelfEvent (enterFrame) {
if (myText1=="0") {
myText1="Seven";
}
if (myText1=="1") {
myText1="Orange";
}
if (myText1=="2") {
myText1="Cherry";
}
if (myText1=="3") {
myText1="Bannana";
}
if (myText1=="4") {
myText1="Pear";
}
if (myText1=="5") {
myText1="Bar";
}
}
onFrame (1) {
}
myRange = 5;
myNumber = Math.round(Math.random()*myRange);
myText1 = myNumber;
}
onSelfEvent (enterFrame) {
if (myText1=="0") {
myText1="Seven";
}
if (myText1=="1") {
myText1="Orange";
}
if (myText1=="2") {
myText1="Cherry";
}
if (myText1=="3") {
myText1="Bannana";
}
if (myText1=="4") {
myText1="Pear";
}
if (myText1=="5") {
myText1="Bar";
}
}
onFrame (1) {
}
now add a new movie clip and name it spin_timer now add the following code to the movie clip.
Swishscript
onFrame (1) {
setLabel("stopped");
}
onFrame (2) {
stop();
}
onFrame (3) {
setLabel("timing");
}
onFrame (55) {
if (_root.myText1=="Seven") {
_parent.gotoAndPlay("seven");
}
if (_root.myText1=="Orange") {
_parent.gotoAndPlay("orange");
}
if (_root.myText1=="Cherry") {
_parent.gotoAndPlay("cherry");
}
if (_root.myText1=="Bannana") {
_parent.gotoAndPlay("bannana");
}
if (_root.myText1=="Pear") {
_parent.gotoAndPlay("pear");
}
if (_root.myText1=="Bar") {
_parent.gotoAndPlay("bar");
}
}
onFrame (65) {
stop();
}
setLabel("stopped");
}
onFrame (2) {
stop();
}
onFrame (3) {
setLabel("timing");
}
onFrame (55) {
if (_root.myText1=="Seven") {
_parent.gotoAndPlay("seven");
}
if (_root.myText1=="Orange") {
_parent.gotoAndPlay("orange");
}
if (_root.myText1=="Cherry") {
_parent.gotoAndPlay("cherry");
}
if (_root.myText1=="Bannana") {
_parent.gotoAndPlay("bannana");
}
if (_root.myText1=="Pear") {
_parent.gotoAndPlay("pear");
}
if (_root.myText1=="Bar") {
_parent.gotoAndPlay("bar");
}
}
onFrame (65) {
stop();
}
thats prety much it for animating and stopping the reel, all you need to do now is design a spin button and add the following code to your spin button.
Swishscript
on (press) {
if (_root.spinning==false) {
_root.reel_1.random.changeNumber();
_root.reel_1.gotoAndPlay("spinning");
_root.reel_1.spin_timer.gotoAndPlay("timing");
_root.spinning=true;
}
}
if (_root.spinning==false) {
_root.reel_1.random.changeNumber();
_root.reel_1.gotoAndPlay("spinning");
_root.reel_1.spin_timer.gotoAndPlay("timing");
_root.spinning=true;
}
}
press Ctrl+t to test in flash player and you should have something working like fig.7 below.
fig.7
it doesnt look much at the moment, but you can add som graphic surrounds for your reel, it is also easy to add more reels, see below for another exanple what can be done by using this script.
You can buy the above example source file for swishmax 2 for £5.00
Thanks,
Craig.
MY LINKS
Site Statistics
TOTAL: 11775
UNIQUE: 51341879
TODAY: 2001
About You
IP: 38.107.179.217
Town: Glendora
Country: US - United States
38.107.179.217
Flag:





