Prefix the void operator with a colon in the ActionScript function statement to inform the compiler that the function will not return a value to the calling routine. Construct the void function such that it follows the syntax (without a return statement):
function <functionName> (arg1:type; arg2:type, ....): void
{ // function instructions;
}
Use ActionScript 3 to print a message with code that uses a void function. Use the code below to display the text stored in in the "text1" string variable with the void function named "printMessage."
var text1:" TextField = new TextField();
text1.text = "you just used your first ActionScript 3 void function";
printMessage(text1);
function printMessage(t1:string): void
(
trace (t1);
)
Use an ActionScript 3 void function that rotates a graphic named myStar one degree every time the animation displays a new animation frame (animations are often set to display anywhere from 12 to 40 frames per second).
stage.addEventListener(Event.ENTER_FRAME, rotatestar);
function rotatestar(e:Event):void
{
myStar.rotation = 1 + myStar.rotation
}
Use the void function in Javascript to create a dummy link, a link that, when clicked, will not redirect the user to another page, but instead does nothing.
<a href="javascript: void(0)">Dummy Link</a>
Use a Javascript void function in your HTML file to display a message in an alert box when a link is clicked instead of redirecting the user to different page. Use the Javascript "redirected link" code to create a link labeled "Get your student ID pin number" that will display the message "You have been assigned a student id pin number of 1202."
<a href="javascript: void(DisplayNumber=1202);alert('You have been assigned a student id pin number of '+ DisplayNumber)">Get your student ID pin number </a>
Use a Javascript void function to display the time on a page when a link is clicked instead of redirecting the the user to a different page. Use the code below in your HTML file to create a link labeled "Check the Time" that will display the current day of the week, month, year, hour, minute and second in the time zone you are in.
<a href="javascript: void(now=new Date());alert('The time is ' + now)">
Check the Time</a>