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:
212
Saves:
955
B/P Bonus:
12%
Whistle:
Normal
Medals:
254
Supporter:
15d

Making a click n' point game using AS3 | Step 5. Inventory & Items

Posted by Minix07 - 3 hours ago


Step 5. Inventory & Items

Inside the game MovieClip, make a new layer to put the inventory.

AD_4nXe2-VJv_hnXT5ah-fBwdbppQaud_7RLjdYIaFpSOpHzZRADLSOE1z5wNWc8Tjf65n976Y31G_WqXBKRxeXT_UHseRgA9FDqzFXuI3kBSatjuTYbA93gpXIUmbHec31WywBMRtIB1g?key=lYln-58pvChvGvHg5Z5QrA

Draw the inventory starting in the first room, as the inventory isn’t needed in the main menu or intro. Convert it into a symbol and give it an instance name. Inside the inventory, make a new layer to put the inventory boxes in and draw one box. Turn it into a MovieClip

AD_4nXf3qjVMATTgekRvKsOohGoufev249gFAKSN3G8JT8vYUziLkIqeQW-CmA3k6lzlPT1XW4Hq_znW7EpfDFbnwHSkaGKStUBamBBjPZTH-DzKDHmtyTqdGJl92dvSag-wqCVtrn2PdQ?key=lYln-58pvChvGvHg5Z5QrA


Using this movieclip, place as many as you want.

AD_4nXdM3sSJkF3BMT5WdOuC8_QK43Vg_nrYNI0QReEkprWOxG2kFI_gjlstsCcWbI6rlK7KgiV6yRRHBIiBNxvS7d0hObsDoULmPi8Onv3EQ4AKPdg03AunEf8ORixxWs7oHc1PmsFM?key=lYln-58pvChvGvHg5Z5QrA

(Pro tip #3: Use the align tool and, with align to stage off, use the space button to evenly space it out)


Now it’s time for the item part of this step. Inside your room, take one of the objects you want to make an item and give it an instance name, if you haven’t already. 

AD_4nXc-XO4R8VmOxmlBVu2nxzVxYgoO17tAmPzAjcbTgJpz8qvvUL8pLuFNn2UuY0YnVYlSVOWqSu1nENltzPQ5wdnLoJfCPK6ePeCVlionlJ1MQ3YTB3-9tt3gWvZz0j-OKJ1q51nuyg?key=lYln-58pvChvGvHg5Z5QrA


The cheez in question:

AD_4nXfBY4T9dFpjRElqNHMJaBb6PPeGIh0NAkVbCM9iqGo3Aqx9bdxYg-z4Lq4vC9i7Yxmzq_MclAF6lLmgv1JAOaAzENNEYW89aRKKaH8ekhqL2bClZnFU4vZ_RqZMZJHBoDciligJ1g?key=lYln-58pvChvGvHg5Z5QrA

(Pro tip #4: If the item is really small, draw a transparent white rectangle over it to give it a bigger hitbox.)


While still being inside the room symbol. Make a new layer to place da code in and use the same structure as making the start button.


this.cheezmc.addEventListener(MouseEvent.CLICK, cheezget);

function cheezget(event: MouseEvent): void {
	
}

Go back to the inventory and into any of the inventory boxes, make a new frame to place your item in.

AD_4nXfCWSj-Td7fQFrT3E8lTaoXEZdS2eRKgCK1kUSA8QxlVmy69g_NPXRbH_6_By62tVufWWwoahkTgXscyCdgfcfA5G-LdlKs1xSO6-r6YWBE8K_P814RbNeBaGV3eMKiVi1xBrOdVQ?key=lYln-58pvChvGvHg5Z5QrA

Make sure to place a stop(); on the first frame to prevent it from going through all the frames and making it flicker. Make a new layer to place the labels on.


AD_4nXfTv2_16CoWtd6KcjgUjSMt3ubK14gOOlcMtB87IFEBe3LAoeePv0xtlEH9yDQ9Pb_EdShe1jpLpsSyHUeTS4_c_spOqPhNlgbqYEaCV5guTSj2q1UenzfOYsjfjRlEMc4hUjiiVQ?key=lYln-58pvChvGvHg5Z5QrA

I have it zoomed in so you can see the label.


Exit it out of the InvBox symbol and give each of them an instance name. Number them off like Invbox1, Invbox2, Invbox3, etc. Be sure to also give the inventory as a whole an instance name. Now, going back to the room where the item is, we can finish the code by telling one of the inventory boxes to go to the “cheez” frame (or whatever you called your frame). Use the previously mentioned target patch to find the item box.


AD_4nXcv2lD9XtDAbFk2W0EULdwJ0oiEnW51u7UXhVf_-8Hatl3CjaegrQNDvi1x_Ois7LV11AxKsCQUaUVGBWdySFHWJtsuFyKlvh_6OmnkJzL1lfJBSqN-DXToXFS5xGxH51GS1U6fXA?key=lYln-58pvChvGvHg5Z5QrA


this.cheezmc.addEventListener(MouseEvent.CLICK, cheezget);

function cheezget(event: MouseEvent): void {
	Object(root).game.Inventory.Itembox3.gotoAndStop(“cheez);
}

Ctrl+Enter to test it, and it should work. However, the cheese is still showing. This can be easily fixed by using the visible property. To make a long story short, each object has properties that you can edit. To make it invisible, you change the visible property to false.


this.cheezmc.addEventListener(MouseEvent.CLICK, cheezget);

function cheezget(event: MouseEvent): void {
	this.cheezmc.visible = false;
	Object(root).game.Inventory.Itembox3.gotoAndStop(“cheez);
}

Test it, and now it should disappear. 


If you want it so, every time a new item is picked up, the box flashes, go inside the Invbox MovieClip, make a new layer, create a square, and convert it into a symbol. Create the animation that is played every time you pick up a new item. I just did a simple fade.

AD_4nXcMPuG7vdyxCqH9jJXwTxU3ZZNbgK-mnTbGrFPj9i8J5nHyNZnZUS4lDha5MxK9yoN38wdxWLguFSmR0cNMh_CbRfdq8yZqU-WkyXkaHDD7ao0gyn9ykXPjAsVXp0xxHMOiVncqsA?key=lYln-58pvChvGvHg5Z5QrA

When making the fade, make sure the last frame contains a stop(); so it doesn't loop. Make this layer span the whole thing and give it an instance name.

AD_4nXdEYzHQ93XEcfKYM75hpD1fPhiqeRumUtQbwK2dFjsUcRzIphYnn-qyjXT7Xun8wfpREV8z0P-3_n9vYETM2pnE3wBGm_at254zWI67z7_0nQ2QGn37addFzJaLrz54JVct0AX0?key=lYln-58pvChvGvHg5Z5QrA


Now, we need to update the code to make it play this MovieClip.

this.cheezmc.addEventListener(MouseEvent.CLICK, cheezget);

function cheezget(event: MouseEvent): void {
	this.cheezmc.visible = false;
	Object(root).game.Inventory.Invbox3.Itemboxflash.gotoAndPlay(1);
	Object(root).game.Inventory.Invbox3.gotoAndStop("cheez");
}

I don’t think I have to explain what gotoAndPlay does, it's literally in the name of what it does.


Tags:

1

Comments

I like this tutorial omg

I'm glad you're enjoying it, even if currently incomplete.