Solved

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

Posted on 2009-05-08
4
740 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Here are some practices and techniques that can be adopted into your Flash/Flex application development process. Note: Not all "performance tips" provide an immediately-recognizable benefit.   This article does not include timing validation data,…
I have been doing hardcore actionscripting for some time; and needless to say I have faced a lot of problems in just understanding others' code rather than understanding what the code executes. A programmer's life can become hell when there are a lo…
In this tutorial viewers will learn how to create a basic shape tween animation in Flash including shape hints for smooth animation Open a new document in Flash: Draw a shape: Select another frame (how long you want the tween to be): Right click and…
The goal of the tutorial is to teach the user how to use the auto adjust feature and what the different options do. When your video is not working right you can choose the auto adjust feature to help choose your settings.

691 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