Jump to content


Photo

Swf Externo Não Carrega Xml


  • Faça o login para participar
8 replies to this topic

#1 J. Silvério

J. Silvério

    Novato no fórum

  • Usuários
  • 3 posts
  • Sexo:Masculino
  • Localidade:SJK -SP

Posted 12/02/2010, 00:21

Olá pessoal,

Já procurei no google, aqui no fórum e em outros também.

Tem a base do site que se chama index.swf. Essa base carrega um sistema de notícias (news.swf) que por sua vez lê os dados em um XML.

Se eu abro a news.swf separadamente ele lê normalmente. Se eu abro o index.swf fica em "loading".

Estou chamando na index.swf a news.swf por um loadMovie. Na news.swf só tem 2 códigos que estão no 1º frame da 2ª linha.

Cod 1 - #include "mc_tween2.as"
Cod 2 - var ticker = new Ticker();

Já adiantando, os apontamentos com relação a leitura de AS e XML estão certos.

Segue o código Ticker.as:


class Ticker {
	
	private var news:Array = new Array(); //the array which stores objects containing text,date,time,link tags from each item in XML file
	private var XMLFile:String="news.xml"; //the name of the XML file
	private var currentMessage=-1; //the current possition in the news array (current displayed headline)
	private var interval=-1; //inverval variable used in function rotateNews to change headlines
	private var interval2=-1; //inverval variable used in function rotateNews to change headlines
	private var textColor:Number; //text color from xml file
	private var overColor:Number; //over state text color from xml file
	private var arrowPress:Boolean=false;
	
	public var maxCharCount:Number=-1; //max char count from XML file
	public var newsTimer; //delay for each headline from XML files
	
	static var instance:Ticker; //this class
	
	
	//constructor
	function Ticker() {
		instance=this; //i am me <img src='http://forum.wmonline.com.br/public/style_emoticons/<#EMO_DIR#>/smile.gif' class='bbc_emoticon' alt=':)' />
		trace("- ticker started");
		init(); //in the constructor function we don't have access to all stage members
	}
	
	//do intializations
	function init(){
		// align stage to top left corner
		Stage.align = "TL";
		// set scale mode to no scale
		Stage.scaleMode = "noScale";
		// create a listener object for the stage
		var stageListener = new Object();
		// this function will be triggered every time the window is resized
		function rearrange() {
			var w:Number = Stage.width, h:Number = Stage.height;
			// rearange objects on stage			
			_root.news_text.txt.autoSize=true;
			//_root.news_back._width=w;
			//_root.news_back._y=h-_root.news_back._height;
			_root.news_count._y=h-_root.news_count._height-12;
			_root.news_count._x=w-_root.news_count._width-37;
			_root.news_dateTime._y=h-_root.news_dateTime._height-4;
			_root.news_dateTime._x=_root.a2._x;
			//_root.grad_right._x=w-_root.grad_right._width;
			//_root.grad_right._y=h-_root.grad_right._height-2;
			_root.news_text._y=h-_root.news_text._height-3;
			//_root.grad_left._y=h-_root.grad_left._height-0.1;
			//_root.grad_up._x=_root.a1._x; _root.grad_up._y=h-26.2; _root.grad_up._width=w-_root.a1._width;
			_root.news._x=_root.a1._x;
		}
		stageListener.onResize = rearrange;
		// add stage listener
		Stage.addListener(stageListener);
		// arange objects on stage
		rearrange();
		//parse the XML file
		XMLRead(XMLFile);
		//assign event handler for text field
		_root.news_text.onRollOver = instance.newsOnRollOver;
		_root.news_text.onRollOut = _root.news_text.onReleaseOutside = instance.newsOnRollOut;
		_root.news_text.onRelease = instance.newsOnRelease;
	}
	
	// this function reads the xml and saves the news to news array
	function XMLRead(fileName) {
		var xml:XML= new XML;
		xml.ignoreWhite=true;
		xml.onLoad = function (success:Boolean) {
			//_root.news_text._y=301;
			if (success) {
				trace("-XML file: "+fileName+" successfully loaded.");
				var mainNode:XMLNode=xml.firstChild.firstChild.firstChild;
				//this will pars "main" node of the XML file
				while (mainNode!=null) {
					mainNode.nodeName.toLowerCase()=="maxcharcount"?instance.maxCharCount=Number(mainNode.firstChild.toString()):false;
					mainNode.nodeName.toLowerCase()=="newstimer"?instance.newsTimer=Number(mainNode.firstChild.toString()):false;
					mainNode.nodeName.toLowerCase()=="textcolor"?instance.textColor=Number(mainNode.firstChild.toString()):false;
					mainNode.nodeName.toLowerCase()=="overcolor"?instance.overColor=Number(mainNode.firstChild.toString()):false;
					mainNode=mainNode.nextSibling;
				}
				var itemsNode:XMLNode=xml.firstChild.firstChild.nextSibling.firstChild;
				//this will pars "items" node of the XML file
				while (itemsNode!=null) {
					mainNode=itemsNode.firstChild;
					var news_object:Object = new Object(); //creates an object
					//this will pars "item" node of the XML file
					while (mainNode!=null) {
						mainNode.nodeName.toLowerCase()=="text"?news_object.text=mainNode.firstChild.toString():false;
						mainNode.nodeName.toLowerCase()=="date"?news_object.date=mainNode.firstChild.toString():false;
						mainNode.nodeName.toLowerCase()=="time"?news_object.time=mainNode.firstChild.toString():false;
						mainNode.nodeName.toLowerCase()=="link"?news_object.link=mainNode.firstChild.toString():false;
						mainNode.nodeName.toLowerCase()=="window"?news_object.window=mainNode.firstChild.toString():false;
						mainNode=mainNode.nextSibling;
					}
					instance.news.push(news_object); //push the object into news array
					itemsNode=itemsNode.nextSibling;
				}
				/*     --------------- DEBUG --------------
						for (var i=0; i<instance.news.length; i++) {
						for (var name in instance.news[i]) {							
							trace("-->" +name+" = "+instance.news[i][name]);
						}
					}
				       ------------------------------------ */
				//set textColor to headline
				var txt_fmt:TextFormat = new TextFormat();
				txt_fmt.color = instance.textColor;
				_root.news_text.txt.setTextFormat(txt_fmt);
				//start to change news
			  	instance.changeNews(true);
			} else {
				trace("Unable to load XML file: "+fileName);
			}
		}
		//load xml file
		xml.load(fileName);
	}
	
	//trim displayed text to macCharCount read from XML file
	function trimToMaxCharCount(txt:String) : String {
		if (txt.length>instance.maxCharCount) {
			return txt.slice(0,instance.maxCharCount-3)+"...";
		} else {
			return txt;
		}
	}
	
	//change news
	function changeNews(ascending:Boolean) {
		//clear all previus intervals that may be active to avoid overlap
		clearInterval(instance.interval); 
		clearInterval(instance.interval2);
		//adjust message counter
		ascending?instance.currentMessage++:instance.currentMessage--;
		if (instance.currentMessage<0) {
			instance.currentMessage=instance.news.length-1;
		} 
		if (instance.currentMessage>=instance.news.length) {
			instance.currentMessage=0;
		}
		//wipe current headline <--- <--- ---> --->
		//<MovieClip|Sound|TextField>.tween(property(ies), ending value(s) [, seconds, animation type, delay, callback, extra1, extra2]);
		_root.news_dateTime.tween("_y",Stage.height,0.5);
		_root.news_text.tween("_y",Stage.height-28-_root.news_text._height,1);
		instance.interval2 = setInterval(function() {
			clearInterval(instance.interval2);
			//insert new headline
			_root.news_dateTime.date.text=instance.news[instance.currentMessage].date;
			_root.news_dateTime.time.text=instance.news[instance.currentMessage].time;
			_root.news_text.txt.text=instance.trimToMaxCharCount(instance.news[instance.currentMessage].text);
			//change format
			var txt_fmt:TextFormat = new TextFormat();
			txt_fmt.color = instance.textColor;
			_root.news_text.txt.setTextFormat(txt_fmt);
			//bring the headline back to its place ---> ---> <--- <---
			_root.news_dateTime.tween("_y",Stage.height-_root.news_dateTime._height-4,0.5,"easeOutQuad");
			_root.news_text.tween("_y",_root.news_text._y+25,0.5,"easeOutQuad");
			//assign url and window to _root.news movie clip so we can find it easier
			_root.news_text.url=instance.news[instance.currentMessage].link;
			_root.news_text.window=instance.news[instance.currentMessage].window;
			//display headline information <3/27>
			_root.news_count.txt.text=(instance.currentMessage+1)+"/"+instance.news.length;
		},500);
		instance.interval=setInterval(instance.changeNews,instance.newsTimer*1000,true);
	}
	
	//news text events ------- STAT -------
	function newsOnRollOver() {
		clearInterval(instance.interval);
		clearInterval(instance.interval2);
		var txt_fmt:TextFormat = new TextFormat();
		txt_fmt.color = instance.overColor;
		_root.news_text.txt.setTextFormat(txt_fmt);
	}
	
	function newsOnRollOut() {
		clearInterval(instance.interval2);
		var txt_fmt:TextFormat = new TextFormat();
		txt_fmt.color = instance.textColor;
		_root.news_text.txt.setTextFormat(txt_fmt);
		instance.interval2=setInterval(function(){clearInterval(instance.interval2);instance.changeNews(true);},1500);
	}
	
	function newsOnRelease() {
		getURL(_root.news_text["url"],_root.news_text["window"]);
	}
	//news text events ------- STOP -------
	
}


Não sei se é problema de _root que tá fazendo isso. A news.swf não é lida na raiz do index.swf, ela é lida 3 níveis acima. Dentro do index.swf temos:

Scene > mcMain > itens > news (aqui aparece o código loadMovie)

Ufaaaa...

Alguém pode me dar uma luz?

Vi algo parecido no fórum mas já mexi várias vezes e não consegui resolver, preciso da ajuda de programador mais avançado.

Obrigado pela atenção.

Abs!

#2 J. Silvério

J. Silvério

    Novato no fórum

  • Usuários
  • 3 posts
  • Sexo:Masculino
  • Localidade:SJK -SP

Posted 15/02/2010, 00:22

Poxa pessoal, nada?
Não sei mais o que fazer pra solucionar. Não rola "fazer na mão" a parte que com XML fica certinho.
Help !

#3 RonsisM

RonsisM

    Super Veterano

  • Usuários
  • 15724 posts
  • Sexo:Masculino
  • Localidade:Plovdiv

Posted 13/09/2017, 10:00

Cialis 10mg Generique cialis Viagra Pfizer Es
Quanto Costa Il Cialis 10 Mg
Apres Clomid J Ai <a href=http://cialtobuy.com>cialis</a> Can You Take Metamucil With Amoxicillin
Buy Propecia Online Us Pharmacy online pharmacy Amoxicillin Hives Duration Costo Del Cialis In Farmacia Viagra Tablets India Lasixpurchase Cheapeast Bentyl Best Website Overseas generic cialis Awc Canadian Pharmacies
Cialis Et Viagra En Ligne buy cialis Propecia Vom Markt
Propecia Farmacia Viagra Comprar Viagra Generic Pay With Paypal
Amoxicillin Breastfeeding <a href=http://cialtobuy.com>cheap cialis</a> Propecia 1 Mg
Amoxicillin Images online pharmacy Viagra On Line No Prescription
Amoxicillin For Childs Ear Infection Propecia 1 De 50
El Viagra Y La Diabetes <a href=http://cialtobuy.com>cheap cialis</a> Acquisto Levitra Bayer

#4 HaroNism

HaroNism

    Super Veterano

  • Usuários
  • 15385 posts
  • Sexo:Masculino
  • Localidade:San Miguel de Tucuman

Posted 13/09/2017, 20:49

Comprar Pastillas Cialis cialis price Prograf Dermatologue Propecia Mail Order Levitra Viapro Without Prescription cialis Kamagra Kaufen Schweiz
Us Generic For Propecia cialis Canada Kamagra
Help To Purchase Plavix Duree Efficacite Viagra
Viagra Prezzo Basso <a href=http://cialtobuy.com>cialis price</a> Cialis Generique Quebec

#5 RonsisM

RonsisM

    Super Veterano

  • Usuários
  • 15724 posts
  • Sexo:Masculino
  • Localidade:Plovdiv

Posted 01/10/2017, 22:28

Mail Order Stendra Internet Cod Only Next Day Delivery Cialis Generico 5 Mg viagra Cialis Senza Ricetta Dove Comprar Viagra Original Barcelona
Gen Health Levitra Is There A Way To Get Cialis Overnight Buy Real Viagra Online best site to buy levitra Legally Finasteride Amex Accepted

#6 HaroNism

HaroNism

    Super Veterano

  • Usuários
  • 15385 posts
  • Sexo:Masculino
  • Localidade:San Miguel de Tucuman

Posted 02/10/2017, 05:35

Viagra Prices Usa Dosage Amount For Amoxicillin For Uti vardenafil in osterreich erhaltlich Viagra Ansiolitico Per Giovani Vente De Kamagra
Cialis E Birra Amoxicillin Buy Uk Cialis Arzt how to buy levitra in usa Viagra Generika Scilla
Generico De Propecia Action Of Amoxicillin In Leukemic Condition viagra Buy Now Fedex Real Progesterone C.O.D. Without Rx

#7 RonsisM

RonsisM

    Super Veterano

  • Usuários
  • 15724 posts
  • Sexo:Masculino
  • Localidade:Plovdiv

Posted 11/10/2017, 06:42

Amoxicillin Abnormal Dreams buy viagra Generic Levitra Soft Tabs
Amoxicillin Vs Ampicillin Vente Ciprofloxacin Generique viagra Asthmahaler Mist Cod Only Bentyl Direct Us

#8 RonsisM

RonsisM

    Super Veterano

  • Usuários
  • 15724 posts
  • Sexo:Masculino
  • Localidade:Plovdiv

Posted 28/10/2017, 09:42

Finasteride 5 Mg Online Cheap Buy Tinidazole Online eva pills levitra Nolvadex Dosage For Epistane Keflex For Gum Infection Comprar Cialis En Canada
Buy Viagra With Mastercard Costco Propecia Buy Phenergan Overnight Deliery viagra Amoxil Needs Refrigeration No Prescription Pharmacy Keflex Buy Effexor Online Canada
Estrace .5 cialis price Propecia Works Men Propecia Und Viagra Amoxicillin Dosing Children Otitis Media

#9 RonsisM

RonsisM

    Super Veterano

  • Usuários
  • 15724 posts
  • Sexo:Masculino
  • Localidade:Plovdiv

Posted 12/11/2017, 15:45

Xenical 120mg No Prescription viagra Sertraline Of Shore
Buy Zyban 150 Without A Script viagra online prescription 40mg Cialis Viagra Online Alicante
Antibiotics For Herpes Amoxicillin Bystolic Online Pharmacy viagra Reputable Online Levitra Buying Cheap Cialis Online Alternative Viagra Products




1 user(s) are reading this topic

0 membro(s), 1 visitante(s) e 0 membros anônimo(s)

IPB Skin By Virteq