00:00
00:00
Minix07
what is goodie in da hoodie gangalang?

ima dude, dude

Human

Highland High School

was british land

Joined on 1/13/24

Level:
8
Exp Points:
656 / 710
Exp Rank:
> 100,000
Vote Power:
5.04 votes
Rank:
Police Sergeant
Global Rank:
8,100
Blams:
211
Saves:
951
B/P Bonus:
12%
Whistle:
Normal
Medals:
254
Supporter:
15d

Making a click n' point game using AS3 | Steps 4. Making The First Room

Posted by Minix07 - 4 hours ago


Step 4. Making The First Room

Create a new keyframe inside the game MovieClip, in the same MovieClip where the cutscene takes place, if you did one. This should be the 2nd frame or 3rd if you did a cutscene. 

AD_4nXfijJReunmJsMAfMQMleZF5rN4whlkZlTY7CEfcCZ4ZHitI08V-ac-PVSCzmrejCx5n3KH_drxgKA_NuSCDWm2ikgT-wQFiAYqxDKO8FI-wdfrEMsaMUrnYbiAbWRcFMlOIlr5Nnw?key=lYln-58pvChvGvHg5Z5QrA


Create the background for it and convert it into a Symbol, calling it whatever with a suffix of bg or background. 

AD_4nXdOvXUkTIZUqqc5ogsWcGBu6LtMGGQml_nzYzgJDG57X2_SnM3kxlsY1XNn1QE8W3saAOTfU2dZXLjBK0K3Zq65t5lfFjNTZKTpmbivuV9dX6naeo8hXC7sDS66eKNpGdIXjcizkw?key=lYln-58pvChvGvHg5Z5QrA


Exit the symbol and convert it into another symbol, simply call it whatever the room is called.

AD_4nXdGK7wi1xhlRUO3iW753Tk4M1Rhg6SGTmor_79GZhSADQdJN9Wi2v7VGaDsELqDgvpn4FG_hp4NdM3LW9ut3nR2A-I1SxYOouXeF_-gjB5qmfauc34pEevH_0T_mHbyl2I_91ixmg?key=lYln-58pvChvGvHg5Z5QrA


This is the current setup

AD_4nXdKPgku7sgHYHgf2nLOKx0IXE_QtcVXDKQorDP3sJ2_PaIZUtMQv18G4swmOBwDtwXQb4MuPMpittCcly1iYWeTSefaOQgQxzYVweEjbhe5XbsHglhRbl9UKdHEQMePmp07x-W-bA?key=lYln-58pvChvGvHg5Z5QrA


Hopefully that wasn’t too confusing.

We are now ready to add whatever we want inside the room symbol. If you want the object to be interacted with or have animation, make it a MovieClip and place it inside of the room symbol and not the background symbol.

AD_4nXdevC3EvSocnDwsVPPJRJjLX-tlqkQU_OHAaUbLLha1jjPee3H9agDc7Rt3IFY6A4UBLmjqU2Ma2QsJcGjJeiMmmo11GCyCHo5Fvlk1Lp-qMVls0nJlOOHvijNJ4QnC1n8QRbNd?key=lYln-58pvChvGvHg5Z5QrA


Inside the Game Movieclip, make a new layer and place it at the top. Make a bunch of empty frames. Select a frame, then in the properties, give each frame a name, like calling the main menu “menu” and the intro “intro”. These are called labels and are an easier way to be able to go to these rooms than using frame numbers.

AD_4nXf6Ak4kZ4H4W8G4XcYZcwo7QTssoTB9GNu1R-M3iakEC8yha98d8VIvEsd2Kc79bjWCFlMK1M0kkdEJBjbAhAjmEXWfbYkNdnrT6DhhLkQdulVPsIuDkJYWAVhk8aZ9KF3IZ-xGiw?key=lYln-58pvChvGvHg5Z5QrA


Now that we've sorted that out, we can go back to the menu and make the start button work. First, we need to give the Game MovieClip an instance name. Now we can do this

this.startbtn.addEventListener(MouseEvent.CLICK, startgame);

function startgame(event:MouseEvent):void {
	Object(root).game.gotoAndStop(“eduardos”);
}


(Pro Tip: Press Ctrl+Shift+F to auto format, which makes it look nicer)


Make sure to put inside of the gotoAndStop the label of the frame you want it to go next, which may be an intro or the first room, and put it in quotes. Oh, and that root thing? Well..

In AS3, there are 2 ways to call an object: Relative and absolute.


AD_4nXc_8WIUaJmYUkJ3Xugw_tAGT3iuFmpIdDWYCs7Lox2MsAYHbWTVVJy3jDtgJqsSOLvZNEwkhW3ltNnODV7tasu2drFam0NZIbzfstWKnWV2qsmxmHrtUrFyXueQKTeiTGBeuP_Ekg?key=lYln-58pvChvGvHg5Z5QrA


Relative is with where you are currently at, so if I wanted to call an object inside of another object, you can do

this.headmc.eyesmc.gotoAndPlay(1); 

You can also go backwards and refer to a parent of an object, although it's a little clunky. Using Object(this.parent.parent)


AD_4nXfIX8bH8CgUPGbYDzmZEOPoyTVUOnvIhbghrPyLl1LB84_w_Hdm2-3zNZWNxTsOqTUYNKFPbuLJvmga1zK9SYF24ExKf4DKA2t8wHEdsX37YhroZgJBAScQPcEnTaDz3SBnfTf4Cw?key=lYln-58pvChvGvHg5Z5QrA

Absolute is starting from the root and going down the branches, using the Object(root) prefix.

Object(root).guymc.headmc.eyes.mc.gotoAndPlay(1);


Flash has a menu in the Actions panel (looks like a crosshair) to be able to call movieclips, buttons, and texts quickly, with the option to choose to call the object relatively or absolutely. My rule of thumb is, if you are referring to parent objects, use absolute, else use relative.


AD_4nXc6kMWsexWi4L1-qDfH6fQo8jj3vrRVvQPXuOfdC9ZA7o4ztfGN-udL1HT-4bFT16irhs26g-eS9SX7YsnmFpEdcT4wrb9SQDnNBXuxOTO3TrGXU3pgn0YIXZT_m-kS_k8fSFOx3A?key=lYln-58pvChvGvHg5Z5QrA


We can test the game by pressing Ctrl+Enter and….. Oh wait, we forgot the most important keyword in the entirety of Flash (according to my brother) stop(); which does exactly that. This needs to be added inside the Game MovieClip, with all the labels on their own layer that simply has stop();


AD_4nXeLIDWgjgOsTt8P0cTwQCczvU23wH_L_oeUI1YmV9LkAxpzsOaabnPUKbmU0c4NeBeZlyMDXK3FrUeEy6APBTriCY3YyJxoTMLSe7Xu2e9LF9ZPxlxPQ_JiHLglJ2kotmwiy84G?key=lYln-58pvChvGvHg5Z5QrA

(Pro Tip #2: Name your layers so you know where everything is)


Oh, and one last thing before we continue, add semicolons to the end of a line (as long as there aren’t any brackets). This is used to indicate to Flash that it’s the end of the line and to move on to the next one. Luckily, Flash isn’t strict on it (unlike other languages) and will let you get away with not putting any. But, you know, it’s common practice to do it, and I’ve had cases (okay, one) where a semicolon made it work.


Okay, so now that root is explained, we can now test the game by pressing Ctrl+Enter and click! Anytime the compiler (the magic thing that turns it into a swf file) throws an error, the final result will just play as if it were an animation. Getting a warning won’t do this, although it should probably be fixed either way.


Tags:

1

Comments

Comments ain't a thing here.