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 6781283
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:36:22+00:00 2026-05-26T16:36:22+00:00

I tried to execute the following actionscript3 program and I am surprised of the

  • 0

I tried to execute the following actionscript3 program and I am surprised of the result of the call to f() function. I was expecting that the result of f() was “1” or at least “undefined” but the “0” value does not makes any sense for me.

I will be pleased to have a good explanation of this behavior if you have one, or to know if you consider this behavior as “normal”.
I want to precise that I’m studying the behavior of Action Script programs in order to understand how the AVM2 really works and therefore I am not asking equivalent code to do the same thing. As a consequence if you have other tricky examples I am also interested.

package {
import flash.display.Sprite;

  public class S2 extends Sprite {
      public function f():* {
           return x;
       }      
       public static function fs():*{
           return x;
       }      
  }
}
var x:int = 1 ;
var a:S2 = new S2();
var g:Function = a.f;
var gs:Function = S2.fs;
trace("tracing(g)...:"+g()); //tracing(g)...:0
trace("tracing(gs)...:"+gs()); //tracing(gs)...:1

Note: I compiled this program with the following command line:

mxmlc -debug -static-link-runtime-shared-libraries=true -output S2.swf -- S2.as
  • 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-26T16:36:22+00:00Added an answer on May 26, 2026 at 4:36 pm

    Your x variable exists in a different scope than the x you are returning from S2.f()

    S2 extends Sprite, which in turn extends DisplayObject, which already has a x property.
    This is what you are returning.

    If you change the variable name to something like myX you will get an error a expected.

    Doing this will change what is returned:

    var a:S2 = new S2();
    a.x = 10;
    trace(a.f()); // will trace 10
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Just tried to execute a small Lua script, but unfortunately I'm doing something wrong.
I tried to execute the DESCRIBE command via a database link, but this was
When I execute the following java program, sometimes I get an empty response ,
I tried to execute the following query: RESTORE DATABASE TESTDB FROM DISK = <path
How can I execute the following query and retrieve a result via prepared statement:
I am new to Robotium and tried to execute following code to launch an
I tried to execute the following code when I ran into a wierd error.
Suppose that I execute the following SQL statements: start transaction; insert into someTable (userId,
I am using SQL Server 2008. I have tried to execute the following: BEGIN
I have a couple of applications that I would like to execute one following

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.