Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Adobe AIR Development

Reply
Regular Contributor
Marker
Posts: 57
Registered: ‎01-12-2012
My Device: Playbook

TextArea size limit or fetchng files larger than 60Kb

[ Edited ]

Hi is there a size limit for TextArea that I haven't been aware of? I have notied that when I try to fetch large log (txt) files into a textarea, then it takes a lot of time to load the file. So I wonder if there are any function in AIR where it is possible to fetch part of the file and then in the background fetch the rest of the log/txt file or when the reader have scrolled down the text area? Anyone with good ideas?

 

Ahh there might be a limitation on this as well. I have fetched the file into a string will that be able to handle text files just below 1mb in size? Most log files is in the area of 50/60 kb, but some end up at around 900kb at max

 

And.... Buttons... is there an easy way to set a flat white style in the background instead of the grey shade? This small issue is actually driving me more nuts than above, because it should be a simple task/command, but can't find it.

Developer
jtegen
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10

Re: TextArea size limit or fetchng files larger than 60Kb

Which text area class are you using and how are you setting the text?

You can skin QNX buttons (do search on forum). You can also create your own buttons by extending UIComponent and draw your own.
Regular Contributor
Marker
Posts: 57
Registered: ‎01-12-2012
My Device: Playbook

Re: TextArea size limit or fetchng files larger than 60Kb

I am using the only textarea class that I could find in the flashbuilder

 

 

<s:TextArea id="txtField" left="0" right="0" top="70" bottom="0" contentBackgroundColor="#ffffff" borderVisible="false" />

 

I set the text like this, maybe not the cleanest way to do it.

 

protected function btnOpen_clickHandler(event:MouseEvent):void
			{
				var txtFilter:FileFilter = new FileFilter("Text", "*.txt");
				txtFile.browseForOpen("Choose a text file", [txtFilter]);
				txtFile.addEventListener(Event.SELECT, fileOpenSelected);
				
			}
			
			
			private function fileOpenSelected(event:Event):void 
			{ 
				txtFile = event.target as File; 
				stream = new FileStream(); 
				//stream.readAhead = 512;
				stream.openAsync(txtFile, FileMode.READ); 
				stream.addEventListener(Event.COMPLETE, fileReadHandler); 
			}
			
			private function fileReadHandler(event:Event):void 
			{ 
				var str:String = stream.readUTFBytes(stream.bytesAvailable); 
				stream.close(); 
				var lineEndPattern:RegExp = new RegExp(File.lineEnding, "g"); 
				str = str.replace(lineEndPattern, "\n"); 
				txtField.text = str; 
				stream.close(); 
				lblFilename.text = txtFile.name;
			}

 

I did an experiment with readAhead but never get it to work, or maybe I just misunderstood the function of it, but had hoped that, that would have been the answer to read fx 10kb of the text and then fetch the rest, but no such luck.

 

For the buttons I ended up just using an Image instead of a button, because I felt it was way too much work to do remove a grey shade like that, and with the image, it was pretty much straight forward to do and thinking of doing somekind of animation/change of icon when there is a fingerpressed or a mouseover at some point of time, when I get to it.

 

Anyway found out that I could load txt/log files more than 100kb just took so much time that it was impossible to wait for.

 

 

 

Developer
jtegen
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10

Re: TextArea size limit or fetchng files larger than 60Kb

TextArea was not really designed to hold a lot of text. You can see if "appendText(str)" is any faster. I know it is faster than doing something like mycontrol.text += str;

The other choice is to page your text as the user scrolls the control, or to just have page buttons on sections of the text.
Regular Contributor
Marker
Posts: 57
Registered: ‎01-12-2012
My Device: Playbook

Re: TextArea size limit or fetchng files larger than 60Kb

Naah not significantly faster. I will try to see if I can get paging to work, else I think it is time to see if the grass is greener on the Native side and then go with C++ to see if that is faster than AIR.

 

 

Developer
jtegen
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10

Re: TextArea size limit or fetchng files larger than 60Kb

NDK is still early beta, so you probably wont have too much luck at this point with that. But if you do, please let us know.