target of assignment must be a reference value
This week's featured product
Store Locator
This cool AJAX application will enhance your website by showing your stores' locations. You can also display an image and a short description so your users know exactly where to find your business.
Become a premium member
Flabell and Themesbell membership provides users with the ability to download any of our components for Adobe Flash and website themes for free, during an entire year.
read more


Subcribe to topic RSS

Products RSS Feed
Follow us on twitter
support@themesbell.com
Ammy
on 23/6/11
Here's my code:
public static function countInstances(param1:String, param2:String) : int
{
var _loc_3:int = -1;
var _loc_4:int = -1;
do
{
++_loc_4 = param1.indexOf(param2, ++_loc_4);
_loc_3++;
}while (++_loc_4 != -1)
return _loc_3;
}
on 27/6/11
Bassically, you can't do this:
var a:Number; ++a = 3;That's what you do here:++_loc_4 = param1.indexOf(param2, ++_loc_4);What this does is assign a value (param1.indexOf(param2, ++_loc_4)) to another value. You must know that this expression:a++; //or ++a;increments the variable and returns a value. The ++a returns the updated value, after it's incremented and a++ returns the value before it's incremented. Anyway, you can't assign a value to another value. You must assign a value to a reference, which would be a variable name. Your algorithm is not good anyway. This is what you need:var str : String = "A String in another String"; trace(str.split('String').length - 1); //this counts the number of appearances of the 'String' in the str string trace(str.split(new RegExp("IN", "gi")).length-1); //this counts the number of appearances of the "IN" string in the str string, but it will be case insensitiveLast edit: on 27/6/11