Click to See Complete Forum and Search --> : Videoplayer -getURL problem
Hi Everyone,
I am a stumped newbie. I asked this question over on the Flashkit site but had no responses, so I am trying here. Here's the problem: I have a Dreamweaver site that features a Flash multiple video (.flv) player which I have built.This site features videos of real estate that is "for sale". Each flv has a supporting "additional info" webpage / photo slideshow.
The player can correctly play any of the multiple videos in it. Click on a button with the thumbnail jpeg on it, and it loads the flv dynamically. I am using arrays for the flvs, the thumbnails, the videoNames (for the captions) and for the URLS (urlNames) (I will eventually be loading all the data from an XML doc (once I figure out how to do it - later on). When a video is chosen, by clicking on its representative button,(with a thumbnail of the property on it), the flv, loads/plays. A videoName "caption box" shows the flv name (videoNames). The caption box is located on the stage near the projector area. When a different flv is chosen, a different caption appears in the box. So far - so good.
I have created a 2nd text box on the stage, (I call it - URLBox), (it sits right beside the caption box) and dynamically loads, the urlNames, which are the addresses of "additional info" local webpages . Great! This all works up to this point. So far - so good.
Here is where I get lost.
Because there are several different .flv clips, and associated webpages, I have created a "url button", (with the instance "url_btn") which, when clicked on, is supposed to take the user to the associated webpage, based on the URL that appears in the "URLBox". I am getting this data (url address) from an array - (urlNames[videoToLoad]) This is where I am having the problem.... the urlNames shows up in the box when I test the movie but the getURL does not work.
The code I have been trying to use is below - something is wrong - don't know what.
URL_btn.onRelease = function ()
{
getURL = (urlNames[videoToLoad]);
}
Its been a battle getting to this point, and I am at this last item I need to solve, to make the whole thing work. I would be very thankful to anyone who can show me how to get the url_btn to recognize the data in the urlbox and take the user to the "additional info" page when the url_btn is used. Can anyone point me in the right direction please. My mind is slowly turning to jello. What am I doing wrong?? I am using Flash 8 Pro /AS2.0
Alyn Murray
Eye for Video
03-03-2009, 09:19 AM
Looks like you're very close. Depending on how you created and are using the variables... your code looks like it should work.
Here's a little sample converted over from a slide show. The slide show displays an image and a dynamic text box (caption_txt), data coming from an xml file. The dynamic text field was converted to a mc an given instance name "link". I'm using the var "current index" to keep track of the position in the array. Everything works fine. I can click through the slide show (I left off the code of the next/prev buttons) and with each image a different "caption" shows up. The caption is the url to an html file on my local machine.
Compare how your variables are set up... double check to see that your button has an instance name... and ahhh.... wellllll... you're probably pretty close.
var ssx:XML = new XML();
ssx.ignoreWhite = true;
var currentIndex:Number = 0;
var captions:Array = new Array();
var urls:Array = new Array();
ssx.onLoad = function(success){
if (success) {
var ss:Array = ssx.firstChild.childNodes;
for (i=0;i<ss.length;i++) {
captions.push(ss[i].attributes.caption);
urls.push("ss_images/" + ss[i].attributes.url);
}
holder_mc.loadMovie(urls[currentIndex]);
link.caption_txt.text = captions[currentIndex];
}
else
{
trace("XML file failed to load. Please try again later.");
}
}
ssx.load("whw.xml");
link.onRelease = function() {
getURL(captions[currentIndex]);
}
Good luck,
Eye for Video
www.cidigitalmedia.com
Edit:
You use this as instance name:
url_btn
and this in code
URL_btn
Typo in post or in code?
EfV
Regarding the URL btn - I made a spelling mistake in the post. Thank you very much for taking the time to read and respond to my "issue" I am not far enough along in my "Flash Expertise" to fully understand / modify and implement your suggestions. Can I email the code to you or just post it here? Its 140 lines long and being a newbie I do not know what the proper proceedure is. Thanks again. I am so close I can taste it. I am running out of braincells. Experiencing info overload. :) I just need someone to point out my error(s)
Eye for Video
03-03-2009, 01:13 PM
Can you save your actionscript as a text file and just attach to a post?
I'm pretty sure it's a variable naming/use issue because basically the code syntax looks right.
EfV
var nc = new NetConnection ();
nc.connect (null);
var ns = new NetStream (nc);
myVideo.attachVideo (ns);
var videoSnd = new Sound (_root);
videoSnd.setVolume(60);
volSlider.volhdl._x = videoSnd.getVolume()/100 * (volSlider.bg._width - volSlider.volhdl._width);
var lastVideo;
var isPaused = false;
var currentDuration = -1;
ns.onMetaData = function (eventObject)
{
currentDuration = eventObject.duration;
trace("current duration of clip is: "+currentDuration);
};
var videoNames = ["The Beatles","Einstein","Falcon","Shuttle","Landing","Milkyway"];
var videos = ["../../media/video/beatles.flv","../../media/video/einstein.flv","../../media/video/falcon.flv","../../media/video/shuttlelaunch.flv","../../media/video/landingview.flv","../../media/video/milkyway.flv"];
var videoThumbs = ["../../media/thumbs/beatles.jpg","../../media/thumbs/einstein.jpg","../../media/thumbs/falcon.jpg","../../media/thumbs/shuttlelaunch.jpg","../../media/thumbs/landingview.jpg","../../media/thumbs/milkyway.jpg"];
var urlNames = ["../../somepage.html"];
// I have only used 1 url in the urlNames section because it is just a test to see if this works - it does not.
for (var q = 0; q < videos.length; q = q + 1)
{
// create a playlist Button
var newMC = scroller.content.attachMovie("playlistbtn","playbtn" + q, scroller.content.getNextHighestDepth());
// position the new playlist button properly
newMC._y = newMC._height * q;
// set the text label in the playlist
newMC.videoName.text = videoNames[q];
newMC.img.loadMovie(videoThumbs[q]);
newMC.videoID = q;
// add the button functionality (ie.onPress)
newMC.onPress = function ()
{
playNewVideo(this.videoID);
};
}
_root.onEnterFrame = function ()
{
// if current duration is greater than -1, a video is loaded
if (currentDuration > -1)
{
progBar.handle._y = (ns.time/currentDuration) * progBar.bg._height ;
if ( currentDuration - ns.time < .5)
{
//trigger the next video
playNextVideo();
}
}else{
progBar.handle._y = 0 ;
}
}
playbtn.onPress = function ()
{
if (isPaused == true)
{
isPaused = false;
playbtn.gotoAndPlay("pause");
}else {
isPaused = true;
playbtn.gotoAndPlay("play");
}
ns.pause ();
};
mutebtn.onPress = function ()
{
if (videoSnd.getVolume () ==0)
{
mutebtn.gotoAndPlay("mute");
videoSnd.setVolume (100);
} else {
mutebtn.gotoAndPlay("unmute");
videoSnd.setVolume (0);
}
};
nextbtn.onPress = function ()
{
playNextVideo();
};
volSlider.volhdl.onPress = function ()
{
this.startDrag(false,0,0, (volSlider.bg._width-this._width),0) ;
};
volSlider.volhdl.onRelease = volSlider.volhdl.onReleaseOutside= function ()
{
stopDrag ();
videoSnd.setVolume((volSlider.volhdl._x/(volSlider.bg._width-volSlider.volhdl._width)) * 100);
mutebtn.gotoAndPlay("mute");
};
function playNewVideo (videoToLoad)
{
if (lastVideo != videoToLoad)
{
ns.close();
myVideo.clear();
currentDuration = -1;
ns.play(videos[videoToLoad]);
scroller.content["playbtn"+videoToLoad].gotoAndPlay("selected");
scroller.content["playbtn"+lastVideo].gotoAndPlay("unselected");
caption.text = videoNames[videoToLoad];
url.text = urlNames[videoToLoad];
lastVideo = videoToLoad;
isPaused = false;
playbtn.gotoAndPlay("pause");
}
}
// use only for auto loading next video - I have this feature disabled.
//function playNextVideo()
//{
// if (lastVideo < videos.length -1)
// {
// playNewVideo(lastVideo +1);
// }else{
// playNewVideo(0);
// }
// /* this is where everything started causing me problems
I would like to have the getURL button hyperlink to the
appropriate Dreamweaver page. I have used "somepage.html"
could be anything, I can always adjust the path.*/
//}
URL_btn.onPress = function ()
{
getURL = (urlNames[videoToLoad]);
}
Eye for Video
03-03-2009, 08:09 PM
DANG!!!
Sorry I missed this earlier... had a couple deadlines today and time was really pressing.... and ahhh... (any other excuse you'll accept goes here).....
getURL is an ActionScript element or action and you are not defining a function so no "=" needed.
Current code
getURL = (urlNames[videoToLoad]);
correct
getURL(urlNames[videoToLoad]);
Pretty sure that will fix your problems.
EfV
:confused:Hey Thanks for getting back to me. . These days we are all so busy just surviving. However I made the = change you suggested and still - no joy. I have been pouring over this code for days and I am baffled. URL text pops up in the right location when the movie is tested, URL btn shows activity when clicked on, I have used a different url address (http://www.foxnews.com )-( an easy one) - no joy. And I have created a small sample movie with just a button and a small bit of code to see if I can get ANY URL button to work. Works like a charm ,hit the button and boink! I am on the internet at FOX website. Not so in my project though. So somewhere in my code there is a problem. Any more ideas would be appreciated. I will bet the answer is a simple one but just can't recognize the problem. Again thanks for the effort.
Eye for Video
03-04-2009, 07:23 PM
Too bad that didn't cure it..... OK, the part that has me puzzled is
videoToLoad
I was thinking it was a declared variable but it looks like it's an actionscript method or ??
But it work just like a variable in
caption.text = videoNames[videoToLoad];
url.text = urlNames[videoToLoad];
is that correct? It loads the correct name or path to the video?
so in
url.text = urlNames[videoToLoad];
the text in the url text box would be something like
../../somepage.html
correct?
What error message or reaction do you get when you click the URL_btn?
Anyway, as a test of videoToLoad, you could try creating a variable in the getURL using
urlNames[videoToLoad] and then call that variable in the getURL like this:
URL_btn.onPress = function () {
myurl = (urlNames[videoToLoad]);
getURL(myurl);
}
Tested and works fine in my example above.
EfV
Hi Thanks again for hanging in and trying to help me. I really appreciate it. To answer a few of your questions:
"VideoToLoad" I am using this method because there will be times that say, for example, I delete a few videos and then add a couple of different ones. The selection buttons in the fla will automatically be created based on the number of videos in the fla and "videoToLoad" is a way to abstractly keep track of the order of the videos without actually assigning numbers to each of the corresponding Thumbs , videoName, video flvs. etc. (which are indexed to each other) videoToLoad simply grabs a "set" of data linked to the appropriate button. I hope that explains it,...somewhat. :)
Yes, "caption.text = videoNames(videoToLoad)" loads the correct dynamic text into the caption box on the stage (just below my projector) in the fla/swf. The text data is pulled from - var VideoNames - line. What dynamic text gets loaded in the caption box depends on which button gets clicked. First button going from top to botton in my fla/swf plays the first video, first thumb, first videoName etc. and changes when a different button is chosen etc. Again I hope that explains it somewhat. I am using a scrollpane component so the number of buttons I can use is infinate. The scrollpane sits beside the projector. Shows 6 of its video buttons at a time.
-----------------------------------------------------------------------
Regarding the URL section you mentioned in your response,..Yes, you are correct
url.text = urlNames[videoToLoad];
Located in the "function playnewvideo (videoToLoad) section
-----------------------------------------------------------------------
and the text that appears in the "urlbox" , reads from the
var urlNames = ["../../somepage.html"]; line.
Located in the 'var section " (I call it.)
------------------------------------------------------------------------
When I click on the "url button" on the stage (fla -test movie) nothing happens at all. I am trying to get to the point where,... when I click the url button on the fla/swf, whatever dynamic text is showing in the URLbox - pulled from the Var urlNames = (which would be the address of the html page I would be trying to get to ) is where I would be transported to - ("beam me up, Scotty")
I have not tried your suggestions from your last post yet ( just got home )
Thanks again buddy for the time you have put into this. I will try your suggestions in the next few hours (got a bunch of personal stuff to do first) then I will report back to you.
Hi Eye for Video
Sorry it took so lloong to get back Business and family crisis that I am sure a lot of people are experiencing. However I did manage to create a URL button that when pressed would take me to a linked page that is/was associated with the current video playing. Thanks again for all the help was hittinga mental wall and just could not get my brain to work So thanks. Alyn
Eye for Video
03-30-2009, 09:35 AM
Hey Alyn,
Glad you were able to get it working. I'd really like to know how you finally acheived that. Perhaps you could post an explaination.
Thanks!
EfV
Hi I posted the "solution" to my problem but somehow it does not appear in the thread so I will try again. ;
Here is what has worked as I was wanting it to.
Basically I created a var URLNames = " the addresses of the files (pages) in my dreamweaver site"
then I adapted the " caption.text = videoNames variable...."
So the caption.text = videoNames (as was previous) now reads
caption.text = URLNames (videoToLoad) // which are the addresses of the targeted webpages
(in sequence with the other videos on the player)
I created a URL button on the stage and gave it the instance of URLBTN then a little bit of text appears
just above the button it reads FOR MORE INFORMATION PRESS ON BUTTON.
In the getURL section (last bit of code) it reads
URLBtn.onPress = function
{ getURL(caption.text);
ns.close(); // closes the netstream feed
myVideo.clear(); // expunges any video still showing on the projector
}
WORKS GREAT!!
function playNewVideo (videoToLoad)
{
if (lastVideo != videoToLoad)
{
ns.close();
myVideo.clear();
currentDuration = -1;
ns.play(videos[videoToLoad]);
scroller.content["playbtn"+videoToLoad].gotoAndPlay("selected");
scroller.content["playbtn"+lastVideo].gotoAndPlay("unselected");
caption.text = URLNames[videoToLoad]; // HERES WHERE THE CHANGES BEGIN
lastVideo = videoToLoad;
isPaused = false;
playbtn.gotoAndPlay("pause");
}
}
// if the code has 2 slashes in front of of it, the "skip to next video" feature will be disabled.***
function playNextVideo()
{
if (lastVideo < videos.length -1)
{
playNewVideo(lastVideo +1);
}else{
playNewVideo(0);
}
}
// HERE IS THE FINAL BIT OF CODE
URLbtn.onPress = function ()
{
getURL(caption.text);
ns.close();
myVideo.clear();