Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9197053
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T21:59:16+00:00 2026-06-17T21:59:16+00:00

Examples: if (foo) {} if (foo != undefined) {} if (foo != null) {}

  • 0

Examples:

if (foo) {}


if (foo != undefined) {}


if (foo != null) {}


try {foo} catch(e:Error) {}

Gives a compiler error. How do I prevent this?

Answer (thanks Poke):

// declare the variable first   
var foo:DisplayObject;

if (foo == null) {
    trace('foo is null') // traces  
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T21:59:17+00:00Added an answer on June 17, 2026 at 9:59 pm

    ActionScript 3 is statically typed. That means that every variable has to be declared before it can be used in any way. Declaring a variable is unrelated to its initialization in which the variable gets a value for the first time; very often, both are done at the same time though doing something like var myVar:uint = 2 (this declares the variable myVar as uint and initializes it with the value 2).

    So in your case, you get an error because you are accessing a variable that has not been declared, so the compiler does not know about the name you are trying to access. So you will need to make sure that your variable is actually declared before you use it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

when I look up the syntax for .data(), it gives examples like this: $('body').data('foo',
How do I make chained objects in PHP5 classes? Examples: $myclass->foo->bar->baz(); $this->foo->bar->baz(); Not: $myclass->foo()->bar()->baz();
On Pandas documentation of the pivot method, we have: Examples -------- >>> df foo
Consider this contrived, trivial example: var foo = new byte[] {246, 127}; var bar
I have a JSP page at an address like this: http://example.com/foo/bar/rawr/something.jsp When I output
var foo; console.log(typeof foo); //undefined if(typeof foo === 'undefined') console.log(1); if(!foo) console.log(2); In my
Take this code, for example: /* * foo.h * * Created on: Nov 5,
Is it unsafe to compare a variable against undefined? if(foo == undefined) vs if(foo
i have an array of undefined size, for example : <?php $array[foo] = 86
I have such example. function Bar() { this.barVal = BarValue; } function Foo() {

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.