Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
0

User input text trouble

New Here ,
Aug 26, 2012 Aug 26, 2012

Copy link to clipboard

Copied

I have tried multiple ways. It seems like it should be an easy task, but i am having no luck. I made a template of what i am looking for. any help would be great. I'm confused.text box trouble.png

TOPICS
ActionScript

Views

761
Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Aug 26, 2012 Aug 26, 2012

Copy link to clipboard

Copied

What is the code you have tried that is not working?  What aspect of that code is not working the way you want?

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 26, 2012 Aug 26, 2012

Copy link to clipboard

Copied

Figured out what i was doing with the input text to dynamic text and got it working. Except i had to add a button to make it work. As far as the combobox's i am lost. I need help telling the combobox "myComboBox" to change the font of "textfield2" when a certain font is selected. Here is what i have so far, built in 2 layers so far.

//layer 1 AS3 "text input" (this is working fine, would rather not have to click submit though)

mySubmitButton.addEventListener(MouseEvent.CLICK,copyText);

function copyText(e:MouseEvent):void

{

    textfield2.text = textfield1.text;

}

//layer 2 AS3 "font dropdown" (combobox is working, but i don't have a clue on how to make it change font when selected.)

import fl.data.DataProvider;

var fontArray:Array = ["Arial", "Calibri", "Bradley Hand ITC", "Freestyle Script", "Lucida Handwriting"]

var arial:Font = new ArialFont();

var myFormatBlack:TextFormat = new TextFormat();

myFormatBlack.font = arial.fontName;

myFormatBlack.size = 12;

myFormatBlack.color = 0x000000;

myComboBox.textField.setStyle("embedFonts", true);

myComboBox.textField.setStyle("textFormat", myFormatBlack);

myComboBox.dropdown.setRendererStyle("embedFonts", true);

myComboBox.dropdown.setRendererStyle("textFormat", myFormatBlack);

myComboBox.setStyle("embedFonts", true);

myComboBox.setStyle("textFormat", myFormatBlack);

myComboBox.prompt = "Select Font";

myComboBox.width = 100;

myComboBox.height = 25;

myComboBox.setStyle("textPadding", 1);

myComboBox.dataProvider = new DataProvider(fontArray)

text box trouble2.png

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Aug 26, 2012 Aug 26, 2012

Copy link to clipboard

Copied

Here is some code that does what your diagram outlines, though it does not reflect the naming you just showed.  intxt is your textfield1, outxt is your textfield2, font is the font face combobox, and size is the font size combobox.  It doesn't not require a button, this is managed via the first few lines of code

intxt.addEventListener(Event.CHANGE, writeOut);

function writeOut(evt:Event):void {
    outxt.text = intxt.text;
}

font.prompt = "FONT FACE";
font.addItem({label:"Times New Roman"});
font.addItem({label:"Papyrus"});

size.prompt = "FONT SIZE";
size.addItem({label:"18", data:18});
size.addItem({label:"32", data:32});

font.addEventListener(Event.CHANGE, setFormat);
size.addEventListener(Event.CHANGE, setFormat);

function setFormat(evt:Event):void {

   var fontface:String =  "Arial"; // these are the initial values of the output textfield
   var fontsize:Number = 10;

   if(font.selectedIndex > -1){
       fontface = font.selectedItem.label;
   }


   if(size.selectedIndex > -1){
       fontsize = size.selectedItem.data;
   }

   var textFormat:TextFormat = new TextFormat();

   textFormat.font = fontface;
   textFormat.size = fontsize;

   outxt.setTextFormat(textFormat);
}

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Aug 26, 2012 Aug 26, 2012

Copy link to clipboard

Copied

Here is a link to a sample file that is based on your design and the code I just provided:

http://www.nedwebs.com/Flash/AS3_format_text.fla

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 26, 2012 Aug 26, 2012

Copy link to clipboard

Copied

got it working pretty good. Thank you for your help.

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Aug 26, 2012 Aug 26, 2012

Copy link to clipboard

Copied

LATEST

You're welcome

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines