FORUMS: list search recent posts

Scene to scene Problem

COW Forums : Adobe Flash

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Keith Anthony
Scene to scene Problem
on Aug 28, 2013 at 11:06:19 pm

Hi i'm working with CS6 AS3 and i'm baffled with this. i have Scene 2 and it has an MC (Next) which when clicked takes you to Scene 3

Next.addEventListener(MouseEvent.CLICK, fl_ClickToGoToScene211);

function fl_ClickToGoToScene211(event:MouseEvent):void
{
MovieClip(this.root).gotoAndPlay(1, "Scene 3");
isPlayingMC211.stop();
}


That works fine and Scene 3 works perfectly. now when i have another option for Scene 2 to go to Scene 3 which is

isPlayingMC211.addEventListener("enterFrame",checkFrame211);
function checkFrame211(e:Event):void{ if(e.target.currentFrame == 2192)
{ MovieClip(this.root).gotoAndPlay(1,"Scene 3");} }

(frame 2192 is the end of an MC in Scene 2)

with this code it goes to scene 3 but scene 3 is frozen and i cannot click on any of the buttons. Any ideas why this is happening?
Thanx in advance for any help.


Return to posts index

demetri tashie
Re: Scene to scene Problem
on Aug 29, 2013 at 1:20:21 pm

there's a few problems i see, not the least being using large complicated timeline navigation.

i'll assume you are not using Classes, and that all code is written in the ActionScript panel and IS in all one place.

using 'this' and also 'root' can be tricky. you have to be very careful and certain what they are referring to.

with the second set of code, when you test it, does it thorw errors?( i bet it does) if so, what does it say?


QUOTE: ... (frame 2192 is the end of an MC in Scene 2) ...
this is telling , because your event listener is on 'isPlayingMC211' . the function written says
if(e.target.currentFrame == 2192) with 'e.target' referring to 'isPlayingMC211', not to whatever 'MC in Scene 2' you mention.

if it did work, it would direct it to MovieClip(this.root).gotoAndPlay(1,"Scene 3");}
are you sure what 'MovieClip(this.root)' is now referring to?


and check this line isPlayingMC211.addEventListener("enterFrame",checkFrame211)
because that is not how an ENTER_FRAME should be written. it should be written thus:
addEventListener(Event.ENTER_FRAME,checkFrame211)that is probably the biggest mistake that needs correcting

now, i don't like this code, but IF i was attempting it i would say you probably want something like this to account for your nested movieclips, since the parent movieclip has no idea of what any child movieclip is doing unless it is directed to listen for it:


isPlayingMC211.addEventListener(Event.ENTER_FRAME, checkFrame211);
function checkFrame211(e:Event):void{ if(isPlayingMC211.otherMCinScene2.currentFrame == 2192)
{ theMovieClipToBeTargetted(.gotoAndPlay(1,"Scene 3");} }


note that to tell a movelclip 'B' that is nested inside movieclip 'A' to play, you write A.B.play();

If you want to be exact and work an absolute path, it is best to declare/cast the stage as root, then it is easier to work backwards/forwards from

var myRoot:MovieClip = root as MovieClip;

then if 'B' is a movieclip inside 'A' which is on the stage, a function can reference it from anywhere with
{ myRoot.A.B.play(); } which since it is an absolute path, it explicitely tells 'B' to play

i hope these ideas help you solve your problem


Return to posts index

Keith Anthony
Re: Scene to scene Problem
on Aug 29, 2013 at 2:42:11 pm

Hey,

thanks for you lengthy post. maybe this would help you understand a bit more what i'm doing.
So i have 3 identical length MC's nested in the main timeline. isplaying the result of a function i use to determine which one of them is playing. takes the frame number it's on, stops it and continues whichever other one had it's corresponding button clicked on. that works fine and switches seamlessly between the MCs. but when it comes to reading the last frame to then switch to a certain scene it goes bust...i have no errors by the way when publishing

Thanks


Return to posts index


demetri tashie
Re: Scene to scene Problem
on Aug 30, 2013 at 2:11:06 pm

as long as you have everything else worked out, then this code can be tweaked to accomplish that



var totalFramesA:uint = mcA.totalFrames; //variable to hold the total frames,
// (a uint which will usefully also be the same number as the last frame)

addEventListener(Event.ENTER_FRAME, listenA);

function listenA(e:Event):void {

if(mcA.currentFrame==totalFramesA) { //do whatever you want }
}


Return to posts index

Keith Anthony
Re: Scene to scene Problem
on Aug 31, 2013 at 2:11:13 pm

this works the same as the one i had. it goes to the specified scene but then freezes. it seems that whichever scene it goes to, it loops the first 2 frames of that scene.

but then if the command is mouse clicked, it goes to the specified scene and works fine.
any ideas why this could possibly be?


Return to posts index

demetri tashie
Re: Scene to scene Problem
on Aug 31, 2013 at 3:29:07 pm

without seeing more code, or how you constructed your project, it might be harder to go any further.

however, i still think you are targetting something incorrectly.
which mc ( and exactly where is it located) are you referencing with this( quoted from my original response):

QUOTE
QUOTE.. (frame 2192 is the end of an MC in Scene 2) ...
this is telling , because your event listener is on 'isPlayingMC211' . the function written says
if(e.target.currentFrame == 2192)
with 'e.target' referring to 'isPlayingMC211', not to whatever 'MC in Scene 2' you mention.

if it did work, it would direct it to
MovieClip(this.root).gotoAndPlay(1,"Scene 3");}

are you sure what 'MovieClip(this.root)' is now referring to?


i suspect you have another movieclip withing that 'scene' that you are expecting to play, but it might not be directed to play yet.

more/full code, or posting your project can help us figure it out


Return to posts index


Keith Anthony
Re: Scene to scene Problem
on Aug 31, 2013 at 4:35:22 pm

this is how isPlaying is used

var isPlayingMC211:MovieClip =enMC;;
var isPlayingMCcurrentFrame211 = 0;

enbutton.addEventListener(MouseEvent.CLICK, playMC211);
function playMC211(e:MouseEvent):void {

isPlayingMCcurrentFrame211 = isPlayingMC211.currentFrame;
isPlayingMC211 = enMC;
isPlayingMC211.gotoAndPlay(isPlayingMCcurrentFrame211);
itMC.gotoAndStop(1);//frame1 is empty
mtMC.gotoAndStop(1);//frame1 is empty
itbutton.addEventListener(MouseEvent.CLICK, playMC222);
function playMC222(e:MouseEvent):void {

isPlayingMCcurrentFrame211 = isPlayingMC211.currentFrame;
isPlayingMC211 = itMC;
isPlayingMC211.gotoAndPlay(isPlayingMCcurrentFrame211);
enMC.gotoAndStop(1);//frame1 is empty
mtMC.gotoAndStop(1);//frame1 is empty
mtbutton.addEventListener(MouseEvent.CLICK, playMC233);
function playMC233(e:MouseEvent):void {

isPlayingMCcurrentFrame211 = isPlayingMC211.currentFrame;
isPlayingMC211 = mtMC;
isPlayingMC211.gotoAndPlay(isPlayingMCcurrentFrame211);
enMC.gotoAndStop(1);//frame1 is empty
itMC.gotoAndStop(1);//frame1 is empty


that's why i wanted isPlaying to determine the end of the scene to go to the next one. else i could try 3 event listeners on each mc and see from there


Return to posts index

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