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
Highlighted
Developer
Posts: 153
Registered: ‎10-26-2010
My Device: Bold 9900
My Carrier: AT&T
Accepted Solution

TextField testing

Hi,

 

Can anyone tell me what I'm doing wrong here?  I want text large enough to read, but it's real tiny.  I'm just playing around making a primitive text editor and I started with code from the Adobe FileReference webpage.

 

package {
	import flash.display.*;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.net.FileReference;
	import flash.net.URLRequest;
	import flash.net.FileFilter;
	import flash.text.*;
	import flash.text.TextFormat;
	import flash.text.TextFormatAlign;

	[SWF(height="600", width="1024", frameRate="30", backgroundColor="#ffffff")]
	public class EditFile extends Sprite {

		private var MyTextField:TextField = new TextField();
		private var MyButtonField:TextField = new TextField();
		private var MyFile:FileReference = new FileReference();
		private var C_format:TextFormat = new TextFormat();

		public function EditFile() {
	
			C_format.bold = true;
			C_format.size = 40;

			MyTextField.border = true;
			MyTextField.width = 700;
			MyTextField.height = 450;
			MyTextField.setTextFormat(C_format);
			MyTextField.multiline = true;
			MyTextField.type = TextFieldType.INPUT;

			MyButtonField.background = true;
			MyButtonField.backgroundColor = 0x339933;
			MyButtonField.x = 850;
			MyButtonField.y = 120;
			MyButtonField.height = 30;
			MyButtonField.text = "Click here to save";

			addChild(MyTextField);
			addChild(MyButtonField);
			MyButtonField.addEventListener(MouseEvent.CLICK, clickhandler);
			stage.nativeWindow.visible = true;

		}
		
		private function clickhandler(e:MouseEvent): void {
			MyFile.save(MyTextField.text);
		}

	}
}

 

Another cute thing is my cursor keys (kind of) work in the TextField even though there aren't any on the popup keyboard  (Maybe there should be?).  The mouse can select text, but not change the insertion point like the cursor keys can.

 

Thanks,

     Harry

--------------
Accepted PlayBook Applications: Marmi-doos, BASIC, Run and Hide, SuperClip
Accepted OS4-7 SmartPhone App: KeepLightOn
Developer
Posts: 2,462
Registered: ‎11-04-2010
My Device: Bold 9700

Re: TextField testing

[ Edited ]

Hey harry,

 

change this line:

 

MyTextField.setTextFormat(C_format);

 

to this line:

 

MyTextField.defaultTextFormat = C_format;

 

that should do the trick although i cant use my keyboard on my laptop for some reason... only works if i type with the onboard keyboard.

 

Edit: I forgot to put the explanation hah... he defaultTextFormat property applies w/e text format you tell it to all NEW text entered into the field. the setTextFormat method applies w/e text format you tell it to CURRENT text within the field.

J. Rab (Blog) (Twitter)
--
1. If you liked my post or found it useful please click on the thumbs up and provide a Like!
2. If my post solved your problem please click on the Accept as Solution button. Much appreciated!

Approved Apps: OnTrack | ssShots | Hangman
Developer
Posts: 153
Registered: ‎10-26-2010
My Device: Bold 9900
My Carrier: AT&T

Re: TextField testing

Thanks again.

 

I just noticed the simulator keyboard doesn't seem to have a way to do CAPS LOCK.

 

Sometimes my computer keyboard works and sometimes it doesn't.

 

Harry

--------------
Accepted PlayBook Applications: Marmi-doos, BASIC, Run and Hide, SuperClip
Accepted OS4-7 SmartPhone App: KeepLightOn
Contributor
Posts: 49
Registered: ‎11-18-2010
My Device: Flash Builder - PlayBook Simulator

Re: TextField testing

Just a quick note: convention is to have variables and properties start with a lowercase letter, not to mistake them for classes!

Developer
Posts: 153
Registered: ‎10-26-2010
My Device: Bold 9900
My Carrier: AT&T

Re: TextField testing

I had a girlfriend in college whose professor marked her down because she had a variable name that was not spelled 'correctly'.  As if it really matters to the compiler how it is spelled.

 

If you don't like my source code, don't read it.  Plus, you should tell Adobe that their examples are improperly uppercased.

--------------
Accepted PlayBook Applications: Marmi-doos, BASIC, Run and Hide, SuperClip
Accepted OS4-7 SmartPhone App: KeepLightOn
Contributor
Posts: 49
Registered: ‎11-18-2010
My Device: Flash Builder - PlayBook Simulator

Re: TextField testing

Sorry you misunderstood me:

 

 

  • I'm not talking about "correctly" spelling, I'm talking about "conventions";
  • Since you're looking for help: the easier to read your code is, the more answers you'll get. This is why I told you so, only to help you;
  • Sorry about your girlfriend;
  • I'm not responsible for Adobe's mistakes!

 

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

Re: TextField testing

[ Edited ]