StyleableTextField multiline and WordWrap

Hello

Why are there 2 different properties for this? Shouldn't one implies the other? If I want to multiline, I want viceversa and word wrapping.

How are they different? When I just use wordWrap multiline or anything simply?

Thank you.

multiline wouldn't say the user can press ENTER to start a new line

WordWrap simply means a single long line is wrapped, but the user cannot do it with the Enter key

Tags: Flex

Similar Questions

  • Help with sum multiline and formatting «,»

    Hey guys, I need help with a question that I am struggling to solve...

    I have a multiline field in which I paste information from an excel spreadsheet. This information is in a format 1.234,56.

    I was able to have the numbers stuck on the ground in another area, by removing the ',': something like this:

    var withcoma = this.getField("Input_1").value; This is my multi-line field used to paste data from excel

    nocoma = withcoma.replace(/\,/g, ".");

    the var values = nocoma.split("\r");

    var total = 0;

    for (var i in values) total += Number(values[i]);

    this.getField("Total").value = total;


    The point is that I have to be able to change the numbers that I have to format to the format 1,234.56 1.234,56 if I choose to use a different currency than my original and also wear numbers in the field "Total" correctly updated.

    Could someone point me in the right direction?

    Thank you very much!!!

    The solution was to add another line of code to remove the periods used so that thousands separators in numbers.

  • Get the height of the line of StyleableTextField multiline

    Hello

    Then? How can I do: get the height in pixels between lines of StyleableTextField?

    The reason I need it is if I try to Center vertically, (totalHeight - StyleableTextField.textHeight) / 2 she did not consider the vertical spacing and centering is missing a few pixels.

    Thank you.

    I would avoid using the textHeight property.  It works better if you use the getElementPreferredHeight() method that provides a LabelItemRenderer?  See renderer in this thread for an example, I created.

  • Enter the text in the TextBox multiline and new lines

    Hi guys,.

    I have a form that accepts an input of users and records in an access database.

    The data are in turn attracted a recordset and displayed on an ASP using VBS.

    The form takes the info has 1 multiline textbox and I want it to be a simple input box except when the user adds a line break by pressing back I want to be taken into account when the recording is attracted on the detais page...

    Earlier no matter how many times I hit return key when you type in the multi line text box and add paragraphs or simple sentances that all come out no line breaks in page when shown?

    What I have to do my own text rich editor? or is there something Im missing?
    Thanks in advance for any thoughts.
    Tag

    Tag2007, try using the Replace function:

    Replace (your_string, Chr (13) ")
    ")

    David Powers wrote:
    > Tag2007 wrote:
    > Thanks Im on the site now and don't see the version lite? Do you have
    > link to it please...
    >
    > InterAKT was acquired by Adobe in September and most of its products
    > have been abandoned. The full version of KTML is now part of the
    > Kollection suite.
    >
    > The solution to your problem is very simple, however. I'm sorry I can't
    > gives you the exact coding, because I did not use ASP for many years.
    > However, all you need to do is create a function that looks for a
    > strings for the new line of characters and replaces them with
    (or

    (> for XHTML).
    >
    > PHP has built-in (nl2br()) to do so, but in ASP, you will need to
    > Search new character code.
    >

  • (BB10) Label multiline

    Hi all!

    I tried to return a label multiline without success.

    There were methods 'multiline' and 'wordwrap' before, but they aren't there now, so I can't force a label field to be multiline.

    When you extend there is a 'isMultiline()' method, but cannot find a way to put it.

    Any idea?

    Use:

    this.label.maxLines = 5; or what ever

  • Flex 3 problem UITextField height and layout

    Hello

    I use Flex 3 SDK 3.2.

    I have problems of determination of the height of a UITextField. (Unfortunately, I have to use the UITextField because I'm using FlashEff 2.0) "Otherwise, I would use a different component).

    I have a UITextfield multiline and wordWrap. The text is taken from a database, the length varies. I have a radioButtonGroup under the UITextField.

    My goals are:

    (a) to prevent the UITextField hit the radioButtonGroup VBox.

    (b) I want to change the position y the radioButtonGroup based on the height of the UITextField.

    (c) the TitleWindow height should be variable. The UITextField and the radioButtonGroup are a TitleWindow. I would like to change the height of the TitleWindow based on the content inside.

    At the moment, I have put y radioButtonGroup on the TitleWindow downwards, so that the content of the UITextField overlaps. But, when he doesn't are too much text in the UITextField, I get a huge gap between the radioButtonGroup VBox and her.

    I Googled, and from what I can tell, the height of the UITextField behaves strangely.

    Anyone know how to fix this?

    I create the UITextField like this:

    public var tf:UITextField = new UITextField;
    

            tf.autoSize = TextFieldAutoSize.LEFT;
         tf.embedFonts = true;
         tf.multiline = true;
         tf.text = myText;
         tf.width = 440;
         tf.wordWrap = true;
         var myFormat:TextFormat = new TextFormat;
         myFormat.size = 25;
         myFormat.blockIndent=53;
    
         this.addChild(tf);
         tf.validateNow();
         tf.setTextFormat(myFormat);
    

    My VBox looks like this:

    <mx:VBox  id="radioVBox" x="180" y="220">
         <mx:RadioButtonGroup id="myRadioButtonGroup" itemClick="goClickHandler(event);"/>
         <mx:RadioButton  groupName="myRadioButtonGroup" label="A"  fontSize="17" />
         <mx:RadioButton  groupName="myRadioButtonGroup" label="B"  fontSize="17" />
         <mx:RadioButton  groupName="myRadioButtonGroup" label="C"  fontSize="17" />
         <mx:RadioButton  groupName="myRadioButtonGroup" label="D"  fontSize="17" />
         <mx:RadioButton  groupName="myRadioButtonGroup" label="E"  fontSize="17" />
    </mx:VBox>
    

    And it's all wrapped up in a TitleWindow that looks like this:

    <mx:TitleWindow xmlns:mx="http://www.adobe.com/2006/mxml" 
         layout="absolute" 
         width="520"  
            height="450"
            verticalScrollPolicy="off" 
         horizontalScrollPolicy="off" 
          >
    
    

    Any suggestions?

    Thank you.

    -Laxmidi

    Can you put the text field in the VBox, above the radio buttons? The VBox expected

    resize and adjust accordingly.

  • Custome ItemRenderer - Vertical Center for label

    Hello

    I extend the LabelItemRender.

    I have a label called labelCategory.

    It is set to multiline and wordwrap.


    I am also from the override of the method of layoutContents and adjustment: labelCategory.y=(unscaledHeight-labelCategory.textHeight)/2;

    It works fine when there is only one line of text.

    When there are two lines of text, it is off by 2 or 3 pixels.

    Maybe it's the maximum height for rendering and it clips the label, not sure.

    The extent of substitution, I put:

    measuredHeight = Math.max (labelDisplay.textHeight, labelCategory.textHeight) + TEXT_HEIGHT_PADD ING + 10;

    TEXT_HEIGHT_PADDING is 4.

    How can I Center the vertical labelCategory even when it is 2 lines?

    Thank you.

    Measure and layout multiline text can be tricky.  I would say looking at IconItemRenderer how it for her (check out layoutContents() and measure()) messageField.

    Also, it seems that you are the size parameter and the position of the elements through the properties of x, y, width, height, but you should use setElementSize() and setElementPosition().  This will result in better performance by avoiding unnecessary available (set before the position size) passes.  It is a best practice for converters element ActionScript that inherit from the LabelItemRenderer class, but also ActionScript skins that inherit from the MobileSkin class.

    Can you tell me the docs where you got this code example of?

  • fonts Embedded html removes spaces!

    I have a dynamic html textField that has built-in fonts. When I provide it with html, it's the display text formatted (italic, bold, underlined, etc.) incorrectly. It removes a space directly in front of the word formatted.

    for example not formatted:
    Hello world

    formatting:
    Hello World

    I tried to put the space inside and outside the tag format and it makes no difference. Turn off does incorporate the field appears correctly, but my client wants to shipped, anti-aliased text.

    This seems to happen quite randomly so that text formatted in the textfield even display correctly, unlike some!

    There are symbols of police for all my fonts formatted in the library.

    Anyone can shed some light?

    Thanks for your replies.

    This has been fixed by changing to autoSize = true for autoSize = "center".

    Pretty random... It took a few hours poking around to get out!

    Automatic resizing of the textfield has been crucial, because its height determines the position of a clip below. When multiline and wordwrap are true, the lower part of the textfield object is resized dynamically. However, some bugginess was initially strange behaviors horizontally, which was causing spaces before the text formatted to move to the left, with the top of the previous letter!

    Definition of autoSize = 'center' has completely stopped the field looking at the horizontal aspect of the field and vertically. Stange but real.

  • TableView multiline cell

    How can I do with a custom TableCellFactory a TableCell multiline and do the Rowhight changed dynamics. Or how can I calculate the height of the multiline label? It still gives me 0.

    Edited by: 884604 the 12.09.2011 09:40

    Ok. This can be achieved by using the 'Text' node in the table cell. Please check the code below.

    TableColumn descCol = new TableColumn("Description");
    descCol.setPrefWidth(150);
    descCol.setCellValueFactory(new PropertyValueFactory("description"));
    Callback cellFactory = new Callback() {
         @Override
         public TableCell call( TableColumn param) {
              final TableCell cell = new TableCell() {
                   private Text text;
                   @Override
                   public void updateItem(Object item, boolean empty) {
                          super.updateItem(item, empty);
                          if (!isEmpty()) {
                            text= new Text(item.toString());
                            text.setWrappingWidth(140);
                               setGraphic(text);
                          }
                   }
              };
              return cell;
         }
    };
    descCol.setCellFactory(cellFactory);
    

    The important part is the width of the packaging for the text node.

    text.setWrappingWidth(140);
    

    Adjust the width of the package according to the width of your column.
    I hope it will be useful to you.
    Happy coding! :)

  • Can someone help me with the properties of the multiline text field?

    Adobe is not my first or second language. I have been responsible for making a form to fill out and were able to understand a little after reading the Adobe Acrobat Bible, most, however, I just can't understand this little thing that's driving me crazy! I created a large default text field (so the person filling out the form to the management a little) this field is also defined as a multiline and also make field scroll long text. The problem is that the default text is highlighted not crept to crush then tab through the various areas of creation. He puts just the cursor at the end of the text by default so using back or manually select and delete text. I looked at how to set up the rest of the fields and the only thing different, I selected the multiline text box in the Properties menu. I need to be multiline text. If this is not the case, only the first words of the default paragraph I entered couple is visible. Any suggestions or ideas would be a step ahead of where I am now. Thanks in advance.

    Yesterday, we discussed a similar situation and the solution should work for you too: http://forums.adobe.com/thread/756410?tstart=0

    What you do is create a Format script that displays the text that you want, when the field is empty, but this text is not the value of the field. The modified script below prevents printing explanatory text if the field is empty.

  • Embed fonts turn off WordWrap

    I think this new version of Flash (10) might be bugged.

    I'll put up a text field the standard way in the IDE, so the behavior of MultiLine and incorporating the standard font characters.

    If I do, the text field wraps only the LAST word in a paragraph! : o

    Also, I get something like:
    Lorem ipsum dolor sit amet, adipiscing elit our. Praesent in queer arcu
    BAP

    .. even if it is a very long paragraph. The letters at the end of the first line are cut in half, as if it were a single line the value text field and he had a mask on it.

    If I use the settings of device or Bitmap font, word wrap works very well. In fact, if I simply choose not to incorporate fonts, it works fine. I have tried tons of different fonts, so I know that's not the font file.

    I can't do it in the code overrides this behavior, for example the attached code.


    Here is a picture of what is sought as:
    Text incorporated

    And with device fonts, it envelops you well:
    Text not incorporated

    I launch this site tomorrow (Monday). Someone has an idea? I would be so happy.

    Best,
    Aaron

    Thank you very much for Craig having replied to the questionnaire. These are not the problem, but I managed to run to anti-aliasing "animation". Go figure...
    Aaron

  • Increase the width of the label of button component Radio

    Hi guys,.

    I tried to find a way to increase the width of the Radio button component label I use in my Quiz - I have some long questions which are not fully visible in the label box, and he's hiding, how to extend the width of the label, so that she can receive.

    I tried Multiline and Word Wrap in property textfield but its not getting my anywhere.

    Here is what I currently use?

    RB6. Label.Multiline = true;

    RB6. TextField.wordWrap = true;

    RB6. TextField.Width = 352;

    But nothing happens, please help

    I normally give up using the radio button label and just use a textfield that is adjacent to it, reducing to the minimum width of the component so that the area of the button.

  • How to make a morse code translator in AS 3.0

    Hi everyone, thank you for posting my message.

    I want to do a morse code translator.

    What is morse code?

    (the morse code is used by Navy pilots to communicate using the light and/or the sound)

    (each alphabet is designated by the Department of transport points and dashes. being short-lived and dashes being longer)

    It is to her.

    I want an area of dynamic text on top of the screen in flash player (swf)(input field)

    and below it I need another text to the output area. (this text box must be unwritable if possible)

    and I need a button to convert (this button text is translated)

    How it works?

    I have to input alphabets in the text above field and when I press on translate button it should show the points and the indents referred to this character.

    and vice versa.

    Oh and I need for as 3.0 (I need everything inside a movieclip so that the room, next frame previous frame options do not work in flash player)

    I am familiar with some scripts.

    so I need writing scripts for a single character that I have who will copy for each character.

    Please help me on this

    Thanks for reading this message loooooong.

    hoping for some scripts.

    This is a basic model.

    First code will work when you put it on the Flash timeline. You just need to compile the swf.

    If you feel that you are comfortable with the classes of second - class variation.

    Read the comments.

    import flash.events.Event;
    import flash.text.TextField;
    import flash.text.TextFieldAutoSize;
    import flash.text.TextFieldType;
    import flash.text.TextFormat;
    import flash.utils.Dictionary;
    
    // map of letters and integers regualar expressions to Morse code conventions
    var charMap:Dictionary;
    // five spaces per convention
    var wordSeparator:String = "       ";
    // three spaces per convention
    var letterSeparator:String = "   ";
    var input:TextField;
    var output:TextField;
    var prompt:TextField;
    
    init();
    
    function init():void
    {
              createMap();
              drawUI();
    }
    
    function drawUI():void
    {
              drawInput();
              drawOutput();
              drawPrompt();
              placeUI();
    }
    
    /**
     * Places UI elements and positions them relative to each other
     */
    function placeUI():void
    {
              addChild(prompt);
              addChild(input);
              addChild(output);
              prompt.x = input.x = output.x = prompt.y = 20;
              input.y = prompt.y + prompt.height;
              output.y = input.y + input.height + 10;
    }
    
    /**
     * Creates prompt text field
     */
    function drawPrompt():void
    {
              prompt = new TextField();
              prompt.defaultTextFormat = new TextFormat("Arial", 11, 0x004040);
              prompt.multiline = output.wordWrap = false;
              prompt.autoSize = TextFieldAutoSize.LEFT;
              prompt.text = "enter text:"
    }
    
    /**
     * Creates output text field
     */
    function drawOutput():void
    {
              output = new TextField();
              output.defaultTextFormat = new TextFormat("Arial", 12, 0x000000, "bold");
              output.multiline = output.wordWrap = false;
              output.border = true;
              output.borderColor = 0x008040;
              output.background = true;
              output.backgroundColor = 0xDFFFEF;
              output.width = 500;
              output.height = 22;
    }
    
    /**
     * Creates input text field
     */
    function drawInput():void
    {
              input = new TextField();
              input.defaultTextFormat = new TextFormat("Arial", 12);
              input.type = TextFieldType.INPUT;
              input.restrict = "A-Z 0-9";
              input.multiline = input.wordWrap = false;
              input.border = true;
              input.borderColor = 0x808080;
              input.background = true;
              input.backgroundColor = 0xF0F0F0;
              input.width = 500;
              input.height = 22;
              input.addEventListener(Event.CHANGE, onInput);
    }
    
    /**
     * Handles input text field change event
     * @param          e
     */
    function onInput(e:Event):void
    {
              var outString:String = input.text;
              // append word separator to words
              outString = outString.replace(/\b\w+\b/g, addWordSeparator);
              // append letter separator to letters
              outString = outString.replace(/\w/g, addLetterSeparator);
              // loop through the map and replace characers with corresponding Morse codes
              for (var prop:Object in charMap)
                        outString = outString.replace(RegExp(prop), charMap[prop]);
              output.text = outString;
    }
    
    /**
     * Used in String.replace() to inject word separator
     * @return
     */
    function addWordSeparator():String
    {
              return [arguments[0], wordSeparator].join("");
    }
    
    /**
     * Used in String.replace() to inject letter separator
     * @return
     */
    function addLetterSeparator():String
    {
              return [arguments[0], letterSeparator].join("");
    }
    
    /**
     * Creates mapping of alphanumerical characters to Morse code conventions
     */
    function createMap():void
    {
              // international convention
              charMap = new Dictionary();
              charMap[/A/g] = ".-";
              charMap[/B/g] = "-...";
              charMap[/C/g] = "-.-.";
              charMap[/D/g] = "-..";
              charMap[/E/g] = ".";
              charMap[/F/g] = "..-.";
              charMap[/G/g] = "--.";
              charMap[/H/g] = "....";
              charMap[/I/g] = "..";
              charMap[/J/g] = ".---";
              charMap[/K/g] = "-.-";
              charMap[/L/g] = ".-..";
              charMap[/M/g] = "--";
              charMap[/N/g] = "-.";
              charMap[/O/g] = "---";
              charMap[/P/g] = ".--.";
              charMap[/Q/g] = "--.-";
              charMap[/R/g] = ".-.";
              charMap[/S/g] = "...";
              charMap[/T/g] = "-";
              charMap[/U/g] = "..-";
              charMap[/V/g] = "...-";
              charMap[/W/g] = ".--";
              charMap[/X/g] = "-..-";
              charMap[/Y/g] = "-.--";
              charMap[/Z/g] = "--..";
              charMap[/0/g] = "-----";
              charMap[/1/g] = ".----";
              charMap[/2/g] = "..---";
              charMap[/3/g] = "...--";
              charMap[/4/g] = "....-";
              charMap[/5/g] = ".....";
              charMap[/6/g] = "-....";
              charMap[/7/g] = "--...";
              charMap[/8/g] = "---..";
              charMap[/9/g] = "----.";
    }
    

    Version of the class:

    package
    {
              import flash.display.Sprite;
              import flash.events.Event;
              import flash.text.TextField;
              import flash.text.TextFieldAutoSize;
              import flash.text.TextFieldType;
              import flash.text.TextFormat;
              import flash.utils.Dictionary;
    
              public class Morse extends Sprite
              {
                        // map of letters and integers regualr expressions to Morse code conventions
                        private var charMap:Dictionary;
                        // five spaces per convention
                        private var wordSeparator:String = "       ";
                        // three spaces per convention
                        private var letterSeparator:String = "   ";
                        private var input:TextField;
                        private var output:TextField;
                        private var prompt:TextField;
    
                        public function Morse()
                        {
                                  init();
                        }
    
                        private function init():void
                        {
                                  createMap();
                                  drawUI();
                        }
    
                        private function drawUI():void
                        {
                                  drawInput();
                                  drawOutput();
                                  drawPrompt();
                                  placeUI();
                        }
    
                        /**
                         * Places UI elements and positions them relative to each other
                         */
                        private function placeUI():void
                        {
                                  addChild(prompt);
                                  addChild(input);
                                  addChild(output);
                                  prompt.x = input.x = output.x = prompt.y = 20;
                                  input.y = prompt.y + prompt.height;
                                  output.y = input.y + input.height + 10;
                        }
    
                        /**
                         * Creates prompt text field
                         */
                        private function drawPrompt():void
                        {
                                  prompt = new TextField();
                                  prompt.defaultTextFormat = new TextFormat("Arial", 11, 0x004040);
                                  prompt.multiline = output.wordWrap = false;
                                  prompt.autoSize = TextFieldAutoSize.LEFT;
                                  prompt.text = "enter text:"
                        }
    
                        /**
                         * Creates output text field
                         */
                        private function drawOutput():void
                        {
                                  output = new TextField();
                                  output.defaultTextFormat = new TextFormat("Arial", 12, 0x000000, "bold");
                                  output.multiline = output.wordWrap = false;
                                  output.border = true;
                                  output.borderColor = 0x008040;
                                  output.background = true;
                                  output.backgroundColor = 0xDFFFEF;
                                  output.width = 500;
                                  output.height = 22;
                        }
    
                        /**
                         * Creates input text field
                         */
                        private function drawInput():void
                        {
                                  input = new TextField();
                                  input.defaultTextFormat = new TextFormat("Arial", 12);
                                  input.type = TextFieldType.INPUT;
                                  input.restrict = "A-Z 0-9";
                                  input.multiline = input.wordWrap = false;
                                  input.border = true;
                                  input.borderColor = 0x808080;
                                  input.background = true;
                                  input.backgroundColor = 0xF0F0F0;
                                  input.width = 500;
                                  input.height = 22;
                                  input.addEventListener(Event.CHANGE, onInput);
                        }
    
                        /**
                         * Handles input text field change event
                         * @param          e
                         */
                        private function onInput(e:Event):void
                        {
                                  var outString:String = input.text;
                                  // append word separator to words
                                  outString = outString.replace(/\b\w+\b/g, addWordSeparator);
                                  // append letter separator to letters
                                  outString = outString.replace(/\w/g, addLetterSeparator);
                                  // loop through the map and replace characers with corresponding Morse codes
                                  for (var prop:Object in charMap)
                                            outString = outString.replace(RegExp(prop), charMap[prop]);
                                  output.text = outString;
                        }
    
                        /**
                         * Used in String.replace() to inject word separator
                         * @return
                         */
                        private function addWordSeparator():String
                        {
                                  return [arguments[0], wordSeparator].join("");
                        }
    
                        /**
                         * Used in String.replace() to inject letter separator
                         * @return
                         */
                        private function addLetterSeparator():String
                        {
                                  return [arguments[0], letterSeparator].join("");
                        }
    
                        /**
                         * Creates mapping of alphanumerical characters to Morse code conventions
                         */
                        private function createMap():void
                        {
                                  // international convention
                                  charMap = new Dictionary();
                                  charMap[/A/g] = ".-";
                                  charMap[/B/g] = "-...";
                                  charMap[/C/g] = "-.-.";
                                  charMap[/D/g] = "-..";
                                  charMap[/E/g] = ".";
                                  charMap[/F/g] = "..-.";
                                  charMap[/G/g] = "--.";
                                  charMap[/H/g] = "....";
                                  charMap[/I/g] = "..";
                                  charMap[/J/g] = ".---";
                                  charMap[/K/g] = "-.-";
                                  charMap[/L/g] = ".-..";
                                  charMap[/M/g] = "--";
                                  charMap[/N/g] = "-.";
                                  charMap[/O/g] = "---";
                                  charMap[/P/g] = ".--.";
                                  charMap[/Q/g] = "--.-";
                                  charMap[/R/g] = ".-.";
                                  charMap[/S/g] = "...";
                                  charMap[/T/g] = "-";
                                  charMap[/U/g] = "..-";
                                  charMap[/V/g] = "...-";
                                  charMap[/W/g] = ".--";
                                  charMap[/X/g] = "-..-";
                                  charMap[/Y/g] = "-.--";
                                  charMap[/Z/g] = "--..";
                                  charMap[/0/g] = "-----";
                                  charMap[/1/g] = ".----";
                                  charMap[/2/g] = "..---";
                                  charMap[/3/g] = "...--";
                                  charMap[/4/g] = "....-";
                                  charMap[/5/g] = ".....";
                                  charMap[/6/g] = "-....";
                                  charMap[/7/g] = "--...";
                                  charMap[/8/g] = "---..";
                                  charMap[/9/g] = "----.";
                        }
    
              }
    
    }
    
  • Timer for youtube player?

    Hi, I was wondering if it was possible to display the elapsed time and total time of a video in flash on youtube? I have a reader built chromeless currently on the scene, and it's the only thing missing, thanks!

    Here is a plan of work for her:

    import flash.display.Sprite;
    import flash.events.MouseEvent;
    import flash.events.TimerEvent;
    import flash.geom.Rectangle;
    import flash.system.Security;
    import flash.text.TextField;
    import flash.text.TextFieldAutoSize;
    import flash.text.TextFormat;
    import flash.utils.Timer;
    
    var loader:Loader;
    var seekBarWidth:Number = 500;
    var timeRE:RegExp = /\d+\d+:\d+\d+\s/;
    var seekBar:Sprite;
    var seekHead:Sprite;
    var progressTimer:Timer;
    var countdown:TextField;
    // This will hold the API player instance once it is initialized.
    var player:Object;
    
    init();
    
    function init():void
    {
              Security.allowInsecureDomain("*");
              Security.allowDomain("*");
              initButtons();
              drawSeekBar();
              drawCountdown();
              initTimer();
              loadVideo();
    }
    
    function loadVideo():void
    {
              loader = new Loader();
              loader.contentLoaderInfo.addEventListener(Event.INIT, onLoaderInit);
              loader.load(new URLRequest("http://www.youtube.com/apiplayer?version=3"));
    }
    
    function drawCountdown():void
    {
              countdown = new TextField();
              countdown.defaultTextFormat = new TextFormat("Arial", 10);
              countdown.autoSize = TextFieldAutoSize.LEFT;
              countdown.multiline = countdown.wordWrap = false;
              countdown.text = "00:00 / 00:00";
    }
    
    function initButtons():void
    {
              unMuteBtn.addEventListener(MouseEvent.CLICK, unMuteVideo);
              muteBtn.addEventListener(MouseEvent.CLICK, muteVideo);
              pauseBtn.addEventListener(MouseEvent.CLICK, pauseVideo);
              playBtn.addEventListener(MouseEvent.CLICK, playVideo);
    }
    
    function drawSeekBar():void
    {
              seekBar = new Sprite();
              seekBar.graphics.lineStyle(2);
              seekBar.graphics.moveTo(0, 0);
              seekBar.graphics.lineTo(seekBarWidth, 0);
              drawSeekHead();
    }
    
    function drawSeekHead():void
    {
              seekHead = new Sprite();
              seekHead.graphics.beginFill(0xff0000);
              seekHead.graphics.drawCircle(0, 0, 7);
              seekBar.addChild(seekHead);
              seekHead.mouseEnabled = true;
              seekHead.buttonMode = true;
              seekHead.useHandCursor = true;
              seekHead.addEventListener(MouseEvent.MOUSE_DOWN, startSeek);
    }
    
    function startSeek(e:MouseEvent):void
    {
              stage.addEventListener(MouseEvent.MOUSE_UP, stopSeek);
              stage.addEventListener(MouseEvent.MOUSE_MOVE, onMouseMove);
              seekHead.startDrag(true, new Rectangle(0, 0, seekBarWidth, 0));
              progressTimer.stop();
    }
    
    function onMouseMove(e:MouseEvent):void
    {
              player.seekTo(player.getDuration() * seekHead.x / seekBarWidth);
              e.updateAfterEvent();
    }
    
    function stopSeek(e:MouseEvent):void
    {
              stage.removeEventListener(MouseEvent.MOUSE_UP, stopSeek);
              stage.removeEventListener(MouseEvent.MOUSE_MOVE, onMouseMove);
              seekHead.stopDrag();
              progressTimer.start();
    }
    
    function initTimer():void
    {
              progressTimer = new Timer(50);
              progressTimer.addEventListener(TimerEvent.TIMER, updateSeekBar);
    }
    
    function updateSeekBar(e:TimerEvent):void
    {
              countdown.text = new Date(player.getCurrentTime() * 1000).toUTCString().match(timeRE)[0] + "/ " + new Date(player.getDuration() * 1000).toUTCString().match(timeRE)[0];
              seekHead.x = seekBarWidth * player.getCurrentTime() / player.getDuration();
              e.updateAfterEvent();
    }
    
    function onLoaderInit(e:Event):void
    {
              addChild(loader);
              loader.content.addEventListener("onReady", onPlayerReady);
              loader.content.addEventListener("onError", onPlayerError);
              loader.content.addEventListener("onStateChange", onPlayerStateChange);
              loader.content.addEventListener("onPlaybackQualityChange", onVideoPlaybackQualityChange);
    }
    
    function onPlayerReady(e:Event):void
    {
              // Event.data contains the event parameter, which is the Player API ID
              // Once this event has been dispatched by the player, we can use
              // cueVideoById, loadVideoById, cueVideoByUrl and loadVideoByUrl
              // to load a particular YouTube video.
              player = loader.content;
              player.cueVideoById("FDbP71p4W4g");
              player.setSize(640, 360);
              player.x = 20;
              player.y = 30;
    
              seekBar.x = player.x;
              seekBar.y = player.y + player.height + 10;
    
              countdown.x = seekBar.x + seekBar.width + 10;
              countdown.y = seekBar.y - seekBar.height * .5;
    
              addChild(seekBar);
              addChild(countdown);
    }
    
    function onPlayerError(e:Event):void
    {
              // Event.data contains the event parameter, which is the error code
              trace("player error:", Object(e).data);
    }
    
    function onPlayerStateChange(e:Event):void
    {
              // Event.data contains the event parameter, which is the new player state
              switch (Object(e).data)
              {
                        case 1:
                                  progressTimer.start();
                                  break;
    
                        case 2:
                        case 0:
                                  progressTimer.stop();
                                  break;
              }
    }
    
    function onVideoPlaybackQualityChange(e:Event):void
    {
              // Event.data contains the event parameter, which is the new video quality
              trace("video quality:", Object(e).data);
    }
    
    function createFeaturedButtons(player:Object, featuredVideos:Array):Array
    {
              var results:Array = [];
              for each (var id:String in featuredVideos)
                        results.push(player.getClickToPlayButton(id));
              return results;
    }
    
    function playVideo(e:MouseEvent):void
    {
              if (player)
                        player.playVideo();
    }
    
    function pauseVideo(e:MouseEvent):void
    {
              if (player)
                        player.pauseVideo();
    }
    
    function muteVideo(e:MouseEvent):void
    {
              if (player)
                        player.mute();
    }
    
    function unMuteVideo(e:MouseEvent):void
    {
              if (player)
                        player.unMute();
    }
    
  • Make a timer

    I have a timer digital timer in the background of a Web site, that I am.  It is strictly an aesthetic thing and really does not serve any real purpose otherwise.  Just that it looks like a timer job.  Is there a way I can do that with actionscript so that I don't have to actually the numbers change keyframe?  I'm actually more than one animation guy and it would usually just animate calendar down, but it's probably more work that it is worth.

    Thank you

    The example below shows the countdown of 2 minutes to zero.

    import flash.display.Sprite;
    import flash.events.TimerEvent;
    import flash.text.TextField;
    import flash.text.TextFormat;
    import flash.utils.Timer;
    
    var countDownDisplay:TextField;
    var timer:Timer;
    var date:Date;
    
    init();
    
    function init():void
    {
              countDownDisplay = new TextField();
              countDownDisplay.defaultTextFormat = new TextFormat("Arial", 120, 0x008040);
              countDownDisplay.multiline = countDownDisplay.wordWrap = false;
              countDownDisplay.border = true;
              countDownDisplay.autoSize = "left";
              countDownDisplay.x = countDownDisplay.y = 20;
              countDownDisplay.text = "00:00 ";
              addChild(countDownDisplay);
              date = new Date(1000 * 120);
              timer = new Timer(500);
              timer.addEventListener(TimerEvent.TIMER, onTimer);
              timer.start();
    }
    
    function onTimer(e:TimerEvent):void
    {
              date.time -= timer.delay;
              countDownDisplay.text = date.toUTCString().match(/\d\d:\d\d\s/)[0];
              if (date.time <= 0)
              {
                        timer.stop();
              }
    }
    

Maybe you are looking for