Re: Quickie for xml dynamic text loader in flash
Radley Marx <[email protected]> Sat, 20 Oct 2007 11:01:16 -0700
| Newsgroups | gmane.comp.web.flashcoders.devel |
|---|---|
| Message-ID | <[email protected]> |
Unless there's a significant reason for needing separate XML files
for each... keyframe(?)... you can put them all together much more
easily and load everything from the beginning into an array of
objects. This way you only have to refer to local storage and not
have to call to the server over and over for each... uh... keyframe...
<news>
<article xmlns="http://www.#.com">
<date>June, 22 2008</date>
<title>Article 1</title>
<content><![CDATA[The first manned mission to Mars...]]></content>
</article>
<article xmlns="http://www.#.com">
<date>June, 24 2008</date>
<title>Article 2</title>
<content><![CDATA[The second manned mission to Mars...]]></content>
</article>
<article xmlns="http://www.#.com">
<date>June, 29 2008</date>
<title>Article 3</title>
<content><![CDATA[The third manned mission to Mars...]]></content>
</article>
</news>
Not sure why you're using keyframes for each. You can keep the same
textFields, and just update them.
Last tip: your news articles in the XML don't need to be news1,
news2, news3. If you put them in an array you'll have news_array
[0].title, news_array[1].title and so on.
-radley
> <?xml version="1.0" encoding="UTF-8" standalone="no"?>
> <news xmlns="http://www.#.com"><newsDate xmlns="">June 29,
> 2008</newsDate><newsTitle xmlns="">First manned mission to Mars
> lands</newsTitle><newsContent xmlns="">The first manned mission to
> Mars has
> touched down on the surface of the red planet. After six months of
> space
> travel, the five astronauts on board MarsEx 1 will finally
> experience an end
> to their weightless conditions.</newsContent></news>
On Oct 19, 2007, at 11:11 AM, Eric Walton wrote:
> Hello All,
>
>
> Quick question about an xml file I am loading into a dynamic text box.
>
> K, I have a dynamic text box/area that loads a simple xml file
> using the
> following:
>
> var RootNode:XMLNode;
> var myXML:XML = new XML();
> myXML.ignoreWhite = true;
> myXML.onLoad = loadNews;
> myXML.load("xmlnews1/newsData.xml");
> function loadNews(success:Boolean):Void {
> if (success) {
> RootNode = this.firstChild;
> var content_str:String = ""+RootNode.childNodes[1].firstChild;
> content_str +=" ("+RootNode.childNodes[0].firstChild;
> content_str += ")" + RootNode.childNodes[2].firstChild;
> news_txt.text = content_str;
> }
> }
>
> OK, That works splendidly. Below is the xml file.
>
> <?xml version="1.0" encoding="UTF-8" standalone="no"?>
> <news xmlns="http://www.#.com"><newsDate xmlns="">June 29,
> 2008</newsDate><newsTitle xmlns="">First manned mission to Mars
> lands</newsTitle><newsContent xmlns="">The first manned mission to
> Mars has
> touched down on the surface of the red planet. After six months of
> space
> travel, the five astronauts on board MarsEx 1 will finally
> experience an end
> to their weightless conditions.</newsContent></news>
>
> What I need to do is use the same xml file on numerous keyframes
> but have each frame contain different text.
>
> So could I do this?
>
> <?xml version="1.0" encoding="UTF-8" standalone="no"?>
> <news xmlns="http://www.#.com"><newsDate xmlns="">June 30,
> 2008</newsDate><newsTitle xmlns="">First manned mission to Mars
> lands</newsTitle><newsContent xmlns="">The first manned mission to
> Mars has
> touched down on the surface of the red planet. After six months of
> space
> travel, the five astronauts on board MarsEx 1 will finally
> experience an end
> to their weightless conditions.</newsContent>
> </news>
>
> *added to xml file for second keyframe
>
> <news1 xmlns="http://www.#.com"><newsDate xmlns="">June 31,
> 2008</newsDate><newsTitle1 xmlns="">Second Story
> Title</newsTitle><newsContent1 xmlns="">Here is the second story full
> text</newsContent1>
> </news1>
>
> *added to xml file for third keyframe
>
> <news2 xmlns="http://www.#.com"><newsDate xmlns="">June 32,
> 2008</newsDate><newsTitle2 xmlns="">Third Story
> Title</newsTitle><newsContent2 xmlns="">Here is the third story full
> text</newsContent1>
> </news2>
>
>
> Also I am thinking I will need something in each keyframe to call
> the specific text section of the xml file.
>
> *Note*
> In the beginning I had/have a dynamic text box on each keframe and
> each was
> calling a seperate xml doc.
> this way I will have only ONE xml file to edit for all the
> keyframes instead
> of 80! I am really enjoying the
> difficulty of this task.
>
> Hope someone can help.
> Much love,
>
>
>
> Eric Walton 9 / Edub9
>
> To view more about
> The Artwork of Eric Walton 9 / Edub9
> please visit the following:
> www.HollywoodFineART.com
> www.Myspace.com/ericwalton9_edub9
> Providentia Marketing LLC
> _______________________________________________
> Flashcoders mailing list
> [email protected]
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
------------------------------------------------------------------------
------
Radley Marx
www.radleymarx.com
[email protected]
------------------------------------------------------------------------
------
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders