views:

6

answers:

0

I am unsure how I would reset an IDataInput stream when deserializing data in an AIR application.

What I am attempting is:

public function readExternal(input:IDataInput):void {
  var file_version:String = null;
  try {
    file_version = input.readString();
  } catch (e:Error){
    //We have an older file type, attempt to parse
    var fs:FileStream = input as FileStream; //<!-- PROBLEM CODE
    fs.position = 0;
    first_value = input.readInt();
    second_value = input.readDouble();
  }

  if(file_version != null) {
    switch(file_version) {
    ...

The obvious problem is that my variable fs the FileStream is going to be null because you can not cast IDataInput in such a way.

I am not sure how to rectify this problem, if there is a work-around for this, or I am going to have to try something completely different.

I am going to need to reset the input stream in some fashion to gain access to first_value but I am at a complete loss trying to figure out how to do this.

Any help would be appreciated!

Thanks, Dan