A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: Need help with array code!

  1. #1

    Need help with array code!

    I'm trying to build an array code and have forgotten how to do this ...this code is supposed to change the colour of 10 items (portfolio1 through portfolio10) ... could someone please tell me why this isn't working :

    Code:
    my_array=new Array();
    for(i=0; i<10; i++) {
    	my_array [i] = (i + 1);
    	var whatIsIt = "_root.sectionButton2.portfolio"+my_array[i];
    	trace(whatIsIt);
    	whatIsIt.colorTo(0xFF9F00, 1);;
    }
    the trace return is right ...

    _root.sectionButton2.portfolio1
    _root.sectionButton2.portfolio2.....
    _root.sectionButton2.portfolio10

    Thanks!

  2. #2
    Senior Member
    Join Date
    Aug 2000
    Location
    Montréal
    Posts
    14,141
    Code:
    my_array = new Array();
    for (i=0; i<10; i++) {
        my_array[i] = (i+1);
        var whatIsIt = "_root.sectionButton2.portfolio"+my_array[i];
        trace(whatIsIt);
        myColor = new Color(whatIsIt);
        myColor.setRGB(0xFF9F00);
    }
    Problem is not the array but the coloring method.
    gparis

  3. #3
    Thanks gparis ... that worked.

    Seems i took one step forward and two steps back ... what i was trying to do was; i have a list of items, and when one item is selected, i want the previously selected item to change back to white, and the current one to change to orange. I figured if i would make the current one change to orange, and just set the rest of them to white, it would work, but i'm having timing problems and two or three of them change colours at a time ...

    would you happen to know how i'd be able to have something like "previousSelection" as well as a "currentSelection" variable? When the button is clicked, the current "currentSelection" is changed to a "previousSelection" and the new clicked button is the new "currentSelection"?

    I hope this makes sense!

  4. #4
    Senior Member
    Join Date
    Aug 2000
    Location
    Montréal
    Posts
    14,141
    yes. Have the buttons trigger the event onPress and set the variable onRelease.

    gparis

  5. #5
    Ahh yes ... perfect, Thanks

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