2 Replies Latest reply on Sep 4, 2010 7:06 AM by Subeesh Arakkan

    Generate a random String

    djh88ukwb Level 1

      Hello all.

       

      I have a small function (below)  that generates a random string into a text field.

      <?xml version="1.0" encoding="utf-8"?>
      <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
                     xmlns:s="library://ns.adobe.com/flex/spark"
                     xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600">
          <fx:Declarations>
              <!-- Place non-visual elements (e.g., services, value objects) here -->
          </fx:Declarations>
         
          <fx:Script>
              <![CDATA[
                  import mx.utils.UIDUtil;
                 
                  private function createString():void
                  {
                      txt_String.text = UIDUtil.createUID();
                  }
              ]]>
          </fx:Script>
          <s:TextInput x="10" y="10" id="txt_String" width="450"/>
          <s:Button x="10" y="40" label="Generate" click="createString()"/>
      </s:Application>

       

      The only snag is, the string is a massive number, but all i want is a six letter string.  Can anyone help me either cut this string down, or with a new function that creates just a six letter string.