2010-03-31 3 views
0

변환을 테스트하고 싶은 플래시 파일에 액션이 2 개 있습니다. 하나는 탭/창에서 링크를 열고, 다른 하나는 페이지의 Colorbox iframe에 내용을로드합니다.랜덤 액션 선택, 플래시 AS3

다음 작업 중 하나를 임의로 선택하는 방법은 무엇입니까?

나는 현재 버튼에 클릭을 수신 : 두 가지 옵션이 같은 Math.random()를 사용하는 사이에

navigateToURL(new URLRequest("http://www.google.com/"), '_blank'); 

ExternalInterface.call('$.fn.colorbox({ 
    href: "http://www.google.com/", 
    width:"80%", 
    height:"80%", 
    iframe:true, 
    onLoad:function(){ $("#player").css({"visibility":"hidden"}); }, 
    onClosed:function(){ $("#player").css({"visibility":"visible"}); }}) 
'); 

답변

1

가 무작위로 선택하려면 :

clickJoin.addEventListener(MouseEvent.CLICK,toJoin); 

내 두 가지 작업

은 this :

if (Math.random() < 0.5) { 
    // do action 1 
} else { 
    // do action 2 
}