PDA

View Full Version : making your own args list for a component


hangalot
12-05-2003, 06:47 AM
hi there

I would like to know if there is anyway to specify my own list of arguments for the user to choose from, on my component parameters.

for example, when defining a component and i choose boolean as the argument type the user can choose either true or false.

so i wrote a component, adn i want the user to choose which return format he would like to get so is this a possibility.

Ciao
:D

Stimpson
12-05-2003, 08:23 AM
Hey hangalot, you're keeping yourself busy lately ;)

That's possible with inspectable metatags I believe, which you declare in the class code. They reveal certain class properties in the component inspector, and give them legal values to chooce from.

here's some reading on them:

http://www.macromedia.com/devnet/mx/flash/articles/buildtest_comp.html (page 5)

http://www.macromedia.com/devnet/mx/flash/articles/footer_component.html (page 5)

I haven't really worked with them though, so let it know how it works out :D

hangalot
12-21-2003, 10:15 AM
finally got around to using them. :D
so thanks 4 the articles that is where i got the info - specially the second one.

very easy and very nice.

this is how it works:



[Inspectable(type="String", defaultValue="column name" )]
public function set fieldName(inVal:String){
__fieldName = inVal;
return;
};
public function get fieldName():String{
return __fieldName;
};
[ Inspectable( enumeration="varChar,Numeric", defaultValue="varChar" ) ]
public function set dataType(inVal:String){
__dataType = inVal;
return;
};
public function get dataType():String{
return __dataType;
};



by placing these metatags in ur class u don't have to define the properties individualy in the component definition, then in the component definition panel u specify ur as2 class (u would have maybe noticed that if u did this all ur properties disapeared which was set?) and voila` ur properties are auomatically set.



here i defined a string and a list as choices
anyways njoy.

Stimpson
12-22-2003, 05:24 AM
Hey hangalot,

Yeah I also already tried some of them, and like it. Really a convienant and elegant solution here, as supposed to the setting parameters in FMX components :).

hangalot
12-22-2003, 06:11 AM
ja

Stimpson
12-22-2003, 06:33 AM
:p

Zeker weten.

hangalot
12-22-2003, 06:51 AM
i have another question, maybe you have solved this, but I hav not been able to find a sollution to this.

lets say i have a meta tag that is an array, i want each item in the array to choose from an enumeration.

i don't think this is easily done, maybe something like jsfl would be the answer, but maybe u know...
:D

Stimpson
12-22-2003, 02:36 PM
To be honoust I have absolutely no idea. As you said perhaps a seperate jsfl popup which looks up the correct enumeration belonging to a certain inspectable array element in the class file. Not sure if it's possible though, I haven't tried it yet anyway :D.

hangalot
12-23-2003, 07:00 PM
something along the same lines that I have not been able to resolve is how to inherit inspectable properties

From the MM help file...

InspectableList
Use the InspectableList metadata keyword to specify exactly which subset of
inspectable parameters should appear in the Property inspector. Use
InspectableList in combination with Inspectable so that you can hide
inherited attributes for subclassed components. If you do not add an
InspectableList metadata keyword to your component's class, all inspectable
parameters, including those of the component's parent classes, appear in the
Property inspector.

The InspectableList syntax is as follows:

[InspectableList("attribute1"[,...])]

// class definition

The InspectableList keyword must immediately precede the class definition
because it applies to the entire class.

The following example allows the flavorStr and colorStr properties to be
displayed in the Property inspector, but excludes other inspectable
properties from the DotParent class:

[InspectableList("flavorStr","colorStr")]

class BlackDot extends DotParent {

[Inspectable(defaultValue="strawberry")]

public var flavorStr:String;

[Inspectable(defaultValue="blue")]

public var colorStr:String;

...

}

////

any ideas?

Stimpson
12-24-2003, 06:22 AM
any ideas?I'm not sure, what are you trying to achieve exactly? :).

hangalot
12-24-2003, 08:11 AM
i have component A and B, where B extends A.
component A has certain properties which are inspectable.

According to the doc those Properties hould then be inspectable in component B as well, without having to do anything xtra.

i have not been able to acheive this.

:D

hangalot
05-07-2004, 08:43 AM
as a side note. the way to extend classes and bring their properties accross is to import the class specifically.

thus

import p.a.t.h.className //works
vs
import p.a.t.h.*

Stimpson
05-07-2004, 12:57 PM
Hey hangalot,

Wow, I didn't even you know you could extend groups of classes (as in with *). Isn't that multiple inheritance...sortoff. I though that wasnt an option with AS2 oop?? :)

hangalot
05-08-2004, 10:22 AM
ola stimpson

no i did not mean multiple inheritance, that as u noted is not allowed in the language.
what i did mean is that when u create a subclass of ur own component and u do not want to redifene the property getter and setter routines, instead of importing the parent library like this

import a.n.sample.* // where u import all the classes in a folder
u import the specific class
import a.n.sample.classS;

which would mena in the component definition the parents components that have been exposed with meta tags will also b accesible to the sub-component user.

cheers
:D

Stimpson
05-09-2004, 12:00 PM
Oh, right. To get the inherited getter/setters visible in the component inspector you mean :). Excellent! Good to know, that will come in handy :cool:.