dcsimg
A Flash Developer Resource Site

Results 1 to 2 of 2
  1. #1
    Junior Member
    Join Date
    Mar 2018
    Posts
    2

    [Point n Click] Inventory

    Hey guys i'm trying to create a point n click game using AS3 and external files and i'm having a hard time to get the invetory working.

    So let me explain that better...

    The game I want to create is an escape game ( You're locked in a room and need to find itens and hints to get out of there)

    On my .fla file (Teste.fla) there's a hammer handle and a hammer head. Both are movieclips (head name = cabeca and handle name = cabo).

    Here are my codes so far.

    Cabo.as:

    Code:
    package{
    		public class Cabo extends Teste
    	{
    	}
    }
    Cabeca.as:

    Code:
    package{
    		public class Cabeca extends Teste
    	{
    	}
    }
    Teste.as:

    Code:
    package {
    	
    	import flash.display.MovieClip;
    	import flash.events.MouseEvent;
    
    	public class Teste extends MovieClip
    	{		
    		public function Teste():void
    		{
    			buttonMode = true;
    			addEventListener(MouseEvent.CLICK, pegaritem);
    		}
    		
    		protected function pegaritem (e:MouseEvent):void
    		{
    			parent.addChild(this);
    			trace("pegou "+name);
    			x = 50;
    			y = 330;
    			
    			width=50;
    			scaleX=scaleY;
    			
    			if(height>50)
    				{
    				height=50;
    				scaleX=scaleY;
    				}
    				
    			removeEventListener(MouseEvent.CLICK, pegaritem);
    		}
    	}
    }

    So the problem is: When I click on a movieclip (cabeca or cabo), they move to the same position.

    What I want to do is to get the side by side separated by a few pixels.

    I've been looking for a solution and i found out that i should arrange them on an Array... But unfortunately I have no idea how to do that.


    I'm pretty new to using AS3 and external files.


    Anyone has an idea how i can do that?

  2. #2
    Senior Member
    Join Date
    Feb 2005
    Posts
    1,769
    When you extend a class you're basically copy+pasting the code onto your new class. An array would be useful if you're working with an undetermined number of items. If you have like 2 items then don't worry about it. If you want to arrange things than you need to do so by using relative positions. So itemB.x = itemA.x+itemA.width and itemB.y = itemA.y Something like this would be simplest. Or you could do itemB.x+=itemA.width because they're being positioned in the same spot.
    .

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center

×
We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.