0 Replies Latest reply on Sep 16, 2010 6:38 PM by Phuong Thanh

    embed actionscript file in flex application

    Phuong Thanh Level 1

      hello everybody,now i need a help from everybody. it's very importain with me

      i have a action script SRC/fonttype/font.as

      /**
      Suggested workflow:
      - create a fontLibrary subfolder in your project (NOT in /bin or /src)
      - for example: /lib/fontLibrary
      - copy font files in this location
      - create a FontLibrary class in the same location
      - one font library can contain several font classes (duplicate embed and registration code)

      FlashDevelop QuickBuild options: (just press Ctrl+F8 to compile this library)
      @mxmlc -o bin/VietnameseFont.swf -noplay
      */
      package {
          import flash.display.Sprite;
          import flash.text.Font;
          import flash.text.TextField;
          import flash.text.TextFormat;
         
          /**
           * Vietnamese Font library example
           * @author Thanh Tran
           */
          [SWF(backgroundColor='#FFFFFF', frameRate='31', width='600', height='400')]
          public class VietnameseFont extends Sprite {
              /*
              Common unicode ranges:
              Uppercase   : U+0020,U+0041-U+005A
              Lowercase   : U+0020,U+0061-U+007A
              Numerals    : U+0030-U+0039,U+002E
              Punctuation : U+0020-U+002F,U+003A-U+0040,U+005B-U+0060,U+007B-U+007E
              Basic Latin : U+0020-U+002F,U+0030-U+0039,U+003A-U+0040,U+0041-U+005A,U+005B-U+0060,U+0061-U+007A,U+007 B-U+007E
              Latin I     : U+0020,U+00A1-U+00FF,U+2000-U+206F,U+20A0-U+20CF,U+2100-U+2183
              Latin Ext. A: U+0100-U+01FF,U+2000-U+206F,U+20A0-U+20CF,U+2100-U+2183
              Latin Ext. B: U+0180-U+024F,U+2000-U+206F,U+20A0-U+20CF,U+2100-U+2183
              Latin Ext. Add'l: U+1E00-U+1EFF,U+2000-U+206F,U+20A0-U+20CF,U+2100-U+2183
              Greek       : U+0374-U+03F2,U+1F00-U+1FFE,U+2000-U+206f,U+20A0-U+20CF,U+2100-U+2183
              Cyrillic    : U+0400-U+04CE,U+2000-U+206F,U+20A0-U+20CF,U+2100-U+2183
              Armenian    : U+0530-U+058F,U+FB13-U+FB17
              Arabic      : U+0600-U+06FF,U+FB50-U+FDFF,U+FE70-U+FEFF
              Hebrew      : U+05B0-U+05FF,U+FB1D-U+FB4F,U+2000-U+206f,U+20A0-U+20CF,U+2100-U+2183
              --------------------------------------
              VN Unicode    : U+00C0-U+00C3,U+00C8-U+00CA,U+00CC-U+00CD,U+00D0,U+00D2-U+00D5,U+00D9-U+00DA,U+00DD,U+00E 0-U+00E3,U+00E8-U+00EA,U+00EC-U+00ED,U+00F2-U+00F5,U+00F9-U+00FA,U+00FD,U+0102-U+0103,U+01 10-U+0111,U+0128-U+0129,U+0168-U+0169,U+01A0-U+01B0,U+1EA0-U+1EF9
              ÀÁÂà          ÈÉÊ           ÌÍ         Đ       ÒÓÔÕ            ÙÚ         Ý        à áâã           èéê            ìà          òóôõ          ùú         ý         Ăă            Đđ            Ĩĩ           Ũũ            Æ Æ¡Æ¯Æ°        the rest
              VN Composite: U+02C6-U+0323
             
              Vietnamese Unicode = Basic Latin + VN Unicode
              Vietnamese Composite = Vietnamese Unicode + VN Composite
              --------------------------------------
              */
              [Embed(systemFont='Arial'
                  ,fontFamily  = 'ArialRegularVN'
                  ,fontName  ='ArialRegularVN'
                  ,fontStyle   ='normal' // normal|italic
                  ,fontWeight  ='normal' // normal|bold
                  ,unicodeRange = 'U+0020-U+002F,U+0030-U+0039,U+003A-U+0040,U+0041-U+005A,U+005B-U+0060,U+0061-U+007A,U+00 7B-U+007E,U+00C0-U+00C3,U+00C8-U+00CA,U+00CC-U+00CD,U+00D0,U+00D2-U+00D5,U+00D9-U+00DA,U+0 0DD,U+00E0-U+00E3,U+00E8-U+00EA,U+00EC-U+00ED,U+00F2-U+00F5,U+00F9-U+00FA,U+00FD,U+0102-U+ 0103,U+0110-U+0111,U+0128-U+0129,U+0168-U+0169,U+01A0-U+01B0,U+1EA0-U+1EF9',
                  mimeType='application/x-font'
                  //,embedAsCFF='false'
              )]
              public static const fontClass:Class;
             
              public function VietnameseFont() {
                  Font.registerFont(fontClass);
                 
                  var tf: TextField = new TextField();
                  tf.embedFonts = true;
                  var format: TextFormat = new TextFormat("ArialRegularVN", 20, 0);
                  tf.width = 600;
                  tf.height = 400;
                  //tf.autoSize = "left";
                  tf.multiline = true;
                  tf.wordWrap = true;
                  tf.text = "[Number & Punctuation] 1234567890 .,?!:;/\\\"(){}[]<>'+-*/=&%";
                  var upStr: String = "[Upper case] ABCDEFGHIJKLMNOPQRSTUVWXYZ Ä&#144; Ã&#129;ÀẢÃẠ ĂẮẰẲẴẶ ÂẤẦẨẪẬ ÉÈẺẼẸ ÊẾỀỂỄỆ Ã&#141;ÌỈĨỊ ÓÒỎÕỌ Ôá»&#144;ỒỔỖỘ Æ á»šá»œá»žá» á»¢ ÚÙỦŨỤ ƯỨỪỬỮỰ Ã&#157;ỲỶỸỴ"
                  var lowStr: String = "[Lower case] abcdefghijklmnopqrstuvwxyz Ä‘ áà ảãạ ăắằẳẵặ âấầầẫẠéèẻẽẹ êếá»&#129;ểễệ Ãìỉĩị óòá»&#143;õá»&#141; ôốồổỗộ Æ¡á»›á»&#157;ởỡợ úùủũụ ưứừá»á»¯á»± ýỳỷỹỵ";
                  var upCompositeStr: String = "[Upper Composite] AÌ&#129;AÌ€ẢÃAÌ£ Ä‚Ì&#129;ẰẲẴẶ ÂÌ&#129;ẦẨẪẬ EÌ&#129;EÌ€ẺẼEÌ£ ÊÌ&#129;ỀỂỄỆ IÌ&#129;IÌ€ỈĨIÌ£ OÌ&#129;OÌ€ỎÕOÌ£ ÔÌ&#129;ỒỔỖỘ Æ Æ Ì&#129;Æ Ì€Æ Ì‰Æ ÌƒÆ Ì£ UÌ&#129;UÌ€ỦŨUÌ£ ƯÌ&#129;ỪỬỮỰ YÌ&#129;YÌ€ỶỸYÌ£";
                  var lowCompositeStr: String = "[Lower Composite] aÌ&#129;aÌ€ảãaÌ£ ăÌ&#129;ằẳẵặ âÌ&#129;ầẩẫậ eÌ&#129;eÌ€ẻẽeÌ£ êÌ&#129;ềểễệ iÌ&#129;iÌ€ỉĩiÌ£ oÌ&#129;oÌ€ỏõoÌ£ ôÌ&#129;ồổỗộ Æ¡Æ¡Ì&#129;ờởỡợ uÌ&#129;uÌ€ủũuÌ£ Æ°Ì&#129;ừửữự yÌ&#129;yÌ€ỷỹyÌ£";
                  tf.appendText("\n\n" + upStr);
                  tf.appendText("\n\n" + lowStr);
                  tf.appendText("\n\n" + upCompositeStr);
                  tf.appendText("\n\n" + lowCompositeStr);
                  tf.setTextFormat(format);
                  tf.type = "input";
                  addChild(tf);
                 
              }
             
             
          }
         
      }// ActionScript file

      and My flex application:

      <?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"
                     xmlns:font="fonttype.font"
                     minWidth="955" minHeight="600"
                    
                     creationComplete="khoiTao()">
          <fx:Script>
              <![CDATA[
                  import mx.controls.Alert;
                 
                  private function khoiTao():void{
                      tintucRequest.send();               
                  }
                 
                  private function linkClick(event:Event):void{
                      imgBig.source = event.currentTarget.getRepeaterItem().HINH;
                      txtBig.text = event.currentTarget.getRepeaterItem().ND;
                     
                  }
                 
                 
                 
              ]]>
          </fx:Script>
          <fx:Declarations>
              <mx:HTTPService id="tintucRequest" url="http://localhost/webtintuc/tintuc.php" showBusyCursor="true" fault="'Cannot connect Server'"/>
              <!-- Place non-visual elements (e.g., services, value objects) here -->
          </fx:Declarations>
          <mx:VBox x="589.5" y="91">
              <mx:Repeater id="r" dataProvider="{tintucRequest.lastResult.tintuc.item}">   
                  <mx:HBox>
                      <mx:Image width="50" height="50" source="{r.currentItem.HINH}"/>
                      <mx:Label text="{r.currentItem.ND}" useHandCursor="true" buttonMode="true" mouseChildren="false" click="linkClick(event)"/>   
                  </mx:HBox>                   
              </mx:Repeater>
          </mx:VBox>
          <mx:Image x="32" y="37" width="349" height="151" id="imgBig" source="assets/hinh1.jpg"/>
          <mx:Text x="51" y="192" text="Day la noi dung trang mac dinh" fontSize="12" textAlign="center" width="470" id="txtBig"/>
          <mx:Text x="483" y="37" fontSize="12" textAlign="center" width="470" id="txtBig0" text="Cac trang co noi dung tuong tu"/>
         
              <s:Label text="Label" height="32" width="266"/>
              <mx:VBox x="70" y="245" width="200" height="159">
                  <mx:Repeater id="r1" dataProvider="{tintucRequest.lastResult.tieudechinh.item}">   
                      <mx:HBox>
                         
                          <mx:Label text="{r1.currentItem.ND}" useHandCursor="true" buttonMode="true" mouseChildren="false" />   
                      </mx:HBox>                   
                  </mx:Repeater>
              </mx:VBox>
         
      </s:Application>

      How do i work to embed file font.as into this application

      This is example embed font type for my country,

      Can u help me? thanks