0 Replies - 2217 Views - Last Post: 11 August 2012 - 06:24 AM Rate Topic: -----

#1 NicolasProthero  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 02-April 10

ActionScript - Open File on Android

Posted 11 August 2012 - 06:24 AM

Hi, Im trying to open file on mobile with Android. Found several codes on inet tryed them all but, when Im trying it on PC it works fine, but after installing on mobil it stops :-/

First is using FileStream
filePath = File.documentsDirectory.resolvePath("sez_os_cisN.csv");
fS = new FileStream();
try{
	fS.open(filePath,FileMode.READ);
}catch(err:Error){
	trace("fs.open error "+err.message);
}
openTF.text = fS.readMultiByte(fS.bytesAvailable,"UTF-8"); //openTF is TextField

On PC works fine, on mobile shows nothing. String read from fS.readMultiByte(fS.bytesAvailable,"UTF-8") has 0 length

Second using URLLoader
filePath2 = File.documentsDirectory.resolvePath("sez_os_cisN.csv").nativePath;
myReq = new URLRequest(filePath2);
myLoader  =  new  URLLoader();
myLoader.addEventListener(Event.COMPLETE,  fileLoaded2);
myLoader.addEventListener(IOErrorEvent.IO_ERROR,  ioErrorHandler2);
try
	{
	myLoader.load(myReq);
	}
catch (error:Error)
	{
	trace("Just  catched  the  error  :(/>");
	}

public function fileLoaded2(e:Event):void
	{
	openTF2.text = myLoader.data; //openTF2 is TextField
	}
public function ioErrorHandler2(e:IOErrorEvent):void
	{
	openTF2.text = "There  was  a  problem  loading  a  " + filePath2 + "  file:  " + e;
	}

Again on PC fine, on mobile shows error - #2032 (Some ioerror like it didn't find file)


I have third TextField where I write path to file and if it exist. On both mobile and PC it return right path and TRUE. Below screenshot from mobile

Does anyone know what could be problem and how to solve it? Thanks in advance

Attached image(s)

  • Attached Image


Is This A Good Question/Topic? 0
  • +

Page 1 of 1