[AS 2.0] 선택 및 삭제 샘플

ActionScript 2.0 — Tags: , — Siaa @ 11:43 am

다수의 무비클립이나 버튼을 선택 하거나 선택해제 한 뒤, 선택된 무비클립이나 버튼의 값(혹은 변수)만 뽑아내려는 경우.

//Create TextField / TextFormat Setting
this.createTextField("SearchItem",this.getNextHighestDepth(),10,10,520,18);
SearchItem.border = true;
SearchItem.borderColor = 0x666666;

var myformat:TextFormat = new TextFormat();
myformat.font = "Verdana";
myformat.size = 9;
myformat.color = 0x999999;
myformat.letterSpacing = 0;

SearchItem.text = "Not Selected";
SearchItem.setTextFormat(myformat);

var BoxNumber:Number = 12;

var ItemArray:Array = new Array();
for (var i = 0; i <= BoxNumber; i++) {
    ItemArray[i] = i;

    this["NowSelectedBox" + i] = "off";
}

var ItemArraySelected:Array = new Array();

var SendURL:String = "http://www.domain.com/send.php?";

//Event Function (onLoad, EnterFrame, Over, Out, Click)
function BoxLoad(who) {
    who.stop();
}

function BoxEnterFrame(who) {
    var NumOfName:Number = who._name.substr(3, 2);

    if (this["NowSelectedBox" + NumOfName] == "off") {
        who.prevFrame();
    }
    else if (this["NowSelectedBox" + NumOfName] == "on") {
        who.nextFrame();
    }
}

function BoxOver(who) {
    var NumOfName:Number = who._name.substr(3, 2);

    if (this["NowSelectedBox" + NumOfName] == "off") {
        who.onEnterFrame = function() {
            if (who._currentframe != who._totalframes) {
                who.nextFrame();
            }
            else {
                who.gotoAndStop(who._totalframes);
                delete this.onEnterFrame;
            }
        };
    }
}

function BoxOut(who) {
    var NumOfName:Number = who._name.substr(3, 2);

    if (this["NowSelectedBox" + NumOfName] == "off") {
        who.onEnterFrame = function() {
            if (who._currentframe != 1) {
                who.prevFrame();
            }
            else {
                who.gotoAndStop(1);
                delete this.onEnterFrame;
            }
        };
    }
}

function BoxClick(who) {
    var NumOfName:Number = who._name.substr(3, 2);

    if (this["NowSelectedBox" + NumOfName] == "off") {
        this["NowSelectedBox" + NumOfName] = "on";
        if (ItemArray[NumOfName] != "") {
            _root.ItemArraySelected.push(ItemArray[NumOfName]);
            _root.SearchItem.text = _root.SendURL + "area=" + _root.ItemArraySelected.join("&");
            SearchItem.setTextFormat(myformat);
        }
    }
    else if (this["NowSelectedBox" + NumOfName] == "on") {
        this["NowSelectedBox" + NumOfName] = "off";
        if (ItemArray[NumOfName] != "") {
            for (var i:Number = 0; i < ItemArraySelected.length; i++) {
                if (ItemArraySelected[i] == ItemArray[NumOfName]) {
                    ItemArraySelected.splice(i,1);
                    i =- i;

                    _root.SearchItem.text = _root.SendURL + "area=" + _root.ItemArraySelected.join("&");
                    SearchItem.setTextFormat(myformat);
                }
            }
        }
    }
}

//Event Setting
for (var i = 0; i <= BoxNumber; i++) {
    _root.attachMovie("Box","Box" + i,this.getNextHighestDepth());
    _root["Box" + i]._x = (i * 40) + 12;
    _root["Box" + i]._y = 40;
    _root["Box" + i].TextNum.text = i;

    _root["Box" + i].onEnterFrame = function() {
        BoxEnterFrame(this);
    };
    _root["Box" + i].onRollOver = function() {
        BoxOver(this);
    };
    _root["Box" + i].onRollOut = function() {
        BoxOut(this);
    };
    _root["Box" + i].onRelease = function() {
        BoxClick(this);
    };
}
  • Share/Bookmark

0 Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a comment

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License.
(c) 2010 blog.flasia.com | powered by WordPress with Barecity