본문 바로가기

컴터/Flash & Flex

[flex]for문에서 addEventListener 줄때 마지막 값만 가져올때...

336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

for문에서 이벤트를 주면 마지막값만 가져왔다.
그래서 해결책을 찾던중 방법1을 찾았지만, 어떻게 하다 보니 방법2처럼도 되더라..

-> 다른 사람도 나처럼 마지막 값만 가져오나 ㅡㅡ;;

방법1.

http://warkyman.tistory.com/177


url을 따로 저장해서 e:MouseEvent
acb.getChildIndex(e.target);이거면 링크버튼이 몇번째인지 나오고
url:Array//배열형태
위에서 구한인댁스로 url[xx];이런식으로 참조해야대요
addEventListener(MouseEvent.CLICK, goURL);
이거는 마우스이밴트 날리는거라서 제가알기로는 이렇게 해야함



http://cafe.naver.com/ArticleRead.nhn?clubid=10833316&page=4&searchtype=1&query=addEventListener click&searchdate=all&articlemedia=0&sortby=date&articleid=11696



방법2.
 내가 했떤 방법..
 -> 버튼 생성.
 -> btn.label = tmp.tagName;  라벨값 부여
 -> v.target.label; 직접 타겟으로 지정후 해당 값 불러옮.

private function createBtn(tmp:Object):void{
       var btn:LinkButton = new LinkButton();      
       btn.label = tmp.tagName;
       btn.toolTip = tmp.tagName;    
          
       ////href
       btn.addEventListener(MouseEvent.CLICK, href);

}

private function href(v:MouseEvent):void{
    navigateToURL(new URLRequest(v.target.label), '_self');
 }