Solved

Pass a Variable INTO Xml

Posted on 2010-09-07
3
392 Views
Last Modified: 2012-05-10
I have an ActionScript in Flash and an XML file that are working together.

I've set up my variables and such, and then I want to loop through them and add something to each "record." So I can do something like this:

for each (var object:XML in xml.*) {

                  object.appendChild(<myId>my id is here</myId>);
                  trace(object);
      }

That will add a new line in each item like so:
<myId>my id is here</myId>

Now, I obviously don't want to write "my id is here" as the value between the <myId> tags. The problem is I want to do something using a foruma or method or something to get a unique value there.

For example,  I'd like to do something like this...

object.appendChild(<myId>object.childIndex()</myId>);


...where the theory is that it returns the child index number of the object, so the fist item  would be appended with <myId>0</myId> and the second would be <myId>1</myId> and the third would be <myId>2</myId> and so on and so forth.

The problem is that it's writing everything as a string. It's actually writing out <myId>object.childIndex()</myId> for all of them,

I even tried doing something in ActionScript first, where I'd go:

var i;

and then push a value into the i variable via an incremental loop and then I would try

object.appendChild(<myId>i</myId>);

But, again, it just writes in "i" and not the value of i.

I need a way to say, "Calculate this part between the brackets."

Can anyone help? Is it possible? Is there another way around it?
0
Comment
Question by:caf210
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 8

Accepted Solution

by:
ActionScript_Helper earned 500 total points
ID: 33624989
Here's an sample, it will append the new node. But see how we are concatenating string and variable.
---------------
var node:XMLList = new XMLList("<myId>" + i + "</myId>");
object.appendChild(node);

-------
0
 

Author Comment

by:caf210
ID: 33628622
ActionScript_Helper,

Yup, that's it. Exactly what I need.

Thank you much! I will accept as the solution and award the points.
0
 

Author Closing Comment

by:caf210
ID: 33628626
Great job.
0

Featured Post

Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

While working over numerous projects I often had the requirement for doing a screen capture in AS3.0. Unfortunately I found no "ready made" solutions in google search that suited my requirements. But I did come across some great resources which help…
The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question