dimanche 21 février 2016

alphabetic glossary xml by actionscript3

Glossary will navigate to Glossary page that will show alphabetic letters according to the English language , when click in each letter will show words that start with this letter , when click in each word will show the definition of the word . so i made alphabetic letters as buttons in fla . when i click on word the definition didn't show anything but trace is right

import flash.events.MouseEvent;
import flash.events.Event;
import flash.net.URLLoader;
import flash.net.URLRequest;
import flash.display.Sprite;
import flash.display.MovieClip;
stop();
var n:int = 50;
var myLoader:URLLoader= new URLLoader();
myLoader.load(new URLRequest("rr55.xml"));
myLoader.addEventListener(Event.COMPLETE,loadXML);
var myxml:XML = new XML(myLoader.data);
function loadXML(e:Event)
{
    var myxml:XML = new XML(myLoader.data);
    for (var m:int=0; m<1; m++)
    {
        var btn:MovieClip = qwe(String(myxml.a));
        btn.x = 165;
        btn.y = 165 + n;
        addChild(btn);
        addEventListener(MouseEvent.CLICK,ghj);
        n +=  50;
        trace(n);
    }
}
function qwe(label:String):MovieClip
{
    var txt:TextField = new TextField();
    txt.defaultTextFormat = new TextFormat('Cooper Black',20,0x8b3a3a);
    txt.text = label;
    txt.autoSize = TextFieldAutoSize.LEFT;
    txt.background = txt.border = false;
    txt.selectable = false;
    var btn:MovieClip = new MovieClip();
    btn.mouseChildren = false;
    btn.buttonMode = true;
    btn.addChild(txt);
    btn.label = label;
    return btn;
}
function ghj(Event:MouseEvent)
{
    var btn2:MovieClip = qwe(String(myxml.a));
    btn2.buttonMode = false;
    btn2.x = 300;
    btn2.y = 165 + n;
    n +=  50;
    addChild(btn2);
    trace(btn2.y)
}

and my xml is

<?xml version="1.0" encoding="UTF-8"?>

<a>
    worda start with a
    worda2 start with a
    worda3 start with a
</a>

<b>
    wordb start with b
    wordb2 start with b
    wordb3 start with b
</b>

<worda> 
    the definition
</worda>

<worda2>    
    the defenition
</worda2>

<worda3>    
    the defenition
</worda3>

Aucun commentaire:

Enregistrer un commentaire