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

  • Home
  • SEARCH
  • 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 375711
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T14:31:43+00:00 2026-05-12T14:31:43+00:00

I’m a little bit new to Actionscript, but I can’t figure this one out.

  • 0

I’m a little bit new to Actionscript, but I can’t figure this one out. I’ve done a lot of searching on this topic and haven’t found a clear answer. I’ve tried the following solutions that people posted online but none of them work.

All the following solutions give the error: 1120: Access of undefined property myVariable

Suggestion #1:

try {
     trace(myVariable); }
catch {
     trace("your variable doesn't exist"); }

Suggestion #2:

if (myVariable) {
     trace("your variable exists!!"); }
else {
     trace("it doesn't exist"); }

Suggestion #3:

if ( myVariable == null )
     trace("your variable doesn't exist");

Suggestion #4:

if ( myVariable == undefined )
     trace("your variable doesn't exist");

Like I said, I’ve found many forums posts and stuff online that give the above suggestions saying they will work, but they all seem to be giving me that same 1120: Access of undefined property myVariable error.

By the way, in case you are wondering why I would need to check if a variable exists or not, I’m planning on passing variables to the SWF in its URL, so I need to make sure the proper variables exist and handle the code properly if they are not passed in.


Thanks for the quick reply. Still not really working. The scope of the variable is just on the top/root level of the script. Basically, I start a new flash file, on the first frame I add the following action:

// to check for this.myVariable
if ( this.hasOwnProperty( "myVariable" ) ) {
     trace("myVariable exists");
}
else
{
     //Variable doesn't exist, so declare it now
     trace("declaring variable now...");
     var myVariable = "Default Value";
}

trace(myVariable);

When I run the flash file, I get this output:

myVariable exists
undefined

I was expecting this:

declaring variable now...
Default Value
  • 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-05-12T14:31:44+00:00Added an answer on May 12, 2026 at 2:31 pm

    By the way, in case you are wondering
    why I would need to check if a
    variable exists or not, I’m planning
    on passing variables to the SWF in its
    URL, so I need to make sure the proper
    variables exist and handle the code
    properly if they are not passed in.

    Then you are taking the wrong approach. Here’s the right way™ to read and validate SWF parameters, along with default value if they don’t exist:

    private function parameter(name:String, defaultValue:String):String
    {
            // Get parameter list
        var paramObj:Object = LoaderInfo(stage.loaderInfo).parameters;
    
            // Check if parameter exists
        if(paramObj.hasOwnProperty(name) && paramObj[name] != "")
            return paramObj[name];                     
        else
            return defaultValue;
    }
    

    Warning! Since this relays on the ‘stage’ property, Use this code either from the Document Class or after Event.ADDED_TO_STAGE.

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

Sidebar

Related Questions

Does anyone know how can I replace this 2 symbol below from the string
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Seemingly simple, but I cannot find anything relevant on the web. What is the
this is what i have right now Drawing an RSS feed into the php,
I want to count how many characters a certain string has in PHP, but
I have a French site that I want to parse, but am running into
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I'm making a simple page using Google Maps API 3. My first. One marker

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.