ActionScript 重新定位网格上的拇指

Stage.align = "TL";
var total:Number = 20;
var thumbWidth:Number = 100;
var thumbHeight:Number = 60;
buildThumbs();
function buildThumbs():Void {
	for (var i:Number = 0; i<total; i++) {
		var thumb_mc:MovieClip = this.createEmptyMovieClip("thumb"+i+"_mc", i);
		with (thumb_mc) {
			beginFill(0x222222,100);
			lineStyle(0.5,0xCCCCCC,100);
			moveTo(0,0);
			lineTo(thumbWidth,0);
			lineTo(thumbWidth,thumbHeight);
			lineTo(0,thumbHeight);
			lineTo(0,0);
		}
		var label_txt:TextField = thumb_mc.createTextField("label_txt", 0, 0, 0, 0, 0);
		label_txt.text = i+1;
		label_txt.autoSize = true;
		label_txt.textColor = 0xFFFFFF;
	}
	positionInGrid();
	Stage.addListener(this);
}
function positionInGrid():Void {
	var limit:Number = Math.floor(Stage.width/thumbWidth);
	for (var i:Number = 0; i<total; i++) {
		var thumb_mc:MovieClip = this["thumb"+i+"_mc"];
		var column:Number = i%limit;
		var row:Number = Math.floor(i/limit);
		thumb_mc._x = column*thumbWidth;
		thumb_mc._y = row*thumbHeight;
	}
}
function onResize() {
	positionInGrid();
}

Java 从完整路径名中提取文件名(不带扩展名)

public static String getFileNameWithoutExtension(String fileName) {
        File tmpFile = new File(fileName);
        tmpFile.getName();
        int whereDot = tmpFile.getName().lastIndexOf('.');
        if (0 < whereDot && whereDot <= tmpFile.getName().length() - 2 ) {
            return tmpFile.getName().substring(0, whereDot);
            //extension = filename.substring(whereDot+1);
        }    
        return "";
    }

Java 从完整路径名中提取文件的扩展名

public static String getFileExtension(String fileName) {
        File tmpFile = new File(fileName);
        tmpFile.getName();
        int whereDot = tmpFile.getName().lastIndexOf('.');
        if (0 < whereDot && whereDot <= tmpFile.getName().length() - 2 ) {
            return tmpFile.getName().substring(whereDot+1);
        }    
        return "";
    }

Perl 使用XML :: API :: XHTML在命令行上生成XHTML

perl -e "use XML::API::XHTML; my $d = new XML::API::XHTML(); $d->head_open(); $d->title('hello world!'); $d->script({type => 'text/javascript'}, '/* hello scripts! */'); $d->head_close(); $d->body_open(); $d->h1({style => 'color:red'}, 'Hi nerd!'); print $d;"  | tidy -q -o temp.html

C# 使用高级编程技术创建线性列表

using System;
using System.Text;
using System.Collections;
using System.Collections.Generic;

namespace MyOwnGeneric
{
    class OwnObject<T>
    {
        private T content;
        private OwnObject<T> next;

        public T Content
        {
            get { return content; }
            set { content = value; }
        }

        public OwnObject<T> Next
        {
            get { return next; }
            set { next = value; }
        }

        public override string ToString()
        {
            return content.ToString();
        }
    }

    class LinList<T> : IEnumerable<T>
    {
        private OwnObject<T> first;
        private OwnObject<T> last;

        public OwnObject<T> First
        {
            get { return first; }
            set { first = value; }
        }

        public OwnObject<T> Last
        {
            get { return last; }
            set { last = value; }
        }

        public void Add(OwnObject<T> item)
        {
            if (first == null)
            {
                first = item;
                last = item;
            }
            else
            {
                last.Next = item;
                last = item;
            }
        }

        //function to count items in LinList
        public int Count()
        {
            int counter = 0;
            OwnObject<T> position = first;
            while (position != null)
            {
                counter++;
                position = position.Next;
            }
            return counter;
        }

        //function to get the content at a fix position in LinList
        public T GetItem(int pos)
        {
            int counter = 0;
            OwnObject<T> position = first;
            //T result = null not possible because value type
            T result = default(T);
            while (position != null)
            { 
                if (counter == pos)
                {
                    result = position.Content;
                    break;
                }
                counter++;
                position = position.Next;
            }
            return result;
        }

        public override string ToString()
        {
            string result = "";
            OwnObject<T> position = first;
            while (position != null)
            {
                result += position.ToString();
                if (position.Next != null)
                    result += " - ";
                position = position.Next;
            }
            return result;
        }

        //indexer
        public T this[int index]
        {
            get
            {
                return this.GetItem(index);
            }
        }

        //interface IEnumerable
        public IEnumerator<T> GetEnumerator()
        {
            OwnObject<T> position = first;
            while (position != null)
            {
                yield return position.Content;
                position = position.Next;
            }
        }

        IEnumerator IEnumerable.GetEnumerator()
        {
            return GetEnumerator();
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            LinList<string> test = new LinList<string>();
            OwnObject<string> testcont = new OwnObject<string>();
            testcont.Content = "test";
            OwnObject<string> testcont2 = new OwnObject<string>();
            testcont2.Content = "test2";
            OwnObject<string> testcont3 = new OwnObject<string>();
            testcont3.Content = "test3";

            test.Add(testcont);
            test.Add(testcont2);
            test.Add(testcont3);

            //using the interface of IEnumerable
            foreach (string item in test)
            {
                Console.WriteLine(item);
            }

            //using the indexer and the item counter
            for (int i = 0; i < test.Count(); i++)
            {
                Console.WriteLine(test[i]);
            }
        }
    }
}

C# 方法和不同类型的参数传递

using System;

namespace parameters
{
    public static class democlass
    {
        //normal use
        public static int Add(int left, int right)
        {
            return left + right;
        }

        //use the ref Parameter, e.g. for increment
        public static void AddPlus(ref int number)
        {
            number = number + 1;
        }

        //use the out Parameter
        public static void GetHundred(out int number)
        {
            number = 100;
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            int a = 10;
            int b = 20;
            int c;

            c = democlass.Add(a, b);
            Console.WriteLine(c);           //30

            democlass.AddPlus(ref c);
            Console.WriteLine(c);           //31

            democlass.GetHundred(out c);
            Console.WriteLine(c);           //100
        }
    }
}

JavaScript 获取元素的实际样式属性值

function measure(el, styleProp) {
    if (el.currentStyle)
         var st = el.currentStyle[styleProp];
    else if (window.getComputedStyle)

    var st = document.defaultView.getComputedStyle(el, null).getPropertyValue(styleProp);
    return st;
}

AppleScript 在维也纳获取未读消息的数量(RSS-Reader)

tell application "Vienna"
set unreadCount to total unread count
return "Vienna: " & unreadCount & " unread messages"
end tell

ActionScript AS2:使用保险丝淡化和移除目标MC

public function hideElement():Void{
	ZigoEngine.doTween( this, '_alpha', [ 0 ], 1, "easeOutExpo", 0, {scope:this, func:'removeElement'});
} // END hideElement()
public function removeElement():Void{
	this.removeMovieClip();
} // END removeElement()

PHP 回声

<?php echo ''; ?>