Code tagged with xml

XMLObject to DataSet

Posted by Chad Humphries over 2 years ago
//================================================
// XMLObject to DataSet
//================================================
// This allows you to use a standard XML object
// to load data into a datasest. Using the standard
// allows the use of a progress bar to show the
// loading of the XML data. With the XML connector
// component it seems that there is no easy way to
// display the load status. This is designed
// for Flash MX 2004 Pro.
//------------------------------------------------
// [NOTES]
// loaderPopup is a movieclip that has a progress
// bar component in it that is tied to the progress
// of the XML obj.  btnLoadBig_jea is a button
// component that is used to trigger the XML Load.
//------------------------------------------------
loaderPopup._visible = 0; // hide progressbar loader movieclip
var mainXML:XML = new XML();// define & strict type the main xml object

// Once the XML loads, do this..
function xmlPopDsJEA () {
        _root.myDataSet.disableEvents(); // turn off events on the dataset. Processes faster.
        _root.loaderPopup._visible = 0; // hide progresbar loader MC
        _root.btnLoadBig_jea.enabled = 0; // turn off load button [optional]
        _root.btnLoadBig_jea.label = "XML Loaded"; // change the text on the load button [optional]
        numPeople = _root.mainXML.firstChild.childNodes.length - 1; // how many rows
        for (i=0; i
Language ActionScript / Tagged with flash, xml

isThai and ThaiWarp function

Posted by Chad Humphries over 2 years ago
Two fuction to process Thai text with PyICU

import PyICU

def isThai(chr):
    cVal = ord(chr)
    if(cVal >= 3584 and cVal <= 3711):
        return True
    return False

def warp(txt):
    print txt
    bd = PyICU.BreakIterator.createWordInstance(PyICU.Locale("th"))
    bd.setText(txt)
    lastPos = bd.first()
    retTxt = ""
    try:
        while(1):
            currentPos = bd.next()
            retTxt += txt[lastPos:currentPos]
            #Only thai language evaluated
            if(isThai(txt[currentPos-1])):
                if(currentPos < len(txt)):
                    if(isThai(txt[currentPos])):
                        #This is dummy word seperator   
                        retTxt += "|"
            lastPos = currentPos
    except StopIteration:
        pass
        #retTxt = retTxt[:-1]
    return retTxt
Language Python / Tagged with xml