# Need help with dynamic hyperlink for a video player

**URL:** <https://forum.kirupa.com/t/need-help-with-dynamic-hyperlink-for-a-video-player/247301>\
**Category:** flash\
**Created:** [December 20, 2007, 11:09pm UTC](https://forum.kirupa.com/t/need-help-with-dynamic-hyperlink-for-a-video-player/247301 "2007-12-20T23:09:25Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ateet](https://avatars.discourse-cdn.com/v4/letter/a/e480ec/32.png) [@ateet](https://forum.kirupa.com/u/ateet)\
**Post date:** [December 20, 2007, 11:09pm UTC](https://forum.kirupa.com/t/need-help-with-dynamic-hyperlink-for-a-video-player/247301/1 "2007-12-20T23:09:25Z")

</div>

Hi. I am trying to customize some code for a video player I found at Flashcomguru. I’m trying to make it so that when a video plays, the user can click a button and a webpage will popup in a new window. The problem is that I want to use the same button for multiple videos and each video points to a different web page. I want the same button to point to a different webpage depending on what video is playing. I tried using the getURL function wrapped in a For loop but I can’t get it to work. Any code suggestions? I hope I’ve made myself adequately clear. Here is the code:

import XMLHelper;  
var playList:String = “playlist1.xml”;  
//Set up the list box, call function VideoThumb to create the actual thumbnails  
list.rowHeight = 70;  
list.cellRenderer = “VideoThumb”;  
list.selectable = true;  
stop\_pb.enabled = false;  
nc = new NetConnection();  
nc.connect(null);  
// create a new instance of XMLManager  
xmlHelper = new XMLHelper();  
var xmlListener = new Object();  
xmlListener.mc = this;  
xmlListener.onloaded = function(p\_event:Object) {  
trace(“loaded!”);  
var children = p\_event.xml.firstChild.childNodes;  
//trace(children);  
var streamlist = [];// this is our list’s dataprovider  
var a = [];  
for (var i = 0; i\<children.length; i++) {  
//trace(children\*.attributes.name);  
//trace(children\*.attributes.stream);  
// display the ‘name’ attribute and hold the ‘stream’ attribute as data  
streamlist\* = {label:children\*.attributes.name, data:children\*.attributes.stream};  
//trace(streamlist);  
//a\* = {data:children\*.attributes.link};  
//trace (a);  
//if (a){  
//trace(a);  
//}  
list.dataProvider = streamlist;  
var a:Array = children\*.attributes.link  
trace(a);  
if(a){  
hyp.mylinks.htmlText = item.attributes.label;  
testURL.onRelease=function(){  
getURL(a,"\_blank");  
}  
}  
//if (children\*.attributes.link) {  
//trace(children\*.attributes.link);  
//for (var j in children\*.attributes.link){//children\*.attributes) {  
//trace(j);  
[//testURL.onRelease](https://testURL.onRelease) = function() {  
//getURL(a, “\_blank”);  
//};  
//}  
//}  
}  
};  
xmlListener.haserror = function(p\_event:Object) {  
trace(“error loading XML”);  
};  
xmlHelper.load(playList);  
xmlHelper.addEventListener(“onloaded”,xmlListener);  
xmlHelper.addEventListener(“haserror”,xmlListener);

//create new empty listener object  
listListener = {};  
//Function to handle what happens when an item in the list is selected  
listListener.change = function(evtobj) {  
// enable stop button  
stop\_pb.enabled = true;  
testURL = true;  
// close any current stream  
ns.close();  
//create a new stream  
ns = new NetStream(nc);  
ns.onStatus = function(info) {  
//trace(info.code);  
};  
video.attachVideo(ns);//pipe stream to this video object  
var flvfile = evtobj.target.selectedItem.data+".flv";  
// play it  
ns.play(flvfile);  
};  
//Add an event listener on the list  
list.addEventListener(“change”,listListener);  
//resizes the video object to the width and height of the clip  
function onVideoResize() {  
if (video.width != video.\_width || video.height != video.\_height) {  
video.\_width = video.width;  
video.\_height = video.height;  
}  
}  
setInterval(onVideoResize,200);//keeps checking video size  
stop\_pb.onRelease = function() {  
this.enabled = false;  
ns.close();  
video.clear();  
};  
stop();

And here is some sample XML that I am using:

\<xml\>  
\<listitem name=“350BC” stream=“350BC” link=“[http://www.yahoo.com](http://www.yahoo.com)” /\>  
\<listitem name=“CVC-120PH” stream=“CVC-120PH” link=“[http://www.cnn.com](http://www.cnn.com)” /\>  
\<listitem name=“CVC-130R” stream=“CVC-130R” link=“[http://www.google.com](http://www.google.com)” /\>  
\</xml\>

Thanks very much in advanced!
