Skip to main content
May 7, 2009
Answered

Serious help needed... AS2

  • May 7, 2009
  • 1 reply
  • 789 views

Ok. I'm NOT good with as. I'm building a website. i'm gona try to explain the best i can.

SO...I've had a LOT of problems with this website. so i decided to start it over. The way it is now (to fix a lot of other problems), i have a menu ON the main scene, in a mc. And to call the "sections" of the menu (example: photos), i call labeled frames, which are on the MAIN scene as well. Up to now, its working.
Next, when u click on the PHOTOS button (which is a mc as well), the background changes, and the thumbnails appear to the right (animated from outside the stage to inside...) Then, u can pic the pic u want. When you leave the section, i wanted to have the "ThumbOut" animation play and finish BEFORE the section changes.Still ok up till now.

NOW...in the photos section, i created two animations: thumbsIN and thumbsOUT, for when u get IN the section, and LEAVE the section.(OUT) i labeled the frames (thumbin, thumbout) and called those with AS. Still ok.

i then made an action to call these animations when we click on the PHOTOS mc, and SOMEHOW figured out (by copying tutorials and bits of AS:P) how to get it to animate OUT when u leave the section.
it looks like this:

on the Photo and ambiance mc (button):


on (release) {
_parent.gotoAndPlay("Ambiance");

}

On the ABOUT button (Propos)


on (release) {
_parent.thumbMc.gotoAndPlay("thumbout");
_parent.thumbMc.onEnterFrame = function() {
if (_parent.thumbMc._currentframe == 42) {
_parent.thumbMc.stop();
_root.gotoAndPlay("Propos");
}
}
}

/// "thumbout" is the frame label for the OUT which is inside the thumbMc
/// "Propos" is the frame label on the MAINSCENE (root?) which calls my other section (when the PROPOS button is clicked.

Works FINE!!! when im in the photo section, and i click on the about button, works like a charm: thumbnail animation plays, then finishes, THEN changes section.

the problem? THIS: when i'm in any other section, the About(propos) button doesnt work!!

now i think i know why, but i dont have the slightest clue on HOW to do it:
i think i need to say: if the thumbMc is already loaded, go on with the script (meaning, wait for the mc to finish before playing). if NOT, just go play the frame: "propos".

i hope that iv been not too complicated...

please help me!!

thanx!

This topic has been closed for replies.
Correct answer kglad

ok we are getting somewhere!!! nice.. ok, now the REAL problem is:

if i'm IN the photo gallery section (meaning that the thumbMc is loaded), i want it to do this actionscript we just discussed

if i'm NOT IN the gallert section (any other section, meaning that thumbMc is NOT loaded), i want it to just directly to _root.gotoAndPlay("Propos")

meaning that it bypasses the thumbMc animation, and just goes to play the frame labeled "Propos" at the root.

i tried this:

on (release) {
    if(_root.thumbMc.loaded=true)
    {
_parent.thumbMc.gotoAndPlay("thumbout");
_parent.thumbMc.onEnterFrame = function() {
if (_parent.thumbMc._currentframe == 42) {
delete this.onEnterFrame;
_parent.thumbMc.stop();
_root.gotoAndPlay("Propos");
}
}
}
else {
_root.gotoAndPlay("Propos");
}
}

not working...

in my head, it seems perfectly logic, so you can see how much of an expert i am:P Hehe...

what do you suggest?


if there are times when _root.thumbMc exists and times when it doesn't exist and you want to test for its existance, you can use:

if(_root.thumbMc){

//whatever

}

1 reply

kglad
Community Expert
Community Expert
May 7, 2009

(for future projects, you shouldn't attach code to objects.  it makes debugging much more difficult.)

you should delete your onEnterFrame loops when they are no longer needed.  they, at least, eat cpu cycles, or most likely are going to cause difficult to debug problems at some point in your app's development.  and that may be your current problem.

May 7, 2009

Noted! i will try to avoid attaching code on objects. However, to be honest, i'm not sure i know what you are talking about. see, i'm no wizz in actionscript. i barely code... So i have actually NO clue of what you are talking about:'(

kglad
Community Expert
Community Expert
May 7, 2009

try:

on (release) {
_parent.thumbMc.gotoAndPlay("thumbout");
_parent.thumbMc.onEnterFrame = function() {
if (_parent.thumbMc._currentframe == 42) {
delete this.onEnterFrame;
_parent.thumbMc.stop();
_root.gotoAndPlay("Propos");
}
}
}