Environment Hook Up’s

If you would like to dynamically configure the RemoteObject’s endpoint to point to Development server, Production server, Training server or your Local Server, and also if you would like to append a Secure AMF or a non secure AMF messagebroker servlet, please see below

package org.util
{ 
import mx.core.FlexGlobals;

public class EnvironmentUtil
{
public static const DEV_SERVER_URL:String             = 'https://abcd-dev.xyz.ab.org/contextroot/';
public static const LOCAL_SERVER_URL:String           = 'https://localhost:9443/contextroot/';
public static const SYSTEMS_TEST_SERVER_URL:String    = 'https://abcd-sys.xyz.ab.org/contextroot/';
public static const TRAINING_SERVER_URL:String        = 'https://abcd-trn.xyz.ab.org/contextroot/';
public static const TRANSIENT_SERVER_URL:String       = 'https://{server.name}:{server.port}/workerportal/';

public static function get defaultServer():String
{
   return EnvironmentUtil.DEV_SERVER_URL;
}

public static function get isNotProduction():Boolean
{
  return (isDevEnvironment() || isLocalEnvironment());
}

public static function get remoteEndPoint():String
{
   var remoteURL:String = EnvironmentUtil.isLocalEnvironment() ? defaultServer : EnvironmentUtil.TRANSIENT_SERVER_URL;
   if(EnvironmentUtil.isLocalEnvironment()){
     remoteURL += "messagebroker/amf";
   } else {
      remoteURL += "messagebroker/amfsecure";
 }
  return remoteURL;
}

public static function isDevEnvironment():Boolean
{
   return FlexGlobals.topLevelApplication.root.loaderInfo.url.indexOf('213.345.250') != -1;
}

public static function isLocalEnvironment():Boolean
{
   return FlexGlobals.topLevelApplication.root.loaderInfo.url.indexOf('file:///') != -1;
}

public static function isLocalhost():Boolean
{
     return FlexGlobals.topLevelApplication.root.loaderInfo.url.indexOf('localhost') != -1;
}}}
USAGE:
<s:RemoteObject
 id="pingServiceRO"
 destination="pingServiceRO"
 endpoint="{ EnvironmentUtil.remoteEndPoint }"
 />

 <parsley:Object
 id="pingService"
 type="org.chouhans.flexy.PingService">

 <parsley:Property
 name="pingRO"
 idRef="pingServiceRO"
 />

 </parsley:Object>
Advertisements

Reading Hebrew and Arabic in Flex

Some History on Bi-Directional texts, Semitic languages and the languages which are read from right to left:

Arabic, Hebrew, and the non-Semitic languages using the Arabic or the Hebrew alphabet, such as Persian and Yiddish, are written from right to left (except for their numbers!). Urdu which is also derived from Arabic and Persian language and ancient indo – aryan language binti is written from right to left. Ancient Egyptian, Etruscan, Greek and the oldest Latin could be written in both directions. Also Chinese and Japanese can be written right to left (also written from top to bottom, vertically). Korean is NOT written from right to left.

More on these @

http://en.wikipedia.org/wiki/Semitic_languages

http://en.wikipedia.org/wiki/Horizontal_and_vertical_writing_in_East_Asian_scripts

http://en.wikipedia.org/wiki/Bi-directional_text

Here is a sample test to read a text from right to left and vice versa.

<?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">
   <s:layout>
       <s:VerticalLayout />
   </s:layout>
    <fx:Style>
      @namespace s "library://ns.adobe.com/flex/spark";
      @namespace mx "library://ns.adobe.com/flex/mx";      
     @font-face {
       src: url("font/DroidSans.ttf");
       fontFamily: DroidSans;
      }
     s|Label {
        fontFamily: DroidSans;
        fontSize: 24;
      }
    </fx:Style>

    <fx:Script>
      <![CDATA[
          import flashx.textLayout.formats.Direction;
         [Bindable]
         private var textDirection:String = "rtl";         
         protected function onClick( event:MouseEvent ):void {
            if (myLabel.getStyle("direction")=="ltr") {
               myLabel.setStyle("direction", Direction.RTL);
             } else {
               myLabel.setStyle("direction", Direction.LTR);
                }
          }
         ]]>
       </fx:Script>
       <s:VGroup  
         width="100%"
         height="100%"
         paddingTop="20"
        >
       <s:Label
         id="myLabel"
         width="100%"
         text="שלום ‎בעולם‎"
         backgroundColor="#ffff00"
         layoutDirection="{ textDirection }"
       />
       <s:Button
         label="toggle RTL-LTR"
         click="onClick(event)"
        />
       <s:Label
          text="{ myLabel.getStyle('direction') }"
          />
       </s:VGroup>
</s:Application>

In order to run the above source code, you will need the fonts shown below:

You may get this here http://www.fontsquirrel.com/

Hope you enjoyed reading the post !!!