The problem is simple:
I need to pass actual variable to a function.
private var test:String = "KKK";
trace (" Before --->>> " + test);
testFunction(test);
trace (" Next --->>> " + test);
private function testFunction(d:String):void{
d = "MMM";
}
Result:
Before --->>> KKK
Next --->>> KKK
The result is correct but, What I want is, send the actual test variable to my function and change that. So I want to have output like this:
Before --->>> KKK
Next --->>> MMM
Any solution?
Thanks for your answer but if I have a code like this, I need to pass the actual variable to my function:
if ( lastPos == -1 ){// if this is first item
flagLEFT = "mid";
tempImageLEFT = new Bitmap(Bitmap(dataBANK[0]["lineimage" + 10]).bitmapData);
}else if (nextPos == -1){// if this is the last position
flagRIGHT = "mid";
tempImageRGHT = new Bitmap(Bitmap(dataBANK[0]["lineimage" + 13]).bitmapData);
}
As you see, changes are in flagLEFT and tempImageRGHT . Also I have a change on numbers (10 and 13) which can be handle in normal way. I need something like this:
private function itemFirstLast(flag:String, bmp:Bitmap, pos:int):void{
flag = "mid";
bmp = new Bitmap(Bitmap(dataBANK[0]["lineimage" + pos]).bitmapData);
}
Any solution?
One way is to return the new string and assign it to test :
This still doesn’t pass the actual string object but the test string will change. Strings are passed by value in AS3, if you wan’t to actually pass it in you can wrap it in an object :