JAVAC.JP
HOSHI TETSUYA ―“S–ξ
2005/07/25
hossy@javac.jp
http://www.javac.jp
Google
WWW ‚πŒŸυ WWW.JAVAC.JP ‚πŒŸυ

A-4 ‰Ϋ‘θ4 - ‰π“š

‰Ϋ‘θ(4-1)
main.as
---
var test:TestClass=new TestClass();
stop();

ExXML.as
---
class ExXML extends XML{
    private var ignoreWhite=true
    var addEventListener:Function;
    var removeEventListener:Function;
    private var dispatchEvent:Function;
}

TestClass.as
---
import mx.events.EventDispatcher;

class TestClass{
    var ex:ExXML;

    function TestClass(){
        ex=new ExXML();
        loadXML("ini.xml");
    }

    function loadXML(address:String):Void{
        EventDispatcher.initialize(ex);
        ex.onLoad=function(){
            var lo:Object=new Object();
            lo.target=this;
            lo.type="onLoadXML";
            this.dispatchEvent(lo);
        }
        ex.addEventListener("onLoadXML",this);
        ex.load(address);
    }

    function onLoadXML():Void{
        trace(ex);
    }
}
‰Ϋ‘θ(4-2)
main.as
---
var test:TestClass=new TestClass(this);
stop();

ExXML.as
---
class ExXML extends XML{
    private var ignoreWhite=true
    var addEventListener:Function;
    var removeEventListener:Function;
    private var dispatchEvent:Function;
}

TestClass.as
---
import mx.events.EventDispatcher;

class TestClass{
    private var ex:ExXML;
    private var path:MovieClip;
    private var ovalDepth:Number;

    function TestClass(path:MovieClip){
        this.path=path;
        ovalDepth=0;
        ex=new ExXML();
        loadXML("ini.xml");
    }

    function loadXML(address:String):Void{
        EventDispatcher.initialize(ex);
        ex.onLoad=function(){
            var lo:Object=new Object();
            lo.target=this;
            lo.type="onLoadXML";
            this.dispatchEvent(lo);
        }
        ex.addEventListener("onLoadXML",this);
        ex.load(address);
    }

    function onLoadXML():Void{
        var list:Array=ex.firstChild.childNodes;
        for(var i:Number=0;i<list.length;i++){
            var x:XMLNode=XMLNode(list[i]);
            if(x.nodeName="point"){
                var depth:Number=ovalDepth;
                ovalDepth++;
                var linkage:String="oval";
                var mcname:String="oval"+depth;
                path.attachMovie(linkage,mcname,depth);
                var mc:MovieClip=path[mcname];
                mc._x=x.attributes.x;
                mc._y=x.attributes.y;
            }
        }
    }
}



BACKTOPNEXT




All Contents Copyright (C) 2005 HOSHI Tetsuya
Home