Home Tutorials Forums Articles Blogs Movies Library Employment Press

Go Back   ActionScript.org Forums > ActionScript Forums Group > ActionScript 3.0

Reply
 
Thread Tools Rate Thread Display Modes
Old 01-12-2008, 08:48 AM   #1
balaji.r
Registered User
 
Join Date: Jan 2008
Posts: 5
Default How to return the XML data from function.

hi,
I am new to ActionScript. i need help from you. how to return and get the xml Data from function. this is my coding.

package {

import flash.events.*;
import flash.net.*;
import fl.data.DataProvider;

public class LoadXml
{
static var xmlData:XML =new XML();

public function LoadXmlFn():XML
{
var xmlLoader:URLLoader = new URLLoader();
xmlLoader.load(new URLRequest("DomainDetail.xml"));
xmlData=xmlLoader.addEventListener(Event.COMPLETE, LoadedXML);
return xmlData;
}

public function LoadedXML(e:Event):XML
{
xmlData = new XML(e.target.data);
return xmlData;
}
}
}

Please help me..
Advance thanks.
balaji.r is offline   Reply With Quote
Old 01-12-2008, 01:23 PM   #2
springframework
Senior Member
 
Join Date: Mar 2006
Posts: 470
Default

this code is very very wrong:

public function LoadXmlFn():XML
{
var xmlLoader:URLLoader = new URLLoader();
xmlLoader.load(new URLRequest("DomainDetail.xml"));
xmlData=xmlLoader.addEventListener(Event.COMPLETE, LoadedXML);
return xmlData;
}


basically you can't do what you are wanting to do here. there are many many ways to pass data. while returning a value from a function is a valid way of passing data, you are either going to get an error or this function will return null.

this isnt an actionscript question, this is a basic object oriented programming question. i think you need to read a book on Object-Oriented Programming.

there are so many ways to do what you are trying to do. i do not wish to tell you one way and make u believe its the only way. the best help i could give you is to tell you to go to school or read a few books before you try to write anymore actionscript code.




Jesse Couch Vancouver Canada Actionscript 3.0
springframework is offline   Reply With Quote
Old 01-12-2008, 10:17 PM   #3
Dail
noponies
 
Join Date: Sep 2007
Location: New Zealand
Posts: 221
Send a message via ICQ to Dail Send a message via AIM to Dail
Default

As an external .as file;

ActionScript Code:
package {     import flash.events.*;     import flash.net.URLRequest;     import flash.net.URLLoader;     public class loadXml extends EventDispatcher {         public var myXML:XML;         private var myXLoader:URLLoader;         private var myXMLURL:URLRequest;         private var XML_URL:String;         public function loadXml(url:String) {             myXML = new XML();             XML_URL = url;             myXMLURL = new URLRequest(XML_URL);             myXLoader = new URLLoader(myXMLURL);             myXLoader.addEventListener(Event.COMPLETE, completeHandler);             myXLoader.addEventListener(IOErrorEvent.IO_ERROR, handleError);         }         private function completeHandler(e:Event):void {             myXML = XML(e.target.data);             dispatchEvent(new Event("xmlParsed"));         }         private function handleError(event:IOErrorEvent):void {             trace("Error loading XML");         }     } }

IN your .fla or other class...

ActionScript Code:
/*load in xml via call to external xml parsing class*/             var getXML:loadXml = new loadXml("menu.xml");             getXML.addEventListener("xmlParsed", checkLoad);             //call back function for xml loading             function checkLoad(evt:Event):void {                 //access your XML             }
Dail 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

Similar Threads
Thread Thread Starter Forum Replies Last Post
help with getting xml data into a tricky function function thamera ActionScript 2.0 0 10-29-2007 03:44 AM
function to return value after loading data nawtwrong ActionScript 2.0 2 10-10-2007 03:41 PM
Video Smoothing agent-vip ActionScript 2.0 0 05-08-2007 12:21 AM
Ease parameter Clutchplate Simple Stuff (Newbies) 8 03-16-2007 11:21 AM
Issues with setMask Gillies ActionScript 2.0 1 02-28-2007 07:22 AM


All times are GMT. The time now is 10:28 AM.

///
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.