Solved

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

Posted on 2009-05-08
Medium Priority
751 Views
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;
}
}
``````
0
Question by:fario
• 3

LVL 12

Expert Comment

ID: 24336841
remove the semicolon after Boolean.
0

LVL 12

Accepted Solution

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

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

LVL 7

Assisted Solution

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

## Featured Post

Question has a verified solution.

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

This is intended to introduce all collision detection principles in flash, their strengths, weaknesses and workarounds. The main method for Collision Detection in flash is using hitTestObject. But unless you'll be pushing rectangular shapes without …
I come across a lot of question about how to access things in the document class from a movieclip, or accessing something from a movieclip in the document class. It took me a while to figure this out but once I did it makes life so much easier. …
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 set there setting in Adobe Flash Media Live Encoder and YouTube for optimal video and audio quality.
###### Suggested Courses
Course of the Month8 days, 2 hours left to enroll