PDA

View Full Version : how can i set default value on a textInput in action script 3?


genxsol
06-25-2009, 02:28 PM
Hi World,

is there any way to put a default value on a TextInput below for user help

var textField : TextInput = new TextInput();

any example plz

TomMalufe
06-25-2009, 02:32 PM
There is no TextInput type, unless you make it yourself (which I have done in the past). You need to use TextField:
var txtF : TextField = new TextField();
txtF.type = TextFieldType.INPUT;
txtF.text = "default text";
addChild(txtF);

genxsol
06-25-2009, 02:47 PM
i used ur code and got this error
TypeError: Error #1034: Type Coercion failed: cannot convert flash.text::TextField@cc28b51 to mx.core.IUIComponent.
at mx.core::Container/http://www.adobe.com/2006/flex/mx/internal::addingChild()[C:\autobuild\3.x\frameworks\projects\framework\src \mx\core\Container.as:3259]
at mx.core::Container/addChildAt()[C:\autobuild\3.x\frameworks\projects\framework\src \mx\core\Container.as:2207]
at mx.core::Container/addChild()[C:\autobuild\3.x\frameworks\projects\framework\src \mx\core\Container.as:2140]

////////////////////////

can you plz share how did u make text input type ?

tadster
06-25-2009, 03:12 PM
Tom is right, and also make sure you have imported in the TextField Class :


import flash.text.TextField;
..or..
import flash.text.*;


We need to see your code to help out more, is this a Flex project?