Frame Check / Reset Loop / Start Screen / No Repeat

  • DarkTemplar
  • Born
  • Born
  • DarkTemplar
  • Posts: 4

Post 3+ Months Ago

I just have a few simple questions of things I'm having problems with. I am using AS3 on Flash CS4.

1. what is the correct code to check for when it's on a certain frame. In this case, I want it to play the movie until it gets to a certain frame, and then go to and play another part of the clip.

2. Is there a command to tell a loop (in this case a while loop) to reset itself, as in go back to the beginning of it, if a certain condition is met?

3. How do you make it freeze on one frame until you press a start button to have it start playback? I've made the button, but when I put anything other than Stop(); in the actions window whatsoever, it doesn't stop at all.

4. How do you get the clip to play just once and then stop? At default it seems to just keep repeating forever.
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • IceCold
  • Guru
  • Guru
  • User avatar
  • Posts: 1254
  • Loc: Ro

Post 3+ Months Ago

1.
ACTIONSCRIPT Code: [ Select ]
import flash.events.*;
 
targetClip.addEventListener(Event.ENTER_FRAME, onFrame);
function onFrame(evt:Event)
{
   if (evt.target.currentFrame == xFrameNo)
   {
       evt.target.stop(); // or
       evt.target.gotoAndPlay(yFrameNo);
   }  
}
 
  1. import flash.events.*;
  2.  
  3. targetClip.addEventListener(Event.ENTER_FRAME, onFrame);
  4. function onFrame(evt:Event)
  5. {
  6.    if (evt.target.currentFrame == xFrameNo)
  7.    {
  8.        evt.target.stop(); // or
  9.        evt.target.gotoAndPlay(yFrameNo);
  10.    }  
  11. }
  12.  


2. use 2 loops
condition3 is if you want to get out of the first
ACTIONSCRIPT Code: [ Select ]
 while (true)
 {
     while (condition1)
     {
         if (condition2)
             break;
     }
     if (condition3)
        break;
 }
 
  1.  while (true)
  2.  {
  3.      while (condition1)
  4.      {
  5.          if (condition2)
  6.              break;
  7.      }
  8.      if (condition3)
  9.         break;
  10.  }
  11.  



3.
ACTIONSCRIPT Code: [ Select ]
import flash.events.*;
targetClip.stop();
btn.addEventListener(MouseEvent.CLICK, onButtonClick);
function onButtonClick(evt:MouseEvent)
{
   targetClip.play();
}
 
  1. import flash.events.*;
  2. targetClip.stop();
  3. btn.addEventListener(MouseEvent.CLICK, onButtonClick);
  4. function onButtonClick(evt:MouseEvent)
  5. {
  6.    targetClip.play();
  7. }
  8.  


4. put a keyframe in the last frame of the clip, and inside that keyframe add the action script: stop();
  • DarkTemplar
  • Born
  • Born
  • DarkTemplar
  • Posts: 4

Post 3+ Months Ago

When I try the button one I get:

1061: Call to a possibly undefined method addEventListener through a reference with static type Class.

Everything else works though, thanks!
  • IceCold
  • Guru
  • Guru
  • User avatar
  • Posts: 1254
  • Loc: Ro

Post 3+ Months Ago

what exactly is your button instance name?
And what type is it?
  • DarkTemplar
  • Born
  • Born
  • DarkTemplar
  • Posts: 4

Post 3+ Months Ago

The button is called Go and is of type.....button.
  • IceCold
  • Guru
  • Guru
  • User avatar
  • Posts: 1254
  • Loc: Ro

Post 3+ Months Ago

try to make it movieclip
  • DarkTemplar
  • Born
  • Born
  • DarkTemplar
  • Posts: 4

Post 3+ Months Ago

Gives the same error.
  • IceCold
  • Guru
  • Guru
  • User avatar
  • Posts: 1254
  • Loc: Ro

Post 3+ Months Ago

straaanngee. Show me the file.

Post Information

  • Total Posts in this topic: 8 posts
  • Users browsing this forum: No registered users and 16 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.