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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T00:54:00+00:00 2026-05-11T00:54:00+00:00

In an actionscript function (method) I have access to arguments.caller which returns a Function

  • 0

In an actionscript function (method) I have access to arguments.caller which returns a Function object but I can’t find out the name of the function represented by this Function object. Its toString() simply returns [Function] and I can’t find any other useful accessors that give me that… Help :-/

  • 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. 2026-05-11T00:54:00+00:00Added an answer on May 11, 2026 at 12:54 am

    I found an answer and I’ll paste it below.

    @fenomas: yes, you are right of course, functions are just objects and what I’m looking for is a the name of the reference to them (if exists, i.e. the function is not anonymous). You also right that in general this doesn’t look like the best way to do programming 😉 But my scenario is special: I want to implement a Checks class (similar to C CHECK) with methods such as Check.checkTrue and Checks.checkRef in which when the check fails I get a nice trace. The traces will appear only in debug version, not in release.

    I’m using MTASC and the code below only works with MTASC. It should also be used only for debugging purposes and not release. The technique is to iterate on _global and find a function that’s equal to my calling function. It’s a hack that does not always work (anonymous) but it serves me pretty well in most cases.

    39:   /** 40:    * Checks that cond is true. Use this method to validate that condition 41:    * cond holds. 42:    * If cond is false, traces a severe message and returns false to indicate 43:    * check failure. 44:    * 45:    * @param cond the contition expected to be true 46:    * @param msg the message to emit in case the condition is false. 47:    * 48:    * @return false is cond is false 49:    */ 50:   public static function checkTrue(cond:Boolean, msg:String):Boolean { 51:     if (!cond) { 52:       trace('severe', 'CHECK FAILED at ' + 53:           **getFunctionName(arguments.caller)** + ':\n' + msg); 54:     } 55:     return cond; 56:   }   94:   /** 95:    * Gets the name of the function func. 96:    * Warning: Use this only in debug version, not in release 98:    * 99:    * @return The full package path to the function. null if the function 100:    *      isn't found. 101:    */ 102:   private static function getFunctionName(func:Function):String { 103:     var name:String = getFunctionNameRecursive(func, _global); 108:     return name; 109:   } 110:  111:   /** 112:    * Gets the name of the function func by recursively iterating over root. 113:    * Warning: Use this only in debug version, not in release 114:    */ 115:   private static function getFunctionNameRecursive(func:Function, 116:       root:Object):String { 117:     if (!root) { 118:       return null; 119:     } 120:  121:     // Iterate over classes in this package 122:     // A class is a function with a prototype object 123:     for (var i:String in root) { 124:       if (root[i] instanceof Function && root[i].prototype != null) { 125:         // Found a class. 126:         // Iterate over class static members to see if there's a match 127:         for (var f:String in root[i]) { 128:           if(root[i][f] == func) { 129:             return i + '.' + f; 130:           } 131:         } 132:         // Loop over the class's prototype to look for instance methods 133:         var instance:Object = root[i].prototype; 134:         // Reveal prototype's methods. 135:         // Warning: Not to be used in production code!!! 136:         // The following line make all the instance attributes visible to the 137:         // for-in construct. The 'n' value is 8 which means 'unhide' 138:         // See http://osflash.org/flashcoders/undocumented/assetpropflags 139:         // This operation is later undone by setting the 'n' to 1 which means 140:         // 'hide' 141:         _global.ASSetPropFlags(instance, null, 8, 1); 142:         for (var f:String in instance) { 143:           if(instance[f] == func) { 144:             return i + '.' + f; 145:           } 146:         } 147:         // And hide instance methods again 148:         // This line undoes the previous ASSetPropFlags 149:         _global.ASSetPropFlags(instance, null, 1, false); 150:       } 151:     } 152:  153:     // Iterate over sub packages. Sub packages have type 'object' 154:     for (var i:String in root) { 155:       if (typeof(root[i]) == 'object') { 156:         var name:String = getFunctionNameRecursive(func, root[i]); 157:         if (name) { 158:           return i + '.' + name; 159:         } 160:       } 161:     } 162:     return null; 163:   } 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 63k
  • Answers 63k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer Use the ParseChildrenAttribute and PersistChildrenAttribute attributes: [ParseChildren(false)] [PersistChildren(true)] public class… May 11, 2026 at 10:24 am
  • added an answer As well as waiting weeks to hear about the Magic… May 11, 2026 at 10:24 am
  • added an answer \text{and} or \text{or} If you insist on a macro, just… May 11, 2026 at 10:24 am

Related Questions

In an actionscript function (method) I have access to arguments.caller which returns a Function
What is the best way to create several scrollable regions in an ActionScript 3
In the library, right-click on a movieclip that you have written an ActionScript class
I am trying to parse JSON in an Adobe Flex app, using http://www.mikechambers.com/blog/2006/03/28/tutorial-using-json-with-flex-2-and-actionscript-3/'>This Tutorial
In ActionScript, how can you test if an object is defined, that is, not
Is it possible in Actionscript 3 to create a weak reference to an object,
In ActionScript3, how do you get a reference to an object's class?
In an application that I am currently working on, a requirement is to bring
In an application that heavily relies on .htaccess RewriteRules for its PrettyURLs (CakePHP in
In an embedded application (written in C, on a 32-bit processor) with hard real-time

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.