Runescape/WoW-Ish RPG AS Help/Debugging

Excellent… please keep going with this.

What I really want to ask is, are you American McGee’s son? Ps. If so how is grim going?

Um…what? Whos American Mcgee?

He made Alice and some other games. He took up a new project that is smaller in scope than usual and he moved to China to do it. I figured that you probably weren’t but the stuff you’re working on just made me thought it for some reason.

[quote=therobot;2325664]Case statements are a lot like if…then statements, they just have a different structure

var a:String = "arrow";

// This:
switch( a )
{
    case "sword" :
        trace ("sword");
        // Break must be added for each case
        break; 
        
    case "shield" :
        trace ( "shield" );
        break;
        
    case "arrow" :
        trace ( "arrow" );
        break;
        
    default :
        trace ( "var does not match criteria" );
}

// Is pretty much the same as this:    5
if ( a == "sword" )
{
    trace ( "sword" );
}
else if ( a == "shield" )
{
    trace ( "shield" );
}
else if ( a == "arrow" )
{
    trace ( "arrow" );
}
else
{
    trace ( "var does not match criteria" );
}

A class is a blueprint for an object. See also: object oriented programming. They’re really great :rambo:[/quote]

Ok I did some playing around with case statements and I have a few questions:

  1. How do you change the variable inside the case statement? For example, you first set the “a” string to “arrow” in the beginning. Now I want to change that to lets say “sword”. How do I that? I tried a = “sword” but it still doesn’t work.

  2. So why use case statements? Isn’t case statements the same as variables?

Thanks in a advance for any help.

here’s a inventory example i made for you…its kinda bit sloppy, since the code is mostly within the movieclip instances, but still you can use it for a starting ground. Oh, click on the inventory to close/open it and click on items to add them to inventory, and likewise, click to move them out of it.

God damnit, I feel like a noob. I only get like 4/10 of the coding, don’t really understand it. Can someone break it down and explain it to me?

PS: Thanks a LOT blue

Heres the code:

On The Frame:

trace(inventory._x)
_global.additem=0;//means empty
_global.inventory_list=new Array(0,0,0,0,0,0,0,0,0,0,0)//initialise an empty array to hold the slot number
inventory.moveInv=-1;


onEnterFrame=function()
{
    if(_global.additem!=0)
     {
         for(var i=1;i<=_global.inventory_list.length;i++)
         {
             if(_global.inventory_list*==0 and _global.additem!=0)
             {
                 trace(_root.inventory["i"+i]+"        "+i+"  "+_global.additem);
                 _root.inventory["i"+i].gotoAndStop(_global.additem+1);
                 _root.inventory["i"+i].myi=i;
                 _root.inventory["i"+i].myitemid=_global.myitemid;
                 _global.inventory_list*=_global.additem;
                 _global.additem=0;
                 //break;
             }
         }
         if(_global.additem!=0)
          {
              _root.inventory.errortxt.text="No more space";
              _global.myitemid._visible=true;
              _global.myitemid=0;
              _global.additem=0;
          }
     }
}


inventory.invZone.onPress=function()
{
    _root.inventory.moveInv=-_root.inventory.moveInv;//change moving direction
}



inventory.onEnterFrame=function()
{
    if(this.moveInv==1)
    {
      if(_root.inventory._x>580)
         _root.inventory._x-=20;
    }
    if(this.moveInv==-1)
    {
      if(_root.inventory._x<=740) 
         _root.inventory._x+=20;
    }
}

On The Slots:

on(press)
{
_global.inventory_list[myi]=0;
this.myitemid._visible=true;
this.gotoAndStop(1);
_root.inventory.errortxt.text="";
}

On The Items:

on(press)
{
    _global.additem=1;
    _global.myitemid=this;
    this._visible=false;
}

Any help would be appreciated.

Never mind, I figured it out by myself. Btw, can anyone teach me how to set boundaries for a scollable terrain?