How do I change xml to array

Posted on 2010-01-04
Last Modified: 2012-05-08
I have a xml-attribute, that has a line of commaseparated numbers that I want to use as an array.
But even thought I can trace that the content has entered my movie correctly, the numbers doesnt seem to work as an array.....
Take a look at this:
var imgArray:Array = Array(xmlQuestions[0].childNodes[0].attributes.qPix);
trace(imgArray) results correctly in this: 1,3,4,9
so I would think that I could simply enter the array-name like this
var maskNumbers:Array = [imgArray];

but no, the result isnt entered into the function, that you can see in the code below. The code mask an image in 16 bites based on the entered array-numbers.

Even though the correct numbers is traced correctly inside the function
trace(maskArray) shows 1,3,4,9
only the upper left 16th part of the picture is shown.

it is as if the function doesnt accept it as an array even though the trace shows exactly the same if I manually enters the same numbers in the maskNumbers-array

Im lost here. please help....
function initMaskBlocks(maskArray:Array){

for (var i:Number = 0; i < maskArray.length; i++) {

   maskBlock(maskArray[i], qmaskW, qmaskH, qmaskW * ((maskArray[i] - 1) % 4), qmaskH * ((maskArray[i] - 1) / 4 >> 0));


Open in new window

Question by:petersego
    LVL 6

    Accepted Solution

    try the following
    var imgArray:Array = xmlQuestions[0].childNodes[0].attributes.qPix.split(",");

    Open in new window


    Author Closing Comment

    Thanks, works perfect...

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Training Course: Adobe Photoshop CC 2015

    Photoshop has become the standard in image manipulation among professional photographers and graphic designers. This course covers exam objectives for the Adobe Certified Associate (ACA) certification.

    Recently, I was asked to recommend a tracking system to be implemented on a clients website. As the entire site was built on flash, my first thought was to suggest custom built tracking system. However, our company at that point of time didn't h…
    In my long career of working as an actionscript developer, I had spent sleepless night often working hard to solve some small problems which actually took a lot of my development time; later found out the solutions to be a line or two. Here are s…
    In this tutorial viewers will learn how to create a basic motion tween animation in Flash Open a new document in Flash: Draw/import an image: Press CTRL + F8 to convert it into a graphic symbol: Select a frame (how long you want the tween to last): …
    The goal of the tutorial is to teach the user how to select which audio input to use. Once you have an audio input plugged into the laptop or computer, you will go into the audio input settings and choose which audio input you want to use.

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now