0

This may be an obvious search, but I'm not totally sure on the proper syntax... basically what I want to do is:

        private function makeISchedule(data:Array, label:String = null):ArrayCollection{
            var arr:ArrayCollection = new ArrayCollection;

            for (var i:int = 0; i<data.length; i++){
                var isched:SimpleScheduleEntry = new SimpleScheduleEntry;
                isched.startDate = dater.parseString( data[i].DateTime );
                isched.endDate = dater.parseString( data[i].EndDateTime );
                if (label != null){
                    isched.label = data[i].label;
                }
                arr.addItem( isched );
            }
            return arr;
        }

the problem is .label.. it looks for the actual 'label' field rather than using the label string that's been passed to the function. How can I get the 'label' to be read as the argument variable?

1 Answer 1

2

What you're after is:

isched.label = data[i][label];
Sign up to request clarification or add additional context in comments.

1 Comment

haha.. it really was right there in front of me wasn't it. thanks!

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.