Note that there are some explanatory texts on larger screens.

plurals
  1. POActionScript - Determine A Caller's Class?
    primarykey
    data
    text
    <p>since the <a href="https://stackoverflow.com/questions/5465793/actionscript-read-only-property-and-private-set-method">MXMLC compiler doesn't support mixed access modifiers for setters/getters</a>, i would like to know whether a public setter function is being called from inside or outside of the setter's class. this approach should allow me to maintain a public property but with more security, something like public/private hybrid access.</p> <p>is it possible to use arguments' callee property, or perhaps something else, to determine whether the setter was set internally from the setter's class or if it was set externally?</p> <p>here's an example of what i mean:</p> <pre><code>package { //Class public class MyLocation { //Constants public static const LOCATION_LEFT:String = "locationLeft"; public static const LOCATION_RIGHT:String = "locationRight"; //Properties private var sideLocationProperty:String; //Constructor public function MyLocation(sideLocation:String = MyLocation.LOCATION_LEFT) { this.sideLocation = sideLocation; trace(sideLocation); } //Texture Panel Is Collapsed Setter public function set sideLocation(value:String):void { if (value != LOCATION_LEFT &amp;&amp; value != LOCATION_RIGHT &amp;&amp; value != LOCATION_AUTO) throw new ArgumentError("\"MyLocation set sideLocation(value:String)\" – value parameter is not supported."); sideLocationProperty = value; //pseudo code if (arguments.callee is from MyLocation) trace("sideLocation was set internally"); else trace("sideLocation was set externally"); } //Texture Panel Is Collapsed Getter public function get sideLocation():String { return sideLocationProperty; } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload