I guess we could write a story about they way we wish life would be. ;-)
Peace, Mike On 5/4/07, Sebastian Feher <[EMAIL PROTECTED]> wrote:
Oh, nooo! Thanks Mike, I was kinda expecting that but hoping some magic trick would come to save my design. Well, easy comes easy goes.. --- In [email protected] <flexcoders%40yahoogroups.com>, "Michael Schmalle" <[EMAIL PROTECTED]> wrote: > > Opps, > > if (stringid is StringId) > > This should have been > > if (stringid is Id) > > > I guess. :) > > Peace, Mike > > > On 5/4/07, Michael Schmalle <[EMAIL PROTECTED]> wrote: > > > > Hi, > > > > > var sid2 :StringId = "ID_101-102-103"; > > > > There is no way you can do that. AS3 uses typing and that is all you are > > doing. > > > > The "" is the string constructor and there is no way to change that. > > > > If I understand what you are asking there is something you can use so you > > don't have to use toString(). > > > > > > public function StringId(stringId :Object) > > { > > if (stringid is StringId) > > this.guid = stringId.toString(); > > else if(stringid is String) > > this.guid = stringid; > > else > > throw new Error("Incorrect argument type. Must be of type String or > > StringId"); > > } > > > > > > On 5/4/07, Sebastian Feher <[EMAIL PROTECTED]> wrote: > > > > > > I need a class that contains one string that has some constrains when > > > is created. > > > > > > package mypackage > > > { > > > public class StringId > > > { > > > private var stringId :String; > > > > > > public function StringId(stringId :Id) > > > { > > > this.guid = stringId; > > > } > > > } > > > } > > > > > > This works fine: > > > var sid1 :StringId = new StringId("ID_101-102-103"); > > > > > > but I would like to be able to type also: > > > var sid2 :StringId = "ID_101-102-103"; > > > > > > and: > > > var sid3 :StringId = new StringId(sid1); > > > > > > Is there any copy constructor / assignment operator / multiple > > > constructors trick that I can use? > > > > > > The last one I can either replace with: > > > var sid3 :StringId = new StringId(sid1.toString()); > > > > > > or have the constructor make the distinction between the String and > > > StringId being passed in. > > > > > > Any ideas/hints ? > > > > > > Thanks, > > > Sebastian > > > > > > > > > > > > > > > > > -- > > Teoti Graphix > > http://www.teotigraphix.com > > > > Blog - Flex2Components > > http://www.flex2components.com > > > > You can find more by solving the problem then by 'asking the question'. > > > > > -- > Teoti Graphix > http://www.teotigraphix.com > > Blog - Flex2Components > http://www.flex2components.com > > You can find more by solving the problem then by 'asking the question'. >
-- Teoti Graphix http://www.teotigraphix.com Blog - Flex2Components http://www.flex2components.com You can find more by solving the problem then by 'asking the question'.

