Changing the Scene by dragging an Object

In the introductory scene, in a keyframe, declare and initialize global variables to track things that will change during the movie

_global.door = 0; // in this movie you choose which door to enter 0=none chosen

In the movie, create events that will change the value of the global variable, such as this one:


When the apple is clicked on, you can drag it.
When you release it, it sets the global variable, door, to either 1, 2 or 0.
  This code goes on a movie clip
on(press) {
 startDrag(this);
 } 
 
 on(release){
 stopDrag();
 if(this.hitTest(_root.door1)){
 trace("yellow door");
 _global.door = 1;
 }
 else if(this.hitTest(_root.door2)){
 trace("blue door");
 _global.door = 2;
 }
 else{
 _global.door = 0;
 this._x = 35; // put the apple back
 this._y = 140; }
 } 
 

The way the code is written now, this cannot be the first scene in the movie because _global.door must be created before you arrive at this scene. You could initialize _global.door in frame 1 and then have frame 3 loop back to frame 2.

As long as _global.door equals 0, this scene repeats gotoandplay(1) means go back to frame 1 in this scene, so it keeps looping.

trace() displays debugging information in the console that will not appear in the published movie.