Solved

Function to find is a number is Odd or Even in AS3

Posted on 2009-05-08
4
736 Views
Last Modified: 2013-11-11
i'm trying to create this function but i have this error:

1071: Syntax error: expected a definition keyword (such as function) after attribute returns, not false.
1084: Syntax error: expecting rightbrace before semicolon.



Thank You

function isOdd(number:int):Boolean; 
{
	//check if the number is odd or even
	if (number % 2 == 0)
	{
		returns false;
	}
	else
	{
		returns true;
	}
}

Open in new window

0
Comment
Question by:fario
  • 3
4 Comments
 
LVL 12

Expert Comment

by:alien109
ID: 24336841
remove the semicolon after Boolean.
0
 
LVL 12

Accepted Solution

by:
alien109 earned 180 total points
ID: 24336883
and you could shorten it up as

function isOdd(num)
{
      //check if the number is odd or even
      return (num % 2 != 0)
}
0
 
LVL 12

Expert Comment

by:alien109
ID: 24336894
oop. forgot the variable types - but you get the picture :)
0
 
LVL 7

Assisted Solution

by:alexpercsi
alexpercsi earned 20 total points
ID: 24336917
The keyword for returning a value is "return", not "returns"
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Flash media server 1 332
Reduce the size of the Flash SWF file it executes 12 419
Google Chrome pepflashplayer.dll 8 168
Some You tube not working in IE11 on Windows 10 and 8.1 5 81
I know the transition can be hard. We got used to the ease of use ActionScript 2 had, but honestly, it became problematic later on, especially if designers were involved in the project and found it easy to add code as they saw fit. So, this artic…
The last time I worked with Flash and Socket connections was in AS1. A recent project required flash connecting to a Socket, and sending receiving information - we figured it would be easy enough - we all know about the socket policy documents and c…
The goal of the tutorial is to teach the user how to select which audio input to use. Once you have an audio input plugged into the laptop or computer, you will go into the audio input settings and choose which audio input you want to use.
The goal of the tutorial is to teach the user what frame rate is, how to control it and what effect it has on the video.

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question