Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3616386
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T22:29:34+00:00 2026-05-18T22:29:34+00:00

I have a php function that brings in a simple arraycollection (called QuestionSeries) to

  • 0

I have a php function that brings in a simple arraycollection (called QuestionSeries) to FlashBuilder, with a variety of values including “Answers” and “Results” which I need in a format useable in a FlashBuilder 4 pie chart, another arraycollection (called ChartData) which looks something like:

ChartData = [0->[Answer->{Answer},Result->{Result}] , 1->[Answer->{Answer},Result->{Result}] , 2->[Answer->{Answer},Result->{Result}] , … ]

However, the number of [{Answer},{Result}] pairs that I need to call in is dependent on the number that exist in the QuestionSeries arraycollection, although this number is given in QuestionSeries by a value, “Num_Options”.

So, currently I have a bit of script that looks something like:

    protected function graphsetup():void{   

    if(QuestionSeries.Num_Options>=1)
    {                   
        ChartData.addItem({Answer:QuestionSeries.Ans01, Result:QuestionSeries.Ans01_n})
    }
    if(QuestionSeries.Num_Options>=2)
    {                   
        ChartData.addItem({Answer:QuestionSeries.Ans02, Result:QuestionSeries.Ans02_n})
    }
    if(QuestionSeries.Num_Options>=3)
    {                   
        ChartData.addItem({Answer:QuestionSeries.Ans03, Result:QuestionSeries.Ans03_n})
    }
     ...

Which is ok at the moment, as I only ever have between 2 and 6 answers but a) this obviously isn’t optimal even at the moment and b) at some point I may have anything up to 100 answers. So I basically want to put it into a clever for- or while-loop, however my ActionScripting skills aren’t quite up to scratch quite frankly and I was hoping someone might be able to point me in the right direction?

I struggle because I can’t state "QuestionSeries.Ans[i]"..., which was the crux of my initial attempt.

I think one approach may be sort the original QuestionSeries array (all the required values come under Ans[i] and Ans[i]_n so they sit adjacent when sorted alphabetically by index) and then pop or shift elements off the end of it, but being fairly inept in terms of actionscript ability… I couldn’t make it work.

Thanks a lot in advance, I’d really appreciate anything anyone might have to say on this topic.

Josh

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T22:29:34+00:00Added an answer on May 18, 2026 at 10:29 pm

    I think you should really rethink about the structure and the naming convention in your arraycollection for easier iteration. The things you want to iterate over begin from 1 and contain leading zeroes. And I think it would be better to contain all your answers and results as tuples in a simple indexed array.

    Still if that’s not an option, you can use something along the lines of:

    protected function addLeadingZero(number:int):String {
        if (number > 10) return number.toString();
        return "0" + number.toString();
    }
    
    protected function graphSetup():void {
        for (var i:int, l:int = int(QuestionSeries.Num_Options); i < l; i++) {
            ChartData.addItem({
                Answer:QuestionSeries["Ans" + addLeadingZero(i + 1)], 
                Result:QuestionSeries["Ans" + addLeadingZero(i + 1) + "_n"]
            });
        };
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some jQuery code. I have called an Ajax function file, file.php, that
I have a PHP function that allows users to pick which categories there post
I have a PHP function that returns an array. This is the output of
I have a php function that dynamically queries a database, and returns 6 tables.
Does anyone have a PHP function that for example if a mysql_error() happens due
Is there any way to have PHP automatically call a function, before a script
I have code with the following form: <?php function doSomething{ //Do stuff with MySQL
I have a JavaScript function, pop_item . I have to call this from PHP,
I have this little function function makewindows(){ child1 = window.open (about:blank); child1.document.write(<?php echo htmlspecialchars(json_encode($row2['ARTICLE_DESC']),
i need help with disk_total_space function.. i have this on my code <?php $sql=select

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.