Skip to main content
paul_james123
Inspiring
October 6, 2013
Answered

When using 'playbackwards()' can't see movie next time I want to play it.

  • October 6, 2013
  • 1 reply
  • 2156 views

Hi All,

I'm banging my head here:
I have sound cues in a sound file that make tweened movie clips play. (They change alpha state so they fade up.) When I fade up one I also fade down the previous image using 'playbackwards()'.

However, I need to repeat images and it looks like  if I use 'playbackwards()' on an movie clip, I don't see it when I try to play()' it again (play it forwards again).


If I just make the previous image invisible when showing the next image, that previous image will show next time I need to play it...I just can't use 'playbackwards()' on it if I need to play that movie clip again.

Here's some of my code:

// On Cue Point
function onCuePoint(event:CuePointEvent):void
{

//find the movie clip asociated with the string name of the cue in the soundtrack
for ( var faceImg : * in faceImgs ) //run thru all mdImgs
{
  //if the sound cue string name = the faceImg string name
  //then dissolve up the faceImg MC and dissolve down the current faceImg, if there is one

  var newFaceName : String = faceImgs[ faceImg ];

if (event.name == newFaceName) //Find the faceImg MC that matches the cue point name
  {  
   //dissolve up the new faceImg
   faceImg.visible = true;
   faceImg.play(); //face dissolves up
   trace ("faceShowing :" + faceImg);
  
   //dissolve down the current faceImg
   currentFaceImg.playBackwards();
   //currentFaceImg.stop();
   //currentFaceImg.visible = false;
   trace ("previous Img:  " + currentFaceImg);
  
   //The new faceImg becomes the 'current faceImg'
   currentFaceImg = faceImg;
  }

}

}


I've posted the folder with the fla file in question (and sound cue files, etc) here:
http://home.comcast.net/~samiri/director/TEST_soundCues.zip

Any help is greatly appreciated.

This topic has been closed for replies.
Correct answer kglad

This might be more info than you want but here is the whole frame script in the main timeline:

// Import classes
import net.quip.sound.SoundSync;
import net.quip.sound.CuePointEvent;
import flash.utils.Dictionary; //This allows the building of dictionaries
// Import mx.transitions.Tween; //NEED THIS??

// Stop main timeline
stop();

var faceImgs : Dictionary = new Dictionary(); //This is the dictionary variable that handles all the face images as group

var currentFaceImg:Object = new Object(); //make an object that will hold the current face MC
currentFaceImg = face1_MC; //..fill it with the name of the first faceImg in the variable that holds the current faceImg.
currentFaceImg.visible = true;
currentFaceImg.play();

// Hide all the faceImgs and stop them from playing (except the first one)
//face1_MC.visible = false;
//face1_MC.stop();
face2_MC.visible = false;
face2_MC.stop();
face3_MC.visible = false;
face3_MC.stop();


//======================================================================

loadFaceImgDictionary();


function loadFaceImgDictionary() : void
{
faceImgs  [ face1_MC ] = "face1";
faceImgs  [ face2_MC ] = "face2";
faceImgs  [ face3_MC ] = "face3";
}


// Create an instance of SoundSync
var ss:SoundSync = new SoundSync();
// Use instance to add cue points to sound file
//puts a cuePoint in the soundtrack at the millisecond locationi indicated after the comma
ss.addCuePoint("face3", 2500); //dissolve up face3 (and automatically dissolve down face 1 with code below in 'on cue point')
ss.addCuePoint("face2", 4000); //dissolve up face2 (and automatically dissolve down face 3)
ss.addCuePoint("face3", 12000); //dissolve up face3 again (and automatically dissolve down face 2) <== This is where the problem occurs. We don't see the face3_MC again. It might be there but with a 0% alpha state...I don't know (Any faceImg that the 'playbackwards()' was used on won't show on the stage again.)


// Use instance to load external MP3
ss.load(new URLRequest("hisBoy.mp3"));
ss.play();


// Assign event handlers
ss.addEventListener(CuePointEvent.CUE_POINT, onCuePoint);
ss.addEventListener(Event.SOUND_COMPLETE, onSoundComplete);

// On Cue Point
function onCuePoint(event:CuePointEvent):void
{

//currentFaceImg.stop();

//find the movie clip asociated with the string name of the cue in the soundtrack
for ( var faceImg : * in faceImgs ) //run thru all mdImgs
{
  //if the sound cue string name = the faceImg string name
  //then dissolve up the faceImg MC and dissolve down the current faceImg, if there is one
 
  var newFaceName : String = faceImgs[ faceImg ];

if (event.name == newFaceName) //Find the faceImg MC that matches the cue point name
  {  
   //dissolve up the new faceImg
   faceImg.visible = true;
   faceImg.play(); //face dissolves up

  
   //dissolve down the current faceImg
   currentFaceImg.playBackwards();

     
   //The new faceImg becomes the 'current faceImg'
   currentFaceImg = faceImg;
  }

}

}

// On Sound Complete
function onSoundComplete(event:Event):void
{
  stop();

}

Thanks again.


as mentioned in message 5, you need to terminate that loop:

stop();

function playBackwards():void
{
addEventListener(Event.ENTER_FRAME, enterFrame);
}


function enterFrame(e:Event):void
{

      prevFrame();

if(this.currentFrame==1){

removeEventListener(Event.ENTER_FRAME,enterFrame)

}

}

1 reply

kglad
Community Expert
Community Expert
October 6, 2013

where's playBackwards()?

paul_james123
Inspiring
October 6, 2013

it's 20 lines down on the above code quote.

In my main timeline frame script it's on line 92

This is a file that is better to look at:

http://home.comcast.net/~samiri/director/TEST_playBackwards.zip

thanks

paul_james123
Inspiring
October 6, 2013

you probably need to remove the event listener if you're using an enterframe event or, if you're using a time, stop the timer.

if you don't understand the above, copy and paste the playBackwards() code.


Here's the code in the last frame of the movie clips that fade with the alpha tween:

stop();

function playBackwards():void
{
addEventListener(Event.ENTER_FRAME, enterFrame);
}


function enterFrame(e:Event):void
{
      prevFrame();
}

BTW: There's no script in the first frames of those movie clips.

Thanks