# Designer struggling to program!

**URL:** <https://forum.kirupa.com/t/designer-struggling-to-program/275561>\
**Category:** flash\
**Created:** [November 15, 2008, 9:29pm UTC](https://forum.kirupa.com/t/designer-struggling-to-program/275561 "2008-11-15T21:29:42Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![wentworth](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/wentworth/32/3451_2.png) [@wentworth](https://forum.kirupa.com/u/wentworth)\
**Post date:** [November 15, 2008, 9:29pm UTC](https://forum.kirupa.com/t/designer-struggling-to-program/275561/1 "2008-11-15T21:29:42Z")

</div>

Can’t get this working but must be easy to fix! I have a list component populated with XML data. When the user makes a selection the alpha value of “s1 s2 and s3” change. It all works except they all stay changed when another selection is made. I need them to return to their original state when another selectiion is made ie. only one change at a time. I think if I can get the var “selected number” outside the function “selectPiece” it’ll work but when I try to do this I get the error message “Access of undefined property select piece” Here’s my code:-

```auto
s1.alpha=.1;
s2.alpha=.1;
s3.alpha=.1;

function selectPiece(evt:Event):void {
    trace("selected "+evt.target.selectedIndex);
    taPrice.text=piecesXML.piece[evt.target.selectedIndex].price+" €";
    taRef.text=piecesXML.piece[evt.target.selectedIndex].ref;
    loader1.source="images/"+piecesXML.piece[evt.target.selectedIndex].ref+".swf";
    taQty.text=piecesXML.piece[evt.target.selectedIndex].qty;
    var selectedNum:int=(evt.target.selectedIndex);
    trace(selectedNum);

    var aCircle:Array=new Array(s1,s2,s3);
    aCircle[selectedNum].alpha=1;
        
}

l1.addEventListener(Event.CHANGE,selectPiece);

```

If you can help I would really appreciate it, even if you think the above is dreadful coding and needs a total re-write, I want to learn! That’s it - I get the feeling that a lot of people who post problems here are those who like me don’t have a strong programming background but are forced to do some- What we find difficult is how to structure the code where to put the bits, so perhaps a good basic tutorial on this would help or perhaps it’s just me!
