Ok, I’ve spent many hours searching the web for an answer I can understand. Its been a few years since I’ve done major AS1 and AS2 work. So I’m not sure why I decide to start with AS3 on this project.
This is the basic functionality: I have a video that loads upon the start of a scene, then a listener detects flv play completion and then loads the next video in an array. (working). But I also have menu buttons so the user can also control which which video in the array plays. But in order to do this, and not have the original array loop get lost, I need my buttons to set the event variable on click. I feel like I am so close but I cannot figure our how to share this variable between the 2 listeners.
I have researched and it seems I need use a package and a public class. This is foreign to me and not sure I have time to rewrite everything (should have struck with AS2 for now). Can you guys offer me any quick and dirty solutions without a package? or maybe you can help me figure out the right way. This project is now past due because I can’t seem to figure this out.
Here is my code on the root timeline:
import fl.video.*;
import flash.events.Event;
//The Video Array
var myvideoarray:Array=new Array();
myvideoarray[0] = “deliverables/Clinical Pearls/CLINICAL PEARLS 01.flv”;
myvideoarray[1] = “deliverables/Clinical Pearls/CLINICAL PEARLS 02.flv”;
myvideoarray[2] = “deliverables/Clinical Pearls/CLINICAL PEARLS 03.flv”;
myvideoarray[3] = “deliverables/Clinical Pearls/CLINICAL PEARLS 04.flv”;
myvideoarray[4] = “deliverables/Clinical Pearls/CLINICAL PEARLS 05.flv”;
var k:Number = 0;
Vid.play(myvideoarray[k]);
cp_q1.cp_q1btn.gotoAndStop(2);
trace(k);
Vid.addEventListener(VideoEvent.COMPLETE, loadnext);
function loadnext(myevent:VideoEvent):void {
k++;
trace(k);
if (k==0) {
cp_q1.cp_q1btn.gotoAndStop(2);
cp_q2.cp_q2btn.gotoAndStop(1);
cp_q3.cp_q3btn.gotoAndStop(1);
cp_q4.cp_q4btn.gotoAndStop(1);
cp_q5.cp_q5btn.gotoAndStop(1);
}
if (k==1) {
cp_q1.cp_q1btn.gotoAndStop(1);
cp_q2.cp_q2btn.gotoAndStop(2);
cp_q3.cp_q3btn.gotoAndStop(1);
cp_q4.cp_q4btn.gotoAndStop(1);
cp_q5.cp_q5btn.gotoAndStop(1);
}
if (k==2) {
cp_q1.cp_q1btn.gotoAndStop(1);
cp_q2.cp_q2btn.gotoAndStop(1);
cp_q3.cp_q3btn.gotoAndStop(2);
cp_q4.cp_q4btn.gotoAndStop(1);
cp_q5.cp_q5btn.gotoAndStop(1);
}
if (k==3) {
cp_q1.cp_q1btn.gotoAndStop(1);
cp_q2.cp_q2btn.gotoAndStop(1);
cp_q3.cp_q3btn.gotoAndStop(1);
cp_q4.cp_q4btn.gotoAndStop(2);
cp_q5.cp_q5btn.gotoAndStop(1);
}
if (k==4) {
cp_q1.cp_q1btn.gotoAndStop(1);
cp_q2.cp_q2btn.gotoAndStop(1);
cp_q3.cp_q3btn.gotoAndStop(1);
cp_q4.cp_q4btn.gotoAndStop(1);
cp_q5.cp_q5btn.gotoAndStop(2);
}
if (k>= 5) {
k=0;
trace (“Reset to zero”);
trace (k);
cp_q1.cp_q1btn.gotoAndStop(2);
cp_q2.cp_q2btn.gotoAndStop(1);
cp_q3.cp_q3btn.gotoAndStop(1);
cp_q4.cp_q4btn.gotoAndStop(1);
cp_q5.cp_q5btn.gotoAndStop(1);
}
Vid.play(myvideoarray[k]);
}
cp_q2.addEventListener(MouseEvent.CLICK, PlayMovie2);
function PlayMovie2(event:MouseEvent):void
{
trace (k);
cp_q1.cp_q1btn.gotoAndStop(1);
cp_q2.cp_q2btn.gotoAndStop(2);
cp_q3.cp_q3btn.gotoAndStop(1);
cp_q4.cp_q4btn.gotoAndStop(1);
cp_q5.cp_q5btn.gotoAndStop(1);
var k = 1;
Vid.play(myvideoarray[k]);
trace (k);
}
// Your help would be appreciated!