FORUMS: list search recent posts

xml flv player with dynamic text box

COW Forums : Adobe Flash

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
mike simpson
xml flv player with dynamic text box
on Apr 7, 2008 at 7:59:48 pm

i know this is covered in the forum and believe me, i have tried to follow other posts through to get my version working but i can't seem to figure it out.

I have the XML flv player working with a list that is populated via my external XML file.
I have a text box on the stage currently with an instance name of "caption" (because i was following a tutorial and wanted to make sure i did things right!) but i can't seem to get the info from the XML to this text field.

My external XML file has 3 attributes, namely: URL, desc and caption.

I am not good at flash at all but thanks to Lee Brimlow i have managed to get this far by basically copying his tutorials...and they are brilliant..thanks Lee.

I have tried to trace various things but don't really understand it. I do see that my captionArray seems to be undefined and have at times managed to get the text "undefined" into the text box on the stage but thats not right!

Below is my script as it stands:

// create a netConnection object
var nc:NetConnection = new NetConnection();
// connect to null
// create netStream object
// and pass the netConnect to it
var ns:NetStream = new NetStream(nc);
// attach the netStream object to the embedded video object
// netSTream object plays the video"GDOP Loop.flv");

// code for control buttons
// rewind button takes the play head to beginning
rewind_btn.onRelease = function() {
// send the playhead to 0 seconds;
// play button
play_btn.onRelease = function() {
// toggle between pause and play

// control the laoder bar
var videoInterval = setInterval(videoStatus, 100);
var amountLoaded:Number;
var duration:Number;

ns["onMetaData"] = function (obj) {
duration = obj.duration;

function videoStatus() {
amountLoaded = ns.bytesLoaded/ns.bytesTotal;
loader.loadbar._width = amountLoaded*220;
loader.scrub._x = ns.time/duration*220;


// add var for text box here
var captionIndex:Number = videoList.selectedIndex;

// setting up the on press event for scrub bar
var scrubInterval;

loader.scrub.onPress = function() {
scrubInterval = setInterval(scrubit, 10);


//setting up the release event for scrub bar

loader.scrub.onRelease = loader.scrub.onReleaseOutside=function () {
videoInterval = setInterval(videoStatus, 100);

function scrubit() {*duration));
// xml playlist
// create an XMl object
var vidList:XML = new XML();
// ignore white spaces
vidList.ignoreWhite = true;
var captions:Array = new Array ();

vidList.onLoad = function() {
// put the nodes of xml into array
var videoArray:Array = this.firstChild.childNodes;
// iterate through video array
// and add videos to the listbox
for (i = 0;i // captions.addItem(videoArray[i].attributes.caption);

// captions push(this.attribute.caption);
// var captions:videoArray[i].attributes.caption
// }


// when xml is loaded play first item;
// highlight first video in listbox
videoList.selectedIndex = 0;
// new line for text_txt
caption.text = captionsArray[0];

// create a listener that responds
// to changes in the listbox

var vidListener:Object = new Object();
vidListener.change = function() {
// play the item selected in listbox;
captionIndex = videoList.selectedIndex;
// caption.text =20;
caption.text = captionArray[captionIndex];

// register the event listener to listbox
// load xml file
// trace(videoList.selectedIndex);
// end of code.

Currently this puts the text undefined onto the stage so i guess that means i am trying to get the text to populate the correct field but i am unable to actually pass the information from the XML to this field.
I'm sure htis must be a simple thing to correct for someone who knows what they are looking for.
I look forward to learning from anyone that is able to help me out...and would be honored if Lee himself answered my plea!

Thanks in advance,


Return to posts index

mike simpson
Re: xml flv player with dynamic text box
on Apr 7, 2008 at 9:59:33 pm

Crikey...that was a long post. (I didn't preview it.)

I've actually managed to sort it already with a bit more playing around.
I'm quite impressed with myself as i've been trying to sort it for a few days on and off.

If anyone is interested at all i can post my acstionscript incase it helps anyone with the same problem.
Now i have another question:

Is it possible to get HTML text into these same text boxes via the XML?

i understand that i cannot just type the html as it would normally appear as XML sees the tags as different "functions" to use a non programmers way of saying things.

i've seen people mention [CDATA] tags or something but i've not found a concise answer or tutorial as yet.

Thanks again all.


Return to posts index

Brian Mills
Re: xml flv player with dynamic text box
on Apr 9, 2008 at 2:19:35 pm

yes you can do HTML text....make sure your text instance on the stage is set to html text...its a button on the property inspector...and make sure in your AS that the caption.text is set to caption.htmlText

then in the "captions" sections in your XML file put the CDATA tag

"2008 Silver Addy
Greater Dayton Advertising Association
Media Production Group New Years e-card]]>

hope that helps at all...

Return to posts index

Brian Mills
Re: xml flv player with dynamic text box
on Apr 9, 2008 at 2:35:04 pm

crap....not sure how to show the xml code...keeps disappearing...if i figure that out i can show ya

Return to posts index

Brian Mills
Re: xml flv player with dynamic text box
on Apr 9, 2008 at 6:25:29 pm

Return to posts index

mike simpson
Re: xml flv player with dynamic text box
on Apr 9, 2008 at 7:46:04 pm

Thanks Brian,

i'll check out the links.
I have obviously never used CDATA tags etc before so looking forward to learning.


Return to posts index

mike simpson
Re: xml flv player with dynamic text box
on Apr 10, 2008 at 12:00:23 am

I had a look at the link and tried a couple of things but couldn't get the html text to fact everything i tried broke my text box!

What i would like to achieve is having html links within the text box as well as just plain text information form my external XML file.

I would be most grateful if you, or anyone else for that matter, could expand on how i could go about this.

I tried putting the CDATA tags in my xml but it went wrong!

Thanks once again for any help


Return to posts index

Brian Mills
Re: xml flv player with dynamic text box
on Apr 10, 2008 at 2:02:29 pm

email me your XML file and Ill take a look at not an expert by any means...but ill see if there is anything that needs changed

Return to posts index

mike simpson
Re: xml flv player with dynamic text box
on Apr 13, 2008 at 3:57:49 pm


so after a little more digging, trial and error i eventually got this working.
My XML now has the following attribute:

webLink ="<a href="">"

using a combination of the following AS2 scripting i am able to populate my text field form the XML with html links.

var links:Array = new Array();

var linksArray:Array = this.firstChild.childNodes;


and then

link.htmlText = links[0];

If anyone wants to see the whole AS then i could post it some other time.

I am only just beginning to rasp how flash works which is why the above is not explained very well but i got it working and that's the main thing!

hope this is useful to someone sometime!


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2018 All Rights Reserved