dcsimg
A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: XML Simplify Code - HELP please!!

  1. #1
    Junior Member
    Join Date
    Apr 2007
    Location
    Singapore
    Posts
    7

    Red face XML Simplify Code - HELP please!!

    Hi,

    I have to repeat the follow code 4x5 times currently....

    t_factor = rc_xml.p.rc.(@id == t_type).pduration.pfactor;
    t_base = rc_xml.p.rc.(@id == t_type).pduration.pbase;
    t_min = rc_xml.p.rc.(@id == t_type).pduration.pmin;
    t_start = rc_xml.p.rc.(@id == t_type).pduration.pstart;
    t_end = rc_xml.p.rc.(@id == t_type).pduration.pend;

    I'm trying to do the following:

    var myArray_1:Array = new Array("pduration", "poutfit", "pbackground", "ppax");
    var a:int = 0;

    for (a=0; a<4l a++)
    {
    t_factor = rc_xml.p.rc.(@id == t_type).myArray_1[i].pfactor;
    t_base = rc_xml.p.rc.(@id == t_type).myArray_1[i].pbase;
    t_min = rc_xml.p.rc.(@id == t_type).myArray_1[i].pmin;
    t_start = rc_xml.p.rc.(@id == t_type).myArray_1[i].pstart;
    t_end = rc_xml.p.rc.(@id == t_type).myArray_1[i].pend;
    }

    PROBLEM is that Flash won't accept the VARIABLE myArray[i] in place of the element name?

    Can someone please advise ;-)

    Thanks,
    Johann
    Last edited by johanndm; 07-04-2009 at 05:53 AM.

  2. #2
    Junior Member
    Join Date
    Apr 2007
    Location
    Singapore
    Posts
    7

    Found the solution ...

    var myArray_1:Array = new Array("pduration", "poutfit", "pbackground", "ppax");
    var i:int = 0;

    for (i=0; i<4; i++)
    {
    t_factor = rc_xml.p.rc.(@id == t_type).elements(myArray_1[i]).pfactor;
    t_base = rc_xml.p.rc.(@id == t_type).elements(myArray_1[i]).pbase;
    t_min = rc_xml.p.rc.(@id == t_type).elements(myArray_1[i]).pmin;
    t_start = rc_xml.p.rc.(@id == t_type).elements(myArray_1[i]).pstart;
    t_end = rc_xml.p.rc.(@id == t_type).elements(myArray_1[i]).pend;
    }

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center