Hi all,
This problem might be a little tricky to figure out but I'm completely stumped and could use some input on the code.
Kind of a lot of code but please bare with me.
Basically I have 12 images side by side that will slide from left to right when a user clicks on a button that uses tweenMax to tell it to go to a specific _x coordinate. It's just a basic sliding effect that when it stops...loads up an FLV and begins playing a testimonial. When the user clicks another option in the nav..it stops the clip and slides to the desired one.
I got all of it to work but sometimes I run into the FLV getting stuck on the streaming part and not load at all and just stay there. Would someone please look through my code and offer advice on how to make this work and clean it up? Is there a way to make an flv definitely stop and start?
Here is the code:
And then the code for the navigation:Code:stop(); /******************************************************** This lines of code load the videos previews, one by one. ********************************************************/ //Set the images URLs in this array var previewImages:Array = new Array(); previewImages[0] = "videoPreview0.jpg"; previewImages[1] = "videoPreview1.jpg"; previewImages[2] = "videoPreview2.jpg"; previewImages[3] = "videoPreview3.jpg"; previewImages[4] = "videoPreview4.jpg"; previewImages[5] = "videoPreview5.jpg"; previewImages[6] = "videoPreview6.jpg"; previewImages[7] = "videoPreview7.jpg"; previewImages[8] = "videoPreview8.jpg"; previewImages[9] = "videoPreview9.jpg"; previewImages[10] = "videoPreview10.jpg"; previewImages[11] = "videoPreview11.jpg"; //This var keep the order var loadingPrev:Number = 0; //This function set the iamge in the loader function loadPreviews(id) { mcID = id+1; // <-- We need add 1, example: in the array is 0, but the movieclip instance is 1 //Load image in the img_mc (is the loader) testimonialsContent.testimonialsSlider["testimonial"+mcID].img_mc.loadMovie(previewImages[id]); //Now, we check the img_mc width, this is a simple way to check the load status this.onEnterFrame = function() { //if img_mc._width > 100 if (testimonialsContent.testimonialsSlider["testimonial"+mcID].img_mc._width > 100) { //next item setNewLoad(); } }; } //This function set a new preview load function setNewLoad() { delete this.onEnterFrame; if (loadingPrev<11) { loadingPrev++; loadPreviews(loadingPrev); } //Is a simple code, add 1 to loadingPrev, if loadingPrev < 11 } //Start the load loadPreviews(loadingPrev); /********************************** This lines of code load the videos **********************************/ //Set the videos URLs in this array var videosURL:Array = new Array(); videosURL[0] = "Clip1.flv"; videosURL[1] = "Clip2.flv"; videosURL[2] = "Clip4.flv"; videosURL[3] = "Clip1.flv"; videosURL[4] = "Clip2.flv"; videosURL[5] = "Clip4.flv"; videosURL[6] = "Clip1.flv"; videosURL[7] = "Clip2.flv"; videosURL[8] = "Clip4.flv"; videosURL[9] = "Clip1.flv"; videosURL[10] = "Clip2.flv"; videosURL[11] = "Clip4.flv"; var actualID:Number = 0; //This function set the player position and set the new video function playTestimonial(id) { //user can click the navigation bar enableNav(); actualID = id; //close the last video //testimonialsContent.testimonialsSlider.player_mc.closeVideo(); //one less videoID = id - 1; //set the video in the player testimonialsContent.testimonialsSlider.player_mc.setVideo(videosURL[videoID]); //set the player X (over the testimonial MCs testimonialsContent.testimonialsSlider.player_mc._x = testimonialsContent.testimonialsSlider["testimonial"+id]._x; } //This function set the next video function nextTestimonial(){ // actual video + 1 = next video var nextID:Number = Number(actualID) + 1; //If the video is testimonial12 if(nextID == 13){ //We set the enxt video = testimonial1 nextID = 1; } //Simulate the click in the next navigation button navigation_mc["b"+nextID].onRelease(); //And the RollOver navigation_mc["b"+nextID].onRollOver(); } function blockNav(){ noclick_btn._visible = true; } function enableNav(){ noclick_btn._visible = false; } //standard mouse pointer (no Hand) noclick_btn.useHandCursor = false; //user can click the navigation bar enableNav();
if you want files I would love to post them.Code:var menuArray:Array = [{mc:b1, name:"1", label:"module1"}, {mc:b2, name:"2", label:"module2"}, {mc:b3, name:"3", label:"module3"}, {mc:b4, name:"4", label:"module4"}, {mc:b5, name:"5", label:"module5"}, {mc:b6, name:"6", label:"module6"}, {mc:b7, name:"7", label:"module7"}, {mc:b8, name:"8", label:"module8"}, {mc:b9, name:"9", label:"module9"}, {mc:b10, name:"10", label:"module10"}, {mc:b11, name:"11", label:"module11"}, {mc:b12, name:"12", label:"module12"}, {mc:b13, name:"13", label:"module13"}, {mc:b14, name:"14", label:"module14"}]; for(var i:Number = 0; i<menuArray.length; i++){ var btn:MovieClip = menuArray[i].mc; btn.btnMC.btnTxt.text = menuArray[i].name; btn.queue = i; btn.onRelease = function(){ toggleButtons(this); _parent.testimonialsContent.gotoAndStop(menuArray[this.queue].label); //_parent.playTestimonial(menuArray[this.queue].name); _parent.testimonialsContent.testimonialsSlider.player_mc.closeVideo(); _parent.blockNav(); } } var selectedButton:MovieClip; function toggleButtons(btn:MovieClip):Void{ if (selectedButton){ selectedButton.gotoAndPlay("Out"); selectedButton.enabled = true; } btn.enabled = false; selectedButton = btn; }
Thanks in advance and good luck!
Brian
Check the forum often for the latest design announcements. Everything from graphic design and web design, to films and music. Estetica is a great place for people to get together and help each other out.
Bookmarks