FORUMS: list search recent posts

XML content in Flash

COW Forums : Adobe Flash

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Chip Johns
XML content in Flash
on Apr 12, 2010 at 7:33:50 pm

Hi All,

Requesting a little help please! - AS3

I'm trying to load content from an XML Document into a Flash Presentation.

My AS is in the top layer. This layer spand the entire document.

Layer two is set up with keyframes every 10 frames. Each keyframe has a text box on it. I am trying to load the xml into each of these frames. Here is what I have in the AS Layer.


var req:URLRequest = new URLRequest("xml/content.xml");
var loader:URLLoader = new URLLoader();
var xmlContent:XML;

function xmlLoaded(event:Event):void
{
xmlContent = new XML(loader.data);
txt_myTextBox1.text = xmlContent.slideEvent.slideTitle[0]
txt_myTextBox2.text = xmlContent.slideEvent.slideTitle[1]
}

loader.addEventListener(Event.COMPLETE, xmlLoaded);
loader.load(req);


The content shows in the first text box on the first frame, When the playhead hits the second keyframe at frame 10 the xml isn't loaded in that text box.

The text box instance names reflect what is in the code. When I put both text boxes on frame 1, the content shows..!

What do I need to do to get the content to load in each text box?

Thanks for any direction..

--
Chip Johns


Return to posts index

Adam Ashby
Re: XML content in Flash
on Apr 12, 2010 at 10:03:33 pm

Your instance needs to exist in the same frame as the AS referring to it, or else the AS doesn't know what its referring to. I tend to keep my main timeline only one frame long if I can, with animations either actionscript based or nested with a MovieClip. If its necessary that you use multiple frames, have all instances on frame 1 and set their visibility to true or false where needed.

Adam Ashby
mutli-media artist
http://www.adamashby.com


Return to posts index

Chip Johns
Re: XML content in Flash
on Apr 17, 2010 at 11:02:40 am

Thanks Adam. Your explanation helped me get on the road to success. Q:-)

Probably not the cleanest code developed, but, I got it to work.

Appreciate the assistance.

--
Chip Johns


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2018 CreativeCOW.net All Rights Reserved
[TOP]