Note that there are some explanatory texts on larger screens.

plurals
  1. POUsing [Inspectable] to build object inspector IN flex
    primarykey
    data
    text
    <p>I'm building a little tool that lets user to place some geometric figures on screen and then move them around and change their properties. I'm quite new to as3/flex.</p> <p>Figures are represented as objects in as3. So we've got Circle, Triangle, Rectangle classes with different properties.</p> <p>What I like to do is to display some kind of "object inspector" when user selects a figure. This inspector window would resemble similar thing found in many IDEs.</p> <p>Now the question is: Is it possible to take advantage from as3 [Inspectable] tag to obtain list of properties and enable changing them at runtime?</p> <p>If it's not possible then how would you approach this problem without writing type specific code to edit each object?</p> <p><strong>Edit:</strong></p> <p>Just to clarify. Consider this example:</p> <pre><code>public class Shape { /* ... */ } public class Triangle extends Shape { public var a:Number; public var h:Number; //... } public class Circle extends Shape { public var r:Number; public var name:String; //... } </code></pre> <p>I want to give the user an ability to edit <code>a</code>, <code>h</code> from <code>Triangle</code> and <code>r</code>, <code>name</code> from <code>Circle</code>.</p> <p>From what I imagine now, I could follow two paths:</p> <ol> <li><p>Make <code>Triangle</code> and <code>Circle</code> implement <code>IMyInspectable</code> and write custom <code>getProperties():Dictionary</code>, <code>getProperty(name:String):Object</code> and <code>setProperty(name:String, value:Object):void</code> methods for each type. This would involve utterly unelegant switch-spaghetti.</p></li> <li><p>I forgot when I was typing the solution number one. :(</p></li> </ol>
    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