View Full Version : need help urgently
darrenleong
May 7th, 2007, 04:15 AM
Hey guys .. When i key in a integer in box A , Box B will also display that integer without typing it. How to do this ? What is the actionscript ?
http://download.yousendit.com/6B3CBE7351EBBA3E (javascript:ol('http://download.yousendit.com/6B3CBE7351EBBA3E');)
(This is my link to my project)
jwopitz
May 8th, 2007, 04:04 PM
there are a few ways of doing this depending on what IDE you are using:
Binding (if using Flex and an mx component)
manually updating the value via an event handler
depending on the context, you could use a setter function to set the value of the other box when changing the value of the integer. You should be careful with this one cuz it could be bad OOP (dep. on the context).
stringy
May 8th, 2007, 05:49 PM
second suggestion by jwopitz
var defaultText:String =
"Enter Text Here";
var title:TextField;
var t1:TextField;
title = new TextField();
title.width = 350;
title.height = 25;
title.border = true;
title.background = true;
title.selectable = false;
addChild(title);
t1 = new TextField();
t1.text = defaultText;
t1.width = 150;
t1.height = 30;
t1.x = 100;
t1.y = 150;
t1.border = true;
t1.background = true;
t1.type = TextFieldType.INPUT;
addChild(t1);
t1.addEventListener(Event.CHANGE, changeListener);
t1.addEventListener(FocusEvent.FOCUS_IN, FocusInListener);
function changeListener(e:Event):void {
title.text=t1.text
;
}
function FocusInListener(e:FocusEvent):void {
if (t1.text ==defaultText) {
t1.text = "";
}
}
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.