Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

How to delay an event?

New Here ,
Jun 01, 2016 Jun 01, 2016

Hi everybody. I want to delay an event some minutes or seconds in order not to interfere with another event. How can I dow it? Thanks in advance.

Regards

TOPICS
ActionScript
2.3K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Jun 02, 2016 Jun 02, 2016

then you're NOT trying to delay an event being dispatched.

you can just use the timer to delay the call to a function that does something with '..another Clip with another sound'.

var t:Timer=new Timer(5000,1);

t.addEventListener(TimerEvent.TIMER,f2);

function f1():void{

addChild(mc1);

t.start();

}

function f2(e:TimerEvent):void{

addChild(mc2);

}

Translate
Community Expert ,
Jun 01, 2016 Jun 01, 2016

there are several ways to handle that.

one would be to use a listener and listener function to capture the event, remove the listener, use a timer and timer listener to capture a delayed timerevent in the timer listener function where you re-dispatch the original event.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 01, 2016 Jun 01, 2016

Wel I think it will be perfect with a timer. I have tried to put a timer and then with an "if"sentence asking if the timer has a determined value then do the other hings I want to, but obviously my code is wrong because it doesnt work. So how can I do it? Thanks

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 01, 2016 Jun 01, 2016

var capturedE:Event;

var delayTime = 5000;

var t:Timer=new Timer(delayTime,1);

t.addEventListener(TimerEvent.delayDispatchF);

function eventlistenerF(e:Event):void{

// remove the listener that calls this

capturedE=e;

t.start();

}

function delayDispatchF(e:TimerEvent):void{

capturedE.currentTarget.dispatchEvent(capturedE);

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 01, 2016 Jun 01, 2016

Ok. I'm a bit confused. So this piece of code manages the time, but how can I conect this with both events? I mean the event just executed and the new one that I want to delay. Thanks

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 01, 2016 Jun 01, 2016

have your listener call eventlistenerF

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 01, 2016 Jun 01, 2016

Sorry. I have told you it is an event but it is just a function. It's my fault. I have a function and I want that after that a new function takes place. Sorry again and thanks

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 01, 2016 Jun 01, 2016

what's dispatching the event and what type of event will be dispatched?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 01, 2016 Jun 01, 2016

Thanks for all your patience. Well I have a movieClip that appears throw code (addChild....) and as this hapens I have a sound taken from the library. The other thing that hapens next is another Clip with another sound. That's why I want to display first one and then the other in order not to mix both sounds.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 02, 2016 Jun 02, 2016

then you're NOT trying to delay an event being dispatched.

you can just use the timer to delay the call to a function that does something with '..another Clip with another sound'.

var t:Timer=new Timer(5000,1);

t.addEventListener(TimerEvent.TIMER,f2);

function f1():void{

addChild(mc1);

t.start();

}

function f2(e:TimerEvent):void{

addChild(mc2);

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 02, 2016 Jun 02, 2016
LATEST

Well they are not events but the first depend on an event thats why I have made the wrong question. I have to say in my own defense that I started with flash long time ago, when it was not Adobe flash. When I started it was AS1, then I jumped to AS2 and I am completely new with AS3 wich is quite diferent. Thanks. I'm going to try this

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines