Solved

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

Posted on 2009-05-08
4
733 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Does Flash have a Firefox problem? 5 313
YouTube Link 10 358
To view Flash technology content error 4 6,570
Video sharing with user login 3 203
Recently, I was asked to recommend a tracking system to be implemented on a clients website. As the entire site was built on flash, my first thought was to suggest custom built tracking system. However, our company at that point of time didn't h…
In my long career of working as an actionscript developer, I had spent sleepless night often working hard to solve some small problems which actually took a lot of my development time; later found out the solutions to be a line or two. Here are s…
The goal of the tutorial is to teach the user how to live broadcast using Flash Media Live Encoder and connecting it to YouTube to broadcast. Log into your Youtube account, choose live stream settings, start live stream from Flash Media Live Enc…
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.

786 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