Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 10-21-2009, 01:16 PM   #1
mmdguru
Member
 
mmdguru's Avatar
 
Join Date: May 2008
Location: Oslo
Posts: 84
Send a message via MSN to mmdguru Send a message via Skype™ to mmdguru
Default display XML data

Hi flashers,

I have an XML response that goes like this:

Code:
<vervelst>
> 	<vervet>
> 		<id>10456</id>
> 		<fornavn></fornavn>
> 		<etternavn></etternavn>
> 		<epost>[email protected]</epost>
> 		<mobil>[email protected]</mobil>
> 		<samtykkeepost>0</samtykkeepost>
> 		<samtykkekonkurranse>0</samtykkekonkurranse>
> 		<status>2</status>
> 	</vervet>
> 	<vervet>
> 		<id>10464</id>
> 		<fornavn>Rune</fornavn>
> 		<etternavn>Helge</etternavn>
> 		<epost>[email protected]</epost>
> 		<mobil>[email protected]</mobil>
> 		<samtykkeepost>0</samtykkeepost>
> 		<samtykkekonkurranse>1</samtykkekonkurranse>
> 		<status>1</status>
> 	</vervet>
> </vervelst>
With my code I can trace out what is important to me, that's the status and epost nodes!

I want to load this data into a movieclip with two textfields(status and epost) in flash. The problem is that I need to add movieclips dynamically equal to the length of my XML file. The XML can contain hundreds of <vervet> nodes! This is being added from a database through asp=)

Any ideas guys?? All help is greatly appreciated!

My Code so far:

ActionScript Code:
package {     import flash.display.Sprite;     import flash.events.*;     import flash.net.*;     public class Status extends Sprite {         public var qs:QueryString = new QueryString();         public var id:int=10007;//qs.parameters.id;         public function Status() {             var scriptURL:URLRequest=new URLRequest("http://connectorretail.com/dn/fame/hentstatus.asp");             scriptURL.method=URLRequestMethod.POST;             var postVars:URLVariables = new URLVariables();             postVars.id=id;             scriptURL.data=postVars;             var scriptLoader:URLLoader = new URLLoader();             scriptLoader.addEventListener(Event.COMPLETE, scriptDoneLoading);             scriptLoader.load(scriptURL);         }         function scriptDoneLoading(evt:Event):void {             var responseXML:XML=new XML(evt.target.data);             parseData(responseXML);         }         function parseData(xmlOutput:XML):void {             trace("XML Output");             trace("------------------------");             trace(xmlOutput.vervet.epost);             trace(xmlOutput.vervet.status)         }     } }


As you can see, I can trace the "epost" and "status"! I just need to represent this data into flash=)

Last edited by mmdguru; 10-21-2009 at 01:18 PM.
mmdguru is offline   Reply With Quote
Old 10-21-2009, 02:05 PM   #2
mcandw
Registered User
 
Join Date: Oct 2008
Posts: 19
Default

Not quite sure what you're trying to accomplish.

Don't you just want to traverse the XML graph (see http://www.adobe.com/support/flash/a...ionary827.html) and create a new MovieClip object for each record??
mcandw is offline   Reply With Quote
Old 10-21-2009, 04:49 PM   #3
mmdguru
Member
 
mmdguru's Avatar
 
Join Date: May 2008
Location: Oslo
Posts: 84
Send a message via MSN to mmdguru Send a message via Skype™ to mmdguru
Default

I just want to display my xml data in flash! load the "epost" and "status" into dynamic textfields...

These textfields can be inside a movieclip. So I want to add a movieclip for each xml node.

Any ideas??
mmdguru is offline   Reply With Quote
Old 10-22-2009, 10:57 AM   #4
mmdguru
Member
 
mmdguru's Avatar
 
Join Date: May 2008
Location: Oslo
Posts: 84
Send a message via MSN to mmdguru Send a message via Skype™ to mmdguru
Default

Ive managed to create the amount of movieclips that are equal to the length of my epost node in my xml document...the moveclip is called statusMC!

I need to load the epost node inside a text field in my movieclip...

How do I do that?? Please help?

All help is greatly appreciated!!

My code:
ActionScript Code:
package {     import flash.display.Sprite;     import flash.events.*;     import flash.net.*;     public class Status extends Sprite {         private var statusMC:StatusMC;         public var qs:QueryString=new QueryString  ;         public var id:int=10007;//qs.parameters.id;         public function Status() {             var scriptURL:URLRequest=new URLRequest("http://connectorretail.com/dn/fame/hentstatus.asp");             scriptURL.method=URLRequestMethod.POST;             var postVars:URLVariables=new URLVariables  ;             postVars.id=id;             scriptURL.data=postVars;             var scriptLoader:URLLoader=new URLLoader  ;             scriptLoader.addEventListener(Event.COMPLETE,scriptDoneLoading);             scriptLoader.load(scriptURL);         }         function scriptDoneLoading(evt:Event):void {             var responseXML:XML=new XML(evt.target.data);             parseData(responseXML);         }         function parseData(xmlOutput:XML):void {             trace("XML Output");             trace("------------------------");             trace(xmlOutput.vervet.epost);             trace(xmlOutput.vervet.status);             var epostList:XMLList=xmlOutput.vervet.epost;             for (var i:int=0; i<epostList.length(); i++) {                 var epostElement:XML=epostList[i];                                 statusMC = new StatusMC();                 statusMC.x = 40;                 statusMC.y = 60+(i*50);                 addChild(statusMC);                                 trace(epostElement);             }         }     } }
mmdguru is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 04:30 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.