Be a Supporter!

acess xml data in button

  • 162 Views
  • 12 Replies
New Topic Respond to this Topic
A-Genius
A-Genius
  • Member since: Mar. 20, 2010
  • Offline.
Forum Stats
Member
Level 06
Blank Slate
acess xml data in button 2013-11-06 11:23:48 Reply

The problem is that I can't access the xml data within the mouse function!
how do I declare it for a button function?

function nexth(e:Event):void{
var myXML= new XML(e.target.data); 

/*This Code Provide This Error:
ReferenceError: Error #1069: Property data not found on flash.display.SimpleButton and there is no default value.
	at rooms_info/nexth()*/
.
.
.

also when I use: e.target.data rather than new XML it still give me the error when I use the code for this code!
how do I declare it for a button function if I am here?

location_txt.text="Location: " +e.target.data.ROOM[j].@LOC;

/*This Code Provide This Error:
ReferenceError: Error #1069: Property data not found on flash.display.SimpleButton and there is no default value.
	at rooms_info/nexth()*/
milchreis
milchreis
  • Member since: Jan. 11, 2008
  • Offline.
Forum Stats
Member
Level 26
Programmer
Response to acess xml data in button 2013-11-06 11:48:57 Reply

The Mouse click causes a MouseEvent.
The Event has nothing to do with any xml whatsoever.

That's what the error says in clear English.

How to solve this:
Don't copy and paste code mindlessly. It doesn't make any sense to request data from a button.

Explain your goal. What is this xml? What is this button supposed to do?

MSGhero
MSGhero
  • Member since: Dec. 15, 2010
  • Online!
Forum Stats
Supporter
Level 16
Game Developer
Response to acess xml data in button 2013-11-06 11:53:24 Reply

E.target is the thing you clicked, and displayobjects don't have a data property. If you extended sprite and that class has a data property which holds the XML, then cast e.target, but I doubt this is the case since the code would work anyway.

A-Genius
A-Genius
  • Member since: Mar. 20, 2010
  • Offline.
Forum Stats
Member
Level 06
Blank Slate
Response to acess xml data in button 2013-11-06 11:58:14 Reply

At 11/6/13 11:48 AM, milchreis wrote: Explain your goal. What is this xml? What is this button supposed to do?

I need 2 things to declare

This variable:

var myXML = new XML(e.target.data);

to retrieve the data from the XML File Inside a mouse function

add my XML inside my textField when the button is pressed!

location_txt.text="Location: " + myXML.ROOM[j].@LOC;

I hope you understand what I want to achieve here!

A-Genius
A-Genius
  • Member since: Mar. 20, 2010
  • Offline.
Forum Stats
Member
Level 06
Blank Slate
Response to acess xml data in button 2013-11-06 12:00:04 Reply

At 11/6/13 11:53 AM, MSGhero wrote: E.target is the thing you clicked, and displayobjects don't have a data property. If you extended sprite and that class has a data property which holds the XML, then cast e.target, but I doubt this is the case since the code would work anyway.

could you explain that using code example >.>?

MSGhero
MSGhero
  • Member since: Dec. 15, 2010
  • Online!
Forum Stats
Supporter
Level 16
Game Developer
Response to acess xml data in button 2013-11-06 13:12:12 Reply

At 11/6/13 11:58 AM, A-Genius wrote: I hope you understand what I want to achieve here!

Tell us what you think e.target.data is. Is it a string? A class name? An XML object?

A-Genius
A-Genius
  • Member since: Mar. 20, 2010
  • Offline.
Forum Stats
Member
Level 06
Blank Slate
Response to acess xml data in button 2013-11-06 13:38:25 Reply

At 11/6/13 01:12 PM, MSGhero wrote:
At 11/6/13 11:58 AM, A-Genius wrote: I hope you understand what I want to achieve here!
Tell us what you think e.target.data is. Is it a string? A class name? An XML object?

the holder of XML data ? :P

A-Genius
A-Genius
  • Member since: Mar. 20, 2010
  • Offline.
Forum Stats
Member
Level 06
Blank Slate
Response to acess xml data in button 2013-11-06 13:44:43 Reply

At 11/6/13 01:38 PM, A-Genius wrote:
At 11/6/13 01:12 PM, MSGhero wrote:
At 11/6/13 11:58 AM, A-Genius wrote: I hope you understand what I want to achieve here!
Tell us what you think e.target.data is. Is it a string? A class name? An XML object?
the holder of XML data ? :P

am I right?

because that what I meant when I used:
var myXML = new XML(e.target.data);

it seems that it only works in EventListener for the loader!

kkots
kkots
  • Member since: Apr. 16, 2013
  • Offline.
Forum Stats
Supporter
Level 10
Blank Slate
Response to acess xml data in button 2013-11-06 13:59:57 Reply

Are you loading an XML from some URL or do you have it embedded into the SWF using metatags in Flex/FlashDevelop?!!


BBS Signature
A-Genius
A-Genius
  • Member since: Mar. 20, 2010
  • Offline.
Forum Stats
Member
Level 06
Blank Slate
Response to acess xml data in button 2013-11-06 14:15:21 Reply

At 11/6/13 01:59 PM, kkots wrote: Are you loading an XML from some URL or do you have it embedded into the SWF using metatags in Flex/FlashDevelop?!!

I am using URLLoader and my XML file Contain tags!

kkots
kkots
  • Member since: Apr. 16, 2013
  • Offline.
Forum Stats
Supporter
Level 10
Blank Slate
Response to acess xml data in button 2013-11-06 14:20:44 Reply

At 11/6/13 02:15 PM, A-Genius wrote: I am using URLLoader and my XML file Contain tags!

*BOOMHEADSHOT*
Adobe Flash Platform * Reading external XML documents

Documentation taken from the Official Adobe ActionScript 3.0 Documentation


BBS Signature
A-Genius
A-Genius
  • Member since: Mar. 20, 2010
  • Offline.
Forum Stats
Member
Level 06
Blank Slate
Response to acess xml data in button 2013-11-06 14:27:11 Reply

At 11/6/13 02:20 PM, kkots wrote:
At 11/6/13 02:15 PM, A-Genius wrote: I am using URLLoader and my XML file Contain tags!
*BOOMHEADSHOT*
Adobe Flash Platform * Reading external XML documents

Documentation taken from the Official Adobe ActionScript 3.0 Documentation

That does not ignore the fact that I can't find the right code if it's inside mouse event! X.X

A-Genius
A-Genius
  • Member since: Mar. 20, 2010
  • Offline.
Forum Stats
Member
Level 06
Blank Slate
Response to acess xml data in button 2013-11-06 14:51:36 Reply

FIXED THE STUPID PROBLEM!!!!

var myXML= new XML(XMLLoader.data);

that's the correct code!