Welcome, Have a Nice Friday
Creating Components For Swishmax 2
First Of All
Open swishmax 2 and set the size for the canvas, i have used 355 x 25 and frame rate of 12 fps. you can do this through the Movie Properties tab Press Ctrl+J to access this.
Step.1
Using the Text tool drag out a dynamic text box and give it a name of display_txt
and a Var name of display, this is where the full date and time will be displayed. See fig.1 below for settings.
Fig.1
Step.2
Now we want to set up a date function to our component so it can display it.
on Scene_1 we want to add a on Enterframe functio to control our script so add the following script into Scene_1.
mydate = new Date();
weekday = new Array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday");
dates = mydate.getDate();
}
the above code will set a new date function in which we will grab what we want, i have used an array for the days normaily the day would be displayed as a number ie 1-7 but in the weekday array i have determined that the number of day will be substituted with the days name.
if you ran your movie at this stage you would not see anything. this would be normal for now.
Step.3
Ok now lets add a little bit more script with ore functions to carry out, add the following underneath the existing script from above.
year = mydate.getFullYear();
Hours = mydate.getHours();
Minutes = mydate.getMinutes();
Seconds = mydate.getSeconds();
if (Minutes<10) {
Minutes = "0"+Minutes;
}
if (Seconds<10) {
Seconds = "0"+Seconds;
}
The above script sets up and gathers more date functions that we will use in our component.
Month will get the current month number from the system time .
Hours will get the current hour from the system time.
Minutes will get the current minutes from the system time.
Seconds will get the current second from the system time.
if (Minutes<10) {
Minutes = "0"+Minutes;
}
if (Seconds<10) {
Seconds = "0"+Seconds;
}
checks if the minutes from the system time is less than 10 add a zero befor the number IE if minutes show 9 it will be displayed as 09 same goes for the seconds.
Step.4
So far we have set up our functions to gather the day, date, time etc, now will will add some script to take the month number loaded and display the month as words rather than the number IE if the month is 1 it will be displayed as January.
Add the following script below the previous.
month = "January";
} else if (month==1) {
month = "February";
} else if (month==2) {
month = "March";
} else if (month==3) {
month = "April";
} else if (month==4) {
month = "May";
} else if (month==5) {
month = "June";
} else if (month==6) {
month = "July";
} else if (month==7) {
month = "August";
} else if (month==8) {
month = "September";
} else if (month==9) {
month = "October";
} else if (month==10) {
month = "November";
} else if (month==11) {
month = "December";
}
The above code is prety simple to understand, it takes the current month number that is loaded into the month function and displays the months word that goes with the number.
Step.5
Now to add the final piece of the scripting that will make the whole movie functional.
add the following script below the exsisting script.
display = (weekday[mydate.getDay()]+ " the "+ (dates) + "th " + (month) + ", " + (year)+" "+ (Hours)+":"+(Minutes)+":" +(Seconds));
}else if(dates==1){
display = (weekday[mydate.getDay()]+ " the "+ (dates) + "st " + (month) + ", " + (year)+" "+ (Hours)+":"+(Minutes)+":" +(Seconds));
}else if(dates==2){
display = (weekday[mydate.getDay()]+ " the "+ (dates) + "nd " + (month) + ", " + (year)+" "+ (Hours)+":"+(Minutes)+":" +(Seconds));
}else if(dates==3){
display = (weekday[mydate.getDay()]+ " the "+ (dates) + "rd " + (month) + ", " + (year)+" "+ (Hours)+":"+(Minutes)+":" +(Seconds));
}
}
The above code display is our dynamic text boxes name so display will show the current day, month, year and time. this part checks the current day to set wether it displays st, nd, rd or th after displaying the day.
Step.6
Ok to make this into a component that you can share with others and make their life easier is to firstly decide wether otr not you wish others to see your code and edit it., you can select this option from the Authour Component tab you can select this by pressing Ctrl+0 see fig.2 below.
Fig.3
Click on the Add Button the click on Name and type Time then click on Prompt and type Change text display, click onType and select String finaly click on Control and select Edit. see fig.5 below for settings..
Fig.4
Now click on the Update Script tab and type the following parameters.time = display
now click on the Apply( before) tab and type the following display = parameters.time
now we have to decide wether or not you want to make the script visible to other users of it and also wether it is editable by others.
so open up the Object Attributes under the Modify tab and make the following selections see fig.5 below.
Fig.5
Now click OK and save the file into C:\Program Files\SWiSH Max2\components as date&time
you will now be able to drag this from the components in swishmax 2 into any movie project from now on.
Thank you for reading this tutorial i hope it has been of some help to you.
MY LINKS
Site Statistics
TOTAL: 11804
UNIQUE: 51341902
TODAY: 2015
About You
IP: 38.107.179.216
Town: Glendora
Country: US - United States
38.107.179.216
Flag:





