PDA

View Full Version : Class return



mauroluz
October 8th, 2009, 10:10 PM
Hello,

I have a question about return...

example:


var date: Date = new Date();
trace (date)//Thu Oct 8 23:05:51 GMT-0300 2009

How i can get a String return by a Class? The default return with a normal Class is ([object Date])... Constructor can`t return values... how i can make that? :p

Thanks and sorry for my sux english..

Gnoll
October 8th, 2009, 10:17 PM
Hmm? Classes aren't meant to return anything... I think that trace is calling the toString method, you should try overriding that within your class to output something custom.

Good luck,
Gnoll

mauroluz
October 8th, 2009, 11:11 PM
Hmm? Classes aren't meant to return anything... I think that trace is calling the toString method, you should try overriding that within your class to output something custom.

Good luck,
Gnoll

That`s Work! Really thanks!! :)



public function toString():String {
return "test";
}
//test

Gnoll
October 9th, 2009, 04:39 AM
Great! :)

No worries,
Gnoll