A Flash Developer Resource Site

Results 1 to 20 of 40

Thread: Problem Reading XML - Help!

Threaded View

  1. #1
    I know nothing.
    Join Date
    Feb 2008
    Posts
    315

    Problem Reading XML - Help!

    I"m having issues defining values in my AS from the XML. For some reason my AS won't read my XML File. See below. Am I missing anything?

    I've been going through this for hours and can't figure out what I'm missing.

    AS:
    Code:
    
    var newsWidth=300;//news tricker width;
    var newsHeight=335;//news tricker height;
    var itemspace=15;//between two item space.
    var speed=40;//slide speed.
    
    system.useCodepage=true;
    Stage.scaleMode = "noscale";
    // -- draw rectangle
    MovieClip.prototype.drawrect = function(pos_x, pos_y, w, h) {
    	// --
    	this.px = pos_x;
    	this.py = pos_y;
    	this.an = w;
    	this.al = h;
    	// --
    	with (this) {
    		beginFill(0x000000, 30);
    		moveTo(px, py);
    		lineTo(px+an, py);
    		lineTo(px+an, py+al);
    		lineTo(px, py+al);
    		lineTo(px, py);
    		endFill();
    	}
    };
    // -- format text
    myFormat = new TextFormat();
    myFormat.font = "verdana";
    myFormat.size = 20;
    myFormat.color = 0x000000;
    
    
    // xml parsing.
    xmlParse = function (xmlObj) {
    	this = xmlObj;
    	var xpos = 0;
    	var ypos =0;
    	for (var i = 0; i<this.firstChild.childNodes.length; i++) {
    		item = newsTicker_mc.attachMovie("Ticker_mc", "Ticker"+i, 100+i);
    		//item.mytext.embedFonts = true;
    		item.main.mytext.autoSize = true;
    		item.main.mytext.text = this.firstChild.childNodes[i].attributes.mytext;
    		item.mylink = this.firstChild.childNodes[i].attributes.links;
    		item.main.mytext.setTextFormat(myFormat);
    		item._x = xpos;
    		item._y = ypos;
    		ypos += item.main.mytext.textHeight+itemspace;
    		// --
    		item.onRelease = function() {
    			this.main.mytext.textColor = 0x000000;
    			// -- open the link
    			getURL(this.mylink, target="_blank");
    		};
    		// --
    		item.onRollOver = function() {
    			this.news.mytext.textColor = 0x000000;
    			// --clear interval
    			clearInterval(idInterval);
    		};
    		// --
    		item.onRollOut=item.onReleaseOutside = function() {
    			this.main.mytext.textColor = 0x000000;
    			// -- re setInterval,go on move
    			idInterval = setInterval(scrollit, speed, this._parent);
    		};
    	}
    };
    
    // --load xml
    myXML = new XML();
    myXML.ignoreWhite = true;
    myXML.onLoad = function(succes) {
    	if (succes) {
    		xmlParse(this);
    	} else {
    		trace("Error al cargar datos");
    	}
    };
    
    myXML.load("http://tabletrac/tv/text/L.xml");
    
    // --define scroll
    scrollit = function (myclip) {
    	myclip._y -= 1;
    	updateAfterEvent();
    	// -- hitTest
    
    	if (!myclip.hitTest(maskTicker)) {
    		myclip._y = maskTicker._y+maskTicker._height+50;
    	}
    };
    
    // -- create mask
    this.createEmptyMovieClip("maskTicker", this.getNextHighestDepth());
    this.maskTicker.drawrect(newsTicker_mc._x, newsTicker_mc._y, newsWidth, newsHeight);
    newsTicker_mc.setMask(this.maskTicker);
    // -- setInterval
    
    idInterval = setInterval(scrollit, speed, newsTicker_mc);
    XML:
    Code:
    <main>
    <news>
    <new links="" mytext="Welcome to 7 Clans Casino | Thief River Falls"/>
    <new links="" mytext="                                                                                    "/>
    <new links="" mytext="...................................."/>
    <new links="" mytext="Our friendly Player Club Staff are here to guarantee that you experience the best of Northern Minnesota's celebrated hospitality each time you visit us. "/>
    
    
    <new links="" mytext="Don't forget to sign-up for our Players Club! Jackpot will be starting at 4:00pm"/>
    <new links="" mytext="                                                                                    "/>
    <new links="" mytext="...................................."/>
    <new links="" mytext="Check out the pool"/>
    <new links="" mytext="                                                                                    "/>
    <new links="" mytext="...................................."/>
    <new links="" mytext="Lunch and Dinner Buffets starting at $11.95"/>
    <new links="" mytext="                                                                                    "/>
    <new links="" mytext="...................................."/>
    
    </news>-->
    </main>
    Last edited by intromo; 05-07-2008 at 03:42 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center