?
Solved

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

Posted on 2009-05-08
4
Medium Priority
?
744 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 540 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 60 total points
ID: 24336917
The keyword for returning a value is "return", not "returns"
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

This article describes a solution to a problem of subloading one movie into another when they have different SWF versions. Sometime back, I was working on an ActionScript project while I came across an interesting fact which I would like to share…
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 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 how to record live broadcast.
Suggested Courses

764 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