FORUMS: list search recent posts

delaying a loaded clip from playing immediately after a Mouse_down event

COW Forums : Adobe Flash

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Dana Brocious
delaying a loaded clip from playing immediately after a Mouse_down event
on Apr 24, 2011 at 1:01:49 pm

Ok so here is the code I have which is attached to an empty movieclip on my main stage. The clip loads just fine, but I want it to wait (delay) to load until another movieclip (on the main stage) reaches its 30th frame. This is urgent...this project is due on monday, and any help would be greatly appreciated:

var clipLoader:Loader = new Loader()
var clipToLoad:String = new String()


ngdBtn.addEventListener(MouseEvent.MOUSE_DOWN, loadClip1);



function loadClip1(event:MouseEvent):void {
clipToLoad = "NewEnglandMapRESIZE.swf";
var clipRequest:URLRequest = new URLRequest(clipToLoad);
clipLoader.load(clipRequest);
loaderNgd.addChild(clipLoader);

}

Thank you!


Return to posts index

demetri tashie
Re: delaying a loaded clip from playing immediately after a Mouse_down event
on Apr 25, 2011 at 5:47:53 pm

this code is 'attached' to a movie clip? you are asking for trouble.

best to place this code, like ALL the code, on the first frame of the main timeline. then, as long as your file(s) are set up correctly, you can get it to work.

without the other code supplied, i am just giving you the IDEA of what needs to be done, not necessarily specific working code.

i'll call the other clip you refer to as 'clip30frames'

then something like this would get you the expected results:
var clipLoader:Loader = new Loader();
var clipToLoad:String = new String();
<b>var clipRequest:URLRequest;
clip30frames.stop();</b>
ngdBtn.addEventListener(MouseEvent.MOUSE_DOWN, loadClip1);

function loadClip1(event:MouseEvent):void
{
<b>clip30frames.play();
ngdBtn.removeEventListener(MouseEvent.MOUSE_DOWN, loadClip1);
clip30frames.addEventListener(Event.ENTER_FRAME, checksForFrame30);</b>

}
<b>function checksForFrame30(e:Event):void
{
if (clip30frames.currentFrame == 30)
{
clipToLoad = "yourSWF.swf";
clipRequest = new URLRequest(clipToLoad);
clip30frames.stop();</b>
clipLoader.load(clipRequest);
loaderNgd.addChild(clipLoader);
<b>clip30frames.removeEventListener(Event.ENTER_FRAME, checksForFrame30);
}
}</b>


so now your mouse down event doesn't actually trigger the loading of the clip and adding it to the display list, but it triggers the other clip to play ( you'll figre that part out), and attaches a listenr to it which listens to what frame it is in. when it reaches frame 30, it triggers the events you want.

hope that makes sense and can help.


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 CreativeCOW.net All Rights Reserved
[TOP]