argoncloud/ActionBSON — Issue #5: setFromString
Author: egslava
Created: 2011-10-21 22:56:16+00:00
State: open

Hello. I think, that library could be better if it'll support not only method toString for type ObjectID, but method setFromString too.
It's need to change constuctor:

```as3
public function ObjectID ( bytearrayOrString : * ) : void {
if (bytearrayOrString is ByteArray)
setFromBytes( bytearrayOrString );
else if (bytearrayOrString is String)
setFromString(bytearrayOrString);
}
```
And method 'setFromString' should to be added:

```as3
public function setFromString( _id: String): void{
rep = new ByteArray();
rep.endian = Endian.LITTLE_ENDIAN;

while( _id.length > 0 ) {
var byte:String = _id.substr( 0, 2 );
_id = _id.substr(2, _id.length - 2 );
rep.writeByte( int("0x"+byte) );

}
}
```