How do I call variables into Flash by removing existing XML calls?

Posted on 2007-11-19
Last Modified: 2008-02-07
We have a flash audio player that currently uses an XML file to bring in data (audio path, image location, title) for the audio file.  Rather than having one XML file for each audio file (we have a lot), I'd like to pull the details of each audio file (by PHP) through the URL string.

With PHP I can pull the following variables into the actionscript, but I dont know what elements of the XML to replace?

var projectaudio:String;
var projecttitle:String;
var projectimage:String;

Below is the current actionscript and XML:

Here is the current actionscript:

_root.playlist == undefined ? playlist = "mp3player.xml" : playlist=_root.playlist;

// stage variables

Stage.showMenu = false;

Stage.scaleMode = "noScale";


// player variables

volume = 100;

current_audio = 1;


// playlist loading

data_xml = new XML();

data_xml.ignoreWhite = true;

data_xml.onLoad = loadData;


// parsing all xml data into flash

function loadData(success) {

	if (success) {

		imgloc = this.firstChild.attributes.imgloc;

		// showdisplay and playlist toggles

		if (this.firstChild.attributes.showTime != "yes"){

			top.timecomponent._visible = 0;


		showDisplay = this.firstChild.attributes.showDisplay;

		if (showDisplay == "yes") {


			topup = false;

			display_btn._rotation+=180; }

		showPlaylist = this.firstChild.attributes.showPlaylist;

		if (showPlaylist == "yes") {


			botup = false;

			list_btn._rotation+=180; }

		// getting all titles and filenames

		aPath = new Array();

		audioTitel = new Array();

		audioTracks = new Array();


		audioTracks = this.firstChild.childNodes;

		audio_total = audioTracks.length;		

		for (var i = 0; i<audio_total; i++) {



			// buiding playlist buttons

			bot.playlist.btn.duplicateMovieClip("btn"+i, i);

			bot.playlist["btn"+i]._y = bot.playlist.btn._y+i*int(bot.playlist.btn._height) +i;

			bot.playlist["btn"+i].txt = checkDigits(i+1)+". "+audioTitel[i];

			bot.playlist["btn"+i].hit.onPress = function() {

				listClick(this._parent.getDepth()+1); }; 


		//checking autostart mode

		autoStart = this.firstChild.attributes.autoStart;

		if (autoStart == "yes") {


			play_btn._visible = 0;

		} else if (autoStart == "no") {

			play_btn._visible = 1;

			pause_btn._visible = 0;

		} else if (autoStart == "random") {

			current_audio = random(audio_total)+1;


			play_btn._visible = 0;

		} else {

			current_audio = int(this.firstChild.attributes.autoStart);


			play_btn._visible = 0; } }

	// done ! all loaded succesfully. purging trash

	//load company image



	delete audioTracks;

	delete data_xml;}

Here is the XML file:

<?xml version="1.0" encoding="UTF-8"?>

<player showTime="no" autoStart="yes" imgloc="testing.jpg">

    <audio path="" title="Testing Audio" />



Open in new window

Question by:citegirl
1 Comment
LVL 20

Accepted Solution

steelseth12 earned 500 total points
ID: 20314723
Why not have the php file generate the xml data. This way you have alot more flexibility then passing the variables through the url

_root.playlist == undefined ? playlist = "mp3player.php" : playlist=_root.playlist;

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The goal of the tutorial is to teach the user how to set there setting in Adobe Flash Media Live Encoder and YouTube for optimal video and audio quality.
The goal of the tutorial is to teach the user how to select which audio input to use. Once you have an audio input plugged into the laptop or computer, you will go into the audio input settings and choose which audio input you want to use.

705 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now