이름과 점수라는 두 개의 다른 배열이 있는데 [이름 :, 점수 :]가되도록 같은 배열에 배치하고 싶습니다.
var allNames:Array = ["Test A", "Test B", "Test C"];
var allScores:Array = ["10","7","0"];**
예를 들어 각 배열의 첫 번째 요소를 가져 와서 두 번째와 세 번째 요소를 함께 넣습니다. 그래서 위의 배열은
var NamesAndScore = [names:Test A score:10], [name:Test B score:7], [name:Test C score:0]
초심자라서 멍청 해 보이면 미안 해요.
var allNames:Array = ["Test A", "Test B", "Test C"];
var allScores:Array = ["10","7","0"];
// Initialise a new array for the names and scores
var namesAndScores:Array = [];
for (var i:int = 0; i < allNames.length; i ++)
{
// Push an object with name and score properties onto the new array
namesAndScores.push({
name: allNames[i],
score: parseInt(allScores[i], 10)
});
}
// To access the name and score properties of the first element of the new array
trace("name 1", namesAndScores[0].name, "score 1", namesAndScores[0].score);
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다