Note that there are some explanatory texts on larger screens.

plurals
  1. POAS3 reflection. How to find out if a method is overridden?
    primarykey
    data
    text
    <p>Is it possible to use AS3 reflection to find out if a method was overridden?</p> <p>I need a method like:</p> <pre><code>protected function isOverriden(methodName:string) : bool { //magic here! //... return awesomeLocalVariable; } </code></pre> <p>So, I pass in the method name as a string and the isOverridden method yields true only if and only if the object has a method of that name and it is overridden from its original implementation.</p> <p>Any idea on how to code the magic there?</p> <p>Thanks.</p> <p><strong>Edit:</strong> As requested, the context of the problem:</p> <p>I'm building a framework for creating AS3 games. I want to provide "components" for my game objects, each component provides functionality to the game object it is applied. Components are based on events (onClick, onUpdate, onShapeCollision, etc) I need this code in the Component class, so I can register only the events that the actual Component-derived class implements (overrides).</p> <p>Example component:</p> <pre><code> public class CTrace extends ScriptComponent { public override function onClick(event:MouseEvent = null):void { trace(Owner.Id); } } </code></pre> <p>The framework should register the onClick method as the event handler for the MouseEvent.CLICK event because it overrides the default implementation.</p> <p>Why do I need the default implementation? Because I want the classes to override the supported methods so there will be a compile time error if the user tries to use an unsupported event. </p> <p>Does that makes sense?</p>
    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.
 

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