You need to put [Bindable] on top of var mystr.

 

[Bindable]

public var mystr:String = ….

 

However you’re also trying to do things directly in the Script block which isn’t allowed.  You’ll need to create a function and have the application call that.

 

<mx:Application … creationComplete=”setMyStr()”>

 

<mx:Script>

  [Bindable]

  public var mystr:String;

 

  private function setMyStr():Void

  {

    var obj:Rtl = new Rtl();

    myStr = …

  }

</mx:Script>

</mx:Application>

 

HTH,

Matt

 


From: flexcoders@yahoogroups.com [mailto:flexcoders@yahoogroups.com] On Behalf Of breakneck79
Sent: Friday, December 02, 2005 10:13 AM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Using ActionScript Class in Flex Code

 

Dear flexcoders,
I use "Rtl" class that writen in Rtl.as in my MXMl page and using
flexbuilder 2 for development,
In MXML file i can not access to method "convert" from this file,
Please guide me, what is the problem?
Warning : "Unable to detect changes to "mystr"."

Tnx,

********************************************
source code of MXML file :

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.macromedia.com/2005/mxml"
xmlns="*">
     
      <mx:Canvas width="100%" height="100%">
            <mx:Script>
                  <![CDATA[
                        import bin.com.persian.Rtl.*;
                       
                        var obj:Rtl = new Rtl();
                        var mystr:String = obj.convert("&#1580;&#1605;&#1604;&#1607; &#1575;&#1608;&#1604;");
                  ]]>
            </mx:Script>
            <mx:TextInput width="150" id="t1" text="{mystr}"  />
      </mx:Canvas>
</mx:Application>
****************************************************

and source of Rtl.as file:


// ActionScript Document
package bin.com.persian.Rtl {
import bin.com.persian.TextFormat.*;

public class Rtl {
      public function Rtl(){}
            private var strFasalakh:String = "&#1601;&#1587;&#1604;&#1582;";
           
            public function convert(strLine:String):String
            {
                  var stringYe:Ye = new Ye();
                  var strLine:String = strFasalakh + stringYe.
convert(strLine) + strFasalakh;
     
                  var arrPoints:Array = new Array();
                  var intArrayPointCount:Number=0;
                  var bolSetPointer:Boolean = true;
     
                  for (var i:Number=0; i<strLine.length; i++)
                  {
                        if (!persianChar(strLine.slice(i, (i+1))))
                        {
                              if (bolSetPointer)
                              {
                                    arrPoints[intArrayPointCount] =
[i, 0];
                                    bolSetPointer = false;
                              }                       
                             
                        }else if (persianChar(strLine.slice((i-1), i)
))           
                        {
                              if (!bolSetPointer)
                              {
                                    arrPoints[intArrayPointCount][1] =
(i-2);
                                    intArrayPointCount++;
                                    bolSetPointer = true;
                              }
                        }
                  }
                 
                  return finalPlus(spliter(strLine, arrPoints));
            }
           
           
            public function spliter(strLine:String, arrPoints:Array):
Array
            {
                  var arrFinal:Array = new Array();
                  var arrPointsSeri:Array = new Array();
                  var intCountArraySeri:Number=0;

                  for (var g:Number=0; g<arrPoints.length; g++)
                  {
                        for (var h:Number=0; h<2; h++)
                        {
                              if ((h&1) == 1)
                              {
                                    arrPointsSeri[intCountArraySeri] =
int((arrPoints[g][h]) + 1);
                              }else
                              {
                                    arrPointsSeri[intCountArraySeri] =
int(arrPoints[g][h]);
                              }
                        intCountArraySeri++;
                        }
                  }
                 
                  arrFinal[0] = strLine.slice(0 , arrPointsSeri[0]);
                  for (var r:Number=0; r<arrPointsSeri.length-1; r++)
                  {
                        arrFinal[int(r+1)] = strLine.
slice(arrPointsSeri[r] , arrPointsSeri[int(r+1)]);
                  }
                 
                  var bolShowFarsiText:Boolean = false;
                  for (var q:Number=0; q<strLine.length; q++)
                  {
                        if (!persianChar(strLine.slice(q, (q+1))))
                              bolShowFarsiText = true;
                  }
                  if (bolShowFarsiText)
                  arrFinal[arrFinal.length] = strLine.
slice(arrPointsSeri[arrPointsSeri.length-1], strLine.length);     
     
                 
                  arrFinal.reverse();
                  return arrFinal;
            }
           
            public function finalPlus(arrPackage:Array):String
            {
                  var strHolder:String = "";
                  for (var i:Number=0; i<arrPackage.length; i++)
                  {
                        strHolder += arrPackage[i];     
                  }
                 
                  return remover(strHolder);
            }
           
            public function remover(strFinal:String):String
            {
                  var arrFas:Array = strFinal.split(strFasalakh);
                  var strHolder:String = "";
                  for (var i:Number=0; i<arrFas.length; i++)
                  {
                        strHolder += arrFas[i];     
                  }
                  return strHolder;
            }
           
            // All Persian Characters
            public function persianChar(strChar:String):Boolean
            {
                  var bolReturn:Boolean = false;
                  if (strChar == "&#1575;" || strChar == "&#1570;" || strChar ==
"&#1576;" ||
                  strChar == "&#1662;" || strChar == "&#1578;" || strChar == "&#1579;" |
|
                  strChar == "&#1580;" || strChar == "&#1670;" || strChar == "&#1581;" |
|
                  strChar == "&#1582;" || strChar == "&#1583;" || strChar == "&#1584;" |
|
                  strChar == "&#1585;" || strChar == "&#1586;" || strChar == "&#1688;" |
|
                  strChar == "&#1587;" || strChar == "&#1588;" || strChar == "&#1589;" |
|
                  strChar == "&#1590;" || strChar == "&#1591;" || strChar == "&#1592;" |
|
                  strChar == "&#1593;" || strChar == "&#1594;" || strChar == "&#1601;" |
|
                  strChar == "&#1602;" || strChar == "&#1603;" || strChar == "&#1711;" |
|
                  strChar == "&#1604;" || strChar == "&#1605;" || strChar == "&#1606;" |
|
                  strChar == "&#1608;" || strChar == "&#1607;" || strChar == "&#1610;" |
|
                  strChar == "&#1609;" || strChar == "&#1600;" || strChar == "&#1573;" |
|
                  strChar == "&#1571;" || strChar == "&#1574;" || strChar == "&#1569;" |
|
                  strChar == "&#1728;" ||  strChar == " " ||  strChar == "&#1567;"
||
                  strChar == "&#1705;" || strChar == "&#1740;")
                  {
                        bolReturn = true;
                  }
                  // If Find English Char, Return False.
                  return bolReturn;
            }
      }

}

****************************************************











--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com




YAHOO! GROUPS LINKS




Reply via email to