Skip to main content
victorSobrinho
Inspiring
February 5, 2012
Answered

how to define a parameter of frame in the function if?

  • February 5, 2012
  • 1 reply
  • 1092 views
Change Settings

Hello! I am with a doubt, I tenjo one movie clip and inside of it I have a animation! when clicar in a button in palco, the action of the button goes to make there with that the line of the time inside of the animation of movieclip if moves for frame 5, until all good. now when it arrives in frame 6, when to arrive in frame 10 of the animation inside of movie clip has one stop (); but I want that the animation is with a Loop, of the one message of error in the window of exit of the Flash saying that frame is not a function, for the connective if I place one gotoAndPlay (); to say the connective if where the needle of the line of the time has that to be to execute the block if? it sees the code:

import flash.events.MouseEvent;

function vai(event:MouseEvent):void{
  simbolo.gotoAndPlay(5);
}
for(;;){
    if(simbolo.frame(6)){
       simbolo.gotoAndPlay(1);
    }
}

bebe.addEventListener(MouseEvent.CLICK,vai);

Of the one message of error in the window of exit of the flash cs5,

saying that the function does not exist frame! Which word I place in the frame place?

already I tried gotoAndPlay (); e did not funcionaou, for the logic would not go to function but I tried exactly thus.

Change Settings
This topic has been closed for replies.
Correct answer victorSobrinho

It does not function. I the same copied code that you postou and she did not function! already to open the archive again,

I verified the instance name. e does not function! e I saw the code line: to this.removeEventListener (Event.ENTER_FRAME, enterframeF); To open the archive of the flash again, I made a new archive and it did not give certain.

I verified the code. when compiling it does not show no message of error in the window of exit of the adobe flash!

I verified the instance names::


SOLVED PROBLEM

I decided the problem with techniques of action script 2,0, I had that to place in the last frame of timeline of movie clip one gotoAndPlay (2), to come back toward frame 2, of the line of the time of the animation of movie clip. the animation alone starts when the clica user in the button!

code of timeline main:


import flash.events.MouseEvent;

function vai(event:MouseEvent):void{

  simbolo.gotoAndPlay(2);

}

bebe.addEventListener(MouseEvent.CLICK,vai);

code of timeline of movieclip:

frame 1 = stop();

frame 10 (último frame) = gotoAndPlay(2)

Debtor for helping, decided the problem me but not fopi as I wanted, I wanted to all place the code in the first frame of timeline main. still I want answers for this possible method if. I made in this way only to be able to follow with my project.

1 reply

kglad
Community Expert
Community Expert
February 5, 2012

use:

import flash.events.MouseEvent;

function vai(event:MouseEvent):void{
  simbolo.gotoAndPlay(5);

this.addEventListener(Event.ENTER_FRAME,enterframeF);
}



function enterframeF(e:Event):void{

   if(simbolo.currentFrame==6){
       simbolo.gotoAndPlay(1);

this.removeEventListener(Event.EnterFrame,enterframeF);
    }
}

bebe.addEventListener(MouseEvent.CLICK,vai);

victorSobrinho
Inspiring
February 5, 2012

Debtor for answering, but gave error! before the user clicar in the button movieclip already he initiates the Loop, I I want a Loop infinitoda animation, the certainty would be only when the user to clicar in the button. it sees the image, already I compiled with and its block if. already I added to the new function the list of events and removed. but it was the same action.

kglad
Community Expert
Community Expert
February 5, 2012

remove all your code.

copy the code in my message.

paste the code into your actions panel.

test.