Solved

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

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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

This is a very simple example to help those of you who are still migrating from AS2 to AS3 understand the redesigned event model in AS3. In AS2.0, event functions (that is, the function to be performed when an event is fired) were stored as a pro…
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 …
In this tutorial viewers will learn how to create a basic motion tween animation in Flash Open a new document in Flash: Draw/import an image: Press CTRL + F8 to convert it into a graphic symbol: Select a frame (how long you want the tween to last): …
The goal of the tutorial is to teach the user how to how to record live broadcast.

746 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now