Skip to main content
November 28, 2014
Question

About current frame property

  • November 28, 2014
  • 1 reply
  • 1763 views

Hello I am trying to make as3 take action when a certain frame is reached. As far as I understand I need to use current frame property. But it does not work for some reason. It is about as. file so my object is referred to as "this". 

if (this.hitTestObject(_root.mcBall)){

    _root.ballYSpeed *= -1

    if(!hit){      

        hit = true

        this.gotoAndStop(2)

    } else {      

        this.gotoAndStop(3)

  removeEventListener(Event.ENTER_FRAME, enterFrameEvents);

_root.brickAmt --;

I have animation playing inside frame 3 at the end of which goes to (parent) frame 4. How can I tell it if the current frame is 4 to do  _root.brickAmt --;  At this point? Is there another command I can use?

    

Thanks!

This topic has been closed for replies.

1 reply

Ned Murphy
Legend
November 28, 2014

You appear to be mixing AS2 and AS3 code.  That will not work.  "_root" is an AS2 term.  In AS3 ir would be "MovieClip(root)".

In AS3 the current frame can be determined using the "currentFrame" property

I cannot tell from what you describe which timline you are dealing with so I will leave it at the following rough description...

if(currentFrame == 4){

    MovieClip(root).brickAmt --;

}

November 28, 2014

I am sorry I tried to change my question just now and it would not let me. From this code not the other one. What do i add?

_root = MovieClip(root);

  if (this.hitTestObject(_root.mcBall)){ 

       _root.ballYSpeed *= -1 

       if (this.currentFrame == 1){   

        this.gotoAndStop(2)

        } else {                     

        this.gotoAndStop(3)

        removeEventListener(Event.ENTER_FRAME, enterFrameEvents);

        _root.brickAmt --;

  }

  }

  }

}

}

Ned Murphy
Legend
November 29, 2014

What do you add to accomplish what?  Look at what I already offered and think about it before you respond