1

Actually my Flex Application ..Sample code

private var selectedDays:String = null;
            protected function selectRepeatedDays(event:MouseEvent):void
            {
                selectedDays = new String();
                if(MON.selected==true)
                {
                    selectedDays += "MONDAY,";
                    Alert.show("Monday  :"+selectedDays);
                }
                if(TUE.selected==true)
                {
                    selectedDays +=  "TUESDAY,";
                }
                if(WED.selected==true)
                {
                    selectedDays += "WEDNESDAY,";
                    Alert.show("Monday  :"+selectedDays);
                }
                if(THU.selected==true)
                {
                    selectedDays += "THURSDAY,";
                }

}
var arr:ArrayCollection = new ArrayCollection();
arr = selectedDays.substr(0, selectedDays.length-1).toString();

Alert.show(arr.lenth)

But it is not convert... the Alert Statement Not Prompt .. So How to Convert This String into ArrayCollection...

2 Answers 2

2

Use the method split to convert the String to Array:

var array:Array = selectedDays.split(",");

Then (if needed yet) add each item of Array to the ArrayCollection:

var arr:ArrayCollection = new ArrayCollection();
for each (var str:String in array) {
    arr.addItem(str);
}
Sign up to request clarification or add additional context in comments.

1 Comment

var arr:ArrayCollection = new ArrayCollection(array);
1

use below code snippet to convert String to ArrayCollection

  1. Convert String to Array using split method

    var array:Array = selectedDays.split(",");
    
  2. Convert Array to ArrayCollection

    var selectedDaysArr:ArrayCollection = new ArrayCollection(array);
    

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.