A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: [CS4]How to dynamically track a array?

  1. #1
    Member
    Join Date
    Apr 2009
    Posts
    43

    [CS4]How to dynamically track a array?

    ey guys, need some help on my code here. I'm trying to dynamically create buttons that will change accordingly to the matching array vars. So far, the only part that isn't working is the mouse down event. The trace just goes nuts and I'm kinda confuse here. Perhaps theres a better way of doing this? Any help is appreciated =)

    Code:
    var sList:Array = new Array(0, 1, 3, 2, 1, 0, 0, 0);
    var slotClass1 = "1";
    var slotClass2 = "2";
    var slotClass3 = "3";
    var slotClass4 = "4";
    var slotClass5 = "5";
    var slotClass6 = "6";
    var slotClass7 = "7";
    var curSlotSel = ""
    
    function skillStatus() {
    	for (var i = 0; i<_root.sList.length; i++) {
    		switch (_root.sList[i]) {
    			case 0 :
    				_root.skillMenu["skillS_"+[i]].skillText.text = "";
    				_root.skillMenu["skilli_"+[i]].gotoAndStop("blank");
    				break;
    			case 1 :
    				_root.skillMenu["skillS_"+[i]].skillText.text = "Poison Jab";
    				_root.skillMenu["skilli_"+[i]].gotoAndStop("Poison Jab");
    				_root["slotClass"+[i]] = "Poison Jab";
    				break;
    			case 2 :
    
    				_root.skillMenu["skillS_"+[i]].skillText.text = "Double Strike";
    				_root.skillMenu["skilli_"+[i]].gotoAndStop("Double Strike");
    				_root["slotClass"+[i]] = "Double Strike";
    				break;
    			case 3 :
    				_root.skillMenu["skillS_"+[i]].skillText.text = "Advance Boost";
    				_root.skillMenu["skilli_"+[i]].gotoAndStop("Boost");
    				_root["slotClass"+[i]] = "Boost";
    				break;
    		}
    
    		if (_root.customMouse.hitTest(_root.skillMenu["skillS_"+[i]])) {
    			switch (_root.slotClass1) {
    				case "Poison Jab" :
    					trace("1");
    					_root.curSlotSel = "Poison Jab";
    					break;
    				case "Double Strike" :
    					trace("2");
    					_root.curSlotSel = "Double Strike";
    					break;
    				case "Boost" :
    					trace("3");
    					_root.curSlotSel = "Boost";
    					break;
    			}
    
    			onMouseDown = function () {
    				switch (curSlotSel) {
    					case "Poison Jab" :
    						trace("1 is Down");
    						break;
    					case "Double Strike" :
    						trace("2 is Down");
    						break;
    					case "Boost" :
    						trace("3 is Down");
    						break;
    				}
    			};
    		}
    	}
    }
    Its a bit long sorry...

  2. #2
    :
    Join Date
    Dec 2002
    Posts
    3,518
    Code:
    var sList:Array = new Array(0, 1, 3, 2, 1, 0, 0, 0);
    var slotClass0 = "0";
    var slotClass1 = "1";
    var slotClass2 = "2";
    var slotClass3 = "3";
    var slotClass4 = "4";
    var slotClass5 = "5";
    var slotClass6 = "6";
    var slotClass7 = "7";
    var curSlotSel = "";
    
    function doOverSkill() {
    	if (_root.customMouse.hitTest(this)) {
    		_root.curSlotSel = this.skillText.text
    	}
    }
    function doPressSkill() {
    	switch (curSlotSel) {
    		case "Poison Jab" :
    			trace("1 is Down");
    			break;
    		case "Double Strike" :
    			trace("2 is Down");
    			break;
    		case "Advance Boost" :
    			trace("3 is Down");
    			break;
    		default :
    			break;
    	}
    }
    function skillStatus() {
    	for (var i = 0; i<_root.sList.length; i++) {
    		_root.skillMenu["skillS_"+[i]].onRollOver = doOverSkill;
    		_root.skillMenu["skillS_"+[i]].onPress = doPressSkill;
    		switch (_root.sList[i]) {
    			case 0 :
    				_root.skillMenu["skillS_"+[i]].skillText.text = "";
    				_root.skillMenu["skilli_"+[i]].gotoAndStop("blank");
    				break;
    			case 1 :
    				_root.skillMenu["skillS_"+[i]].skillText.text = "Poison Jab";
    				_root.skillMenu["skilli_"+[i]].gotoAndStop("Poison Jab");
    				_root["slotClass"+[i]] = "Poison Jab";
    				break;
    			case 2 :
    				_root.skillMenu["skillS_"+[i]].skillText.text = "Double Strike";
    				_root.skillMenu["skilli_"+[i]].gotoAndStop("Double Strike");
    				_root["slotClass"+[i]] = "Double Strike";
    				break;
    			case 3 :
    				_root.skillMenu["skillS_"+[i]].skillText.text = "Advance Boost";
    				_root.skillMenu["skilli_"+[i]].gotoAndStop("Boost");
    				_root["slotClass"+[i]] = "Boost";
    				break;
    			default :
    				break;
    		}
    		trace(_root["slotClass"+[i]]);
    	}
    }

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