广告合作
|
关于我们
|
网站地图
|
我要投稿
首页 > ActionScript代码库 > Array Object
(页码 1 - 2)   1 2 下一页 »
  • Array String Search
     
    arr = ["Apollo", "Bacchus", "Ianus", "Iupiter", "Mars", "Mercurius"];
    Array.prototype.sucher = function(w) {
            trace(this);
            var resD = [];
            var resC = [];
            for (i in this) {
                    if ((this[i].indexOf(w, 0) != -1)) {
                            resD.push(this[i]);
                            resC.push(i);
                    }
            }
            if (resD.length == 0) {
                    return (-1);
            } else {
                    resC.shift();
                    resC = resC.reverse();
                    return (resC);
            }
    };
    trace(arr.sucher("us"));
  • Array movieclip in rows and colums
     
    on (release) {
            aantal = 1;
            for (a=1; a<=kolom; a++) {
                    for (b=1; b<=rij; b++) {
                            duplicateMovieClip (balletje, aantal, aantal);
                            setProperty (aantal, _x, a * 20);
                            setProperty (aantal, _y, b * 20);
                            aantal = aantal+1;
                    }
            }
    }
  • Array movieclip in rows and columns clearScriptedVersion
     
    on (release) {
            var maxNum = 10;
            var num = 1;
            for (a=1; a<=maxNum; a++) {
                    for (b=1; b<=maxNum; b++) {
                            _root.ball.duplicateMovieClip("ball"+num, num);
                            _root["ball"+num]._x = a*50;
                            _root["ball"+num]._y = b*50;
                            num++;
                    }
            }
    }
  • array flipper
     
    function flip (arr) {
            var tmp = new Array();
            L = arr.length;
            for (i=0; i<arr.length; i++) {
                    tmp.push(arr[L-1]);
                    L = L-1;
            }
            return tmp;
    }
    temp = new Array(5, 10, 15, 20, 25, 30, 35, 40);
    temp = flip(temp);
    trace (temp);
  • Array - Unique
     
    // This script was already posted, but with an error, so i corrected it
    // The other script didnt split tree or more equal elements side by side
    // like this: a = [1,1,1,1] returned a = [1,1]
    
    // This script splits the equal elements from an array
    // Usage: a = [1,1,1,1,1,1];
    // a = a.unique();
    // now a = [1];
    
    Array.prototype.unique = function()
    {
            for (i=0; i<this.length; i++) {
                    for (j=0; j<this.length-i; j++) {
                            if (this[i] == this[i+j+1]) {
                                    this.splice(i+j+1, 1);
                                    j--;
                            }
                    }
            }
            return this;
    };
    
    // Now its correct =]
(页码 1 - 2)   1 2 下一页 »

友情链接

Copyright 2000-2011 ActionScript. All Rights Reserved. 联系我们