Frame Check / Reset Loop / Start Screen / No Repeat

  • DarkTemplar
  • Born
  • Born
  • No Avatar
  • Joined: Sep 12, 2009
  • Posts: 4
  • Status: Offline

Post September 12th, 2009, 11:57 am

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
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post September 12th, 2009, 11:57 am

  • IceCold
  • Guru
  • Guru
  • User avatar
  • Joined: Nov 05, 2004
  • Posts: 1254
  • Loc: Ro
  • Status: Offline

Post September 14th, 2009, 1:03 am

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();
“True mastery transcede any particular art. It stems from mastery of oneself - the ability, developed throgh self-discipline, to be calm, fully aware, and complety in tune with oneself and the surroundings. Then, and only then, can a person know himself. ”
  • DarkTemplar
  • Born
  • Born
  • No Avatar
  • Joined: Sep 12, 2009
  • Posts: 4
  • Status: Offline

Post September 14th, 2009, 6:01 pm

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
  • Joined: Nov 05, 2004
  • Posts: 1254
  • Loc: Ro
  • Status: Offline

Post September 15th, 2009, 1:34 am

what exactly is your button instance name?
And what type is it?
“True mastery transcede any particular art. It stems from mastery of oneself - the ability, developed throgh self-discipline, to be calm, fully aware, and complety in tune with oneself and the surroundings. Then, and only then, can a person know himself. ”
  • DarkTemplar
  • Born
  • Born
  • No Avatar
  • Joined: Sep 12, 2009
  • Posts: 4
  • Status: Offline

Post September 15th, 2009, 11:03 am

The button is called Go and is of type.....button.
  • IceCold
  • Guru
  • Guru
  • User avatar
  • Joined: Nov 05, 2004
  • Posts: 1254
  • Loc: Ro
  • Status: Offline

Post September 15th, 2009, 11:50 pm

try to make it movieclip
“True mastery transcede any particular art. It stems from mastery of oneself - the ability, developed throgh self-discipline, to be calm, fully aware, and complety in tune with oneself and the surroundings. Then, and only then, can a person know himself. ”
  • DarkTemplar
  • Born
  • Born
  • No Avatar
  • Joined: Sep 12, 2009
  • Posts: 4
  • Status: Offline

Post September 16th, 2009, 10:28 am

Gives the same error.
  • IceCold
  • Guru
  • Guru
  • User avatar
  • Joined: Nov 05, 2004
  • Posts: 1254
  • Loc: Ro
  • Status: Offline

Post September 17th, 2009, 5:54 am

straaanngee. Show me the file.
“True mastery transcede any particular art. It stems from mastery of oneself - the ability, developed throgh self-discipline, to be calm, fully aware, and complety in tune with oneself and the surroundings. Then, and only then, can a person know himself. ”

Post Information

  • Total Posts in this topic: 8 posts
  • Users browsing this forum: No registered users and 73 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
 
 

© 2011 Unmelted, LLC. Ozzu® is a registered trademark of Unmelted, LLC.