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("جمله
اول");
]]>
</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 = "فسلخ";
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 ==
"ا" || strChar == "آ" || strChar ==
"ب" ||
strChar ==
"پ" || strChar == "ت" || strChar ==
"ث" |
|
strChar ==
"ج" || strChar == "چ" || strChar ==
"ح" |
|
strChar ==
"خ" || strChar == "د" || strChar ==
"ذ" |
|
strChar ==
"ر" || strChar == "ز" || strChar ==
"ژ" |
|
strChar ==
"س" || strChar == "ش" || strChar ==
"ص" |
|
strChar ==
"ض" || strChar == "ط" || strChar ==
"ظ" |
|
strChar == "ع" || strChar ==
"غ" || strChar == "ف" |
|
strChar ==
"ق" || strChar == "ك" || strChar ==
"گ" |
|
strChar ==
"ل" || strChar == "م" || strChar ==
"ن" |
|
strChar ==
"و" || strChar == "ه" || strChar ==
"ي" |
|
strChar ==
"ى" || strChar == "ـ" || strChar ==
"إ" |
|
strChar ==
"أ" || strChar == "ئ" || strChar ==
"ء" |
|
strChar ==
"ۀ" || strChar == " " || strChar ==
"؟"
||
strChar ==
"ک" || strChar == "ی")
{
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