ios - gotoAndPlay not finding Frame Label AS3 -


i'm trying build simple flash game user drags sombrero onto cactus. i've got when drag sombrero anywhere cactus, snaps it's original position. had when drag onto cactus, stays there.

what want when user drags sombrero onto cactus, takes screen says "yay! play again?" put gotoandplay() inside if statement:

if(droptarget.parent.name == "cactus")                 {                     //scalex = scaley = 0.2;                     //alpha = 0.2;                     //y = stage.stageheight - height - -100;                      //buttonmode = false;                     //removeeventlistener(mouseevent.mouse_down, down);                       gotoandplay("playagain");                       trace("dropped on cactus");                       }                      else                     {                         returntooriginalposition();                           } 

i labeled second frame "playagain." error saying: argumenterror: error #2109: frame label playagain not found in scene playagain. @ flash.display::movieclip/gotoandplay() @ net.dndgtal.cactus_game::sombrero/stageup()

i have googled , checked , double checked suggestions, cannot work. don't have scene "playagain," "scene1." i've tried specifying both scene , frame- doesn't work either. , tried putting in gotoandplay(2), frame two, nothing.

am missing something? appreciated. here of code if helps:

package net.dndgtal.cactus_game { import flash.display.movieclip; import flash.events.mouseevent; import flash.geom.point;  public class sombrero extends movieclip {      protected var originalposition:point;      public function sombrero ()     {         originalposition = new point(x, y);          buttonmode = true;         addeventlistener ( mouseevent.mouse_down, down );          //trace("sombrero constructor");     }      protected function down (event:mouseevent):void     {         parent.addchild(this);         startdrag();         stage.addeventlistener(mouseevent.mouse_up, stageup);          //trace("down");         }          protected function stageup(event:mouseevent):void         {             stage.removeeventlistener(mouseevent.mouse_up, stageup);             stopdrag();              if (droptarget)              {                   if(droptarget.parent.name == "cactus")                 {                     //scalex = scaley = 0.2;                     //alpha = 0.2;                     //y = stage.stageheight - height - -100;                      //buttonmode = false;                     //removeeventlistener(mouseevent.mouse_down, down);                       gotoandplay("playagain");                       trace("dropped on cactus");                       }                      else                     {                         returntooriginalposition();                           }                  }                   else                 {                        returntooriginalposition();                 }              }      protected function returntooriginalposition(): void     {         x = originalposition.x;         y = originalposition.y;         }      }    } 

thanks! let me know if have questions.

your issue 1 of scope. when use gotoandplay("playagain"), take current timeline (scope), sombrero class, , attempt find frame label or scene called "playagain" on it's timeline.

presumably, want main timeline gotoandplay frame label "playagain", not sombrero.

to access main timeline, can use movieclip(root).gotoandplay("playagain").

if it's not main timeline, parent of sombrero, can access movieclip(parent).gotoandplay("playagain")

if relationship between sombrero , whichever timeline trying advance more complicated that, pass in reference in sombrero constructor:

private var targettimeline:movieclip;  public function sombrero (targettimeline_:movieclip) {     targettimeline = targettimeline_;     //...rest of constructor code 

and then:

if(droptarget.parent.name == "cactus"){     targettimeline.gotoandplay("playagain"); 

and when create sombrero, pass in target timeline:

var hat:sombrero = new sombrero(target); 

Comments

Popular posts from this blog

python - mat is not a numerical tuple : openCV error -

c# - MSAA finds controls UI Automation doesn't -

wordpress - .htaccess: RewriteRule: bad flag delimiters -