Try adding the ENTER_FRAME listener to Main instead of myThumb...

//myThumb.addEventListener(Event.ENTER_FRAME, checkFrame);
addEventListener(Event.ENTER_FRAME, checkFrame);




beno - wrote:
On Tue, Feb 2, 2010 at 10:14 AM, Glen Pike <g...@engineeredarts.co.uk>wrote:

Are you trying to see if the current frame of myThumb is 10, or the current
frame of the Main clip?

If you are looking at the current frame of the Main clip, then
e.target.currentFrame should be changed to this.currentFrame.

If these don't have 10 or more frames, then your code won't work.  If you
need to have a check based on the number of times something is called, e.g.
the enterframe handler, then use a counter to increment until it gets to
your magic number then do something:

//class variable called counter.

private var counter:int = 0;

public function checkFrame(e:Event):void {
       if (counter == 10) {
       doTween();
               counter = 0;
       } else {
               counter++;
       }

}


I tried this:

package
{
   import flash.events.Event;
   import flash.events.ProgressEvent;
   import flash.events.Event;
   import flash.events.MouseEvent;
   import flash.display.MovieClip;
   import com.greensock.*;
   import com.greensock.easing.*;
// import CloseThumb;
   public class Main2 extends MovieClip
   {

                public var myThumb:CloseThumb;
private var counter:int = 0;
      public function Main2()
      {
         init();

      }

      public function init():void
      {
//                        CloseThumb();
theThumb();
}

public function checkFrame(e:Event):void {
       if (counter == 10) {
       doTween();
               counter = 0;
       } else {
               counter++;
trace(counter);
}

}

public function doTween():void {
addChild(myThumb);
TweenMax.to(myThumb, .4, {shortRotation:{rotation:60},
ease:Back.easeOut,onComplete:onFinishTween});

}

//If you want to get rid of the thumb after the tween has finished, then add
the "onComplete handler above to point here...
public function onFinishTween():void {
  removeChild(myThumb);
}
//Then in your theThumb function:


public function theThumb():void
              {
                      myThumb = new CloseThumb();
                      myThumb.x = 365;
                      myThumb.y = 355;
myThumb.addEventListener(Event.ENTER_FRAME, checkFrame);

                }

// public function checkFrame(e:Event):void {
// if (e.target.currentFrame == 2) {
//                       doTween();
// }
// }

   }
}


It didn't trace the counter. I tried it in the real program (we're working
with a stripped-down version) but it didn't print, nor throw errors.
TIA,
beno
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders



_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to