Runescape/WoW-Ish RPG AS Help/Debugging

Ok, so lets say I get CS3. I know absolutely ZERO knowledge about AS3. And how will I change my current .fla file to a AS3 Document? Do I have to start over on a new AS3 Document or can I just change the file type from AS2 to AS3? Also, can you give me some good links for basic AS3 tutorials? Thanks.

You will find this exceptionally helpful for moving onto AS3…

[quote=bluemagica;2324976]You will find this exceptionally helpful for moving onto AS3…

Thanks, I’ll be sure to check it out. Now, does anyway have a answer/tips to my current inventory problem?

You started alright with your inventory, but then you are going a bit off-track with the duplicating bit. There are many ways of doing an inventory, but i will tell you a simple way. First Make a tweened background for your inventory, like you have done…Now, go inside this , say invBack_mc. And move it in such a way that the origin point of the invBack_mc lies exactly on the top left corner position, from where you want to start placing the slots. Now comes the fun/trick portion. Make a new mc say 32x32 or so, and call it invSlot_mc , and on the first frame draw a empty square to act as the slot on where to place the items.And then on each successive frame put the pictures of your inventory items, sword, potion, whatever. i hope you have got the idea by now, anyway…

Next just think up how many slots you want in your inventory, 3 columns and 4 rows…


var slot=new Array();
var pos_x=this._x;
var pos_y=this._y;
var gap=5;
for(var i=0;i<4;i++)
{
   for(var j=0;j<4;j++)
   {
      slot[i+j]=this.attachMovie("invSlot_mc","slot_"+(i+j),this.getNextHighestDepth());
      slot[i+j]._x=pos_x
      slot[i+j]._y=pos_y
      slot[i+j].gotoAndStop(1);
      slot[i+j].state="free";
      pos_x+=pos_x+gap;
   }
 pos_y+=pos_y+gap;
}

Now when you make the item mc’s, give them a “item_id” equal to the slot frame number. so on collision


for(var i=0;i<slot.length;i++)
{
 if(_root.invBack_mc.slot*.state=="free")
 {
  _root.invBack_mc.slot*.gotoAndStop(item_id);
  _root.invBack_mc.slot*.state=="item_id";
 } //remember to remove the mc though;
}

This is a very simple way of doing it, if you want to attach actual mc, then just use attachMovie() instead of simple frames.

There are loads of other ways, and most times each coder has his own ways…try to find a way for yourself too :wink:

[quote=bluemagica;2325409]You started alright with your inventory, but then you are going a bit off-track with the duplicating bit. There are many ways of doing an inventory, but i will tell you a simple way. First Make a tweened background for your inventory, like you have done…Now, go inside this , say invBack_mc. And move it in such a way that the origin point of the invBack_mc lies exactly on the top left corner position, from where you want to start placing the slots. Now comes the fun/trick portion. Make a new mc say 32x32 or so, and call it invSlot_mc , and on the first frame draw a empty square to act as the slot on where to place the items.And then on each successive frame put the pictures of your inventory items, sword, potion, whatever. i hope you have got the idea by now, anyway…

Next just think up how many slots you want in your inventory, 3 columns and 4 rows…


var slot=new Array();
var pos_x=this._x;
var pos_y=this._y;
var gap=5;
for(var i=0;i<4;i++)
{
   for(var j=0;j<4;j++)
   {
      slot[i+j]=this.attachMovie("invSlot_mc","slot_"+(i+j),this.getNextHighestDepth());
      slot[i+j]._x=pos_x
      slot[i+j]._y=pos_y
      slot[i+j].gotoAndStop(1);
      slot[i+j].state="free";
      pos_x+=pos_x+gap;
   }
 pos_y+=pos_y+gap;
}

Now when you make the item mc’s, give them a “item_id” equal to the slot frame number. so on collision


for(var i=0;i<slot.length;i++)
{
 if(_root.invBack_mc.slot*.state=="free")
 {
  _root.invBack_mc.slot*.gotoAndStop(item_id);
  _root.invBack_mc.slot*.state=="item_id";
 } //remember to remove the mc though;
}

This is a very simple way of doing it, if you want to attach actual mc, then just use attachMovie() instead of simple frames.

There are loads of other ways, and most times each coder has his own ways…try to find a way for yourself too ;)[/quote]

Thanks a whole bunch ^^ I figured out a way to dynamically do the sliding animation so thats one thing I don’t have to worry about. Now, for the inventory. I dont really want to make a empty frame for each item, since theres going to be a hell lot of items in this game. I just want to create a database with all the items/item id in it(something like a array), then just duplicate a copy from that database whenever a player needs a item. Or I could just assign each item with a id, and create a database full with items idea, then attach a item from the library according to the ID. Is there anyway to do that?

PS: This is my current code for my inventory, although I have no idea how it works and for some reason, it only works if the slots are not in another symbol.

On The Frame:

function addToslot (item) {
if (!item.found) {
item._x = eval (“itemSlot” + currentslotnum)._x;
item._y = eval (“itemSlot” + currentslotnum)._y;
item.found = true;
currentslotnum++;
}
}

On The Items:

onClipEvent (enterFrame) {
if (_root.player.hitTest (this)) {
_root.addToslot (this);

}

}

-_- you didnt understand what i said, did you? I am not telling to make a empty frame for each item, rather i am telling you to put the images of all items under one mc.

Still don’t get what you mean -_- I know I really suck at ActionScript but I just don’t get your code and what you’re trying to explain.

He means create one movieclip which will be a ‘slot’ picture - in each successive frame draw each item as if it was taking up that slot -

So if you had a potion a sword and a key your movieclip would contain:

Frame 0: Empty slot
Frame 1: Slot with potion in
Frame 2: Slot with sword in
Frame 3: Slot with key in

Then you would make sure that the potion had a database ID of 1, the sword an ID of 2 and the key an ID of 3.

It would work and it’s a good idea. Of course I might change a few things, like making a slot item it’s own class and maybe using a case statement to select the frame of each item based on a string rather than an ID then making the name of each item unique in the database - just in case item IDs change.

Ok, so tell me if I’m getting this right.


So how you assign a item with a database ID?

Also, I have no idea about whats a case statement, a class, etc.

ah i know what case statements are now ^^. But how does that relate to my inventory problem? I’m confused again.

-_- Charleh, you are right about the class and string, but jephz is too new, and he needs to know more of the basics first before going to those concepts like class. As for using id instead of string, it will make lesser code at the moment, cause say sword has a id=3, then we know the swords image must be on frame 3; hence we can skip the switch case and such statements at the time…I believe in taking one step at a time, and thats why i showed it in that way.

and Jephz, i see you got cs3, so you will have to learn more of OOP now…anyway, if you still dont understand what i was trying to tell you, then you should hold on for 2 days, and i will make you an example by then!!

[quote=bluemagica;2325921]-_- Charleh, you are right about the class and string, but jephz is too new, and he needs to know more of the basics first before going to those concepts like class. As for using id instead of string, it will make lesser code at the moment, cause say sword has a id=3, then we know the swords image must be on frame 3; hence we can skip the switch case and such statements at the time…I believe in taking one step at a time, and thats why i showed it in that way.

and Jephz, i see you got cs3, so you will have to learn more of OOP now…anyway, if you still dont understand what i was trying to tell you, then you should hold on for 2 days, and i will make you an example by then!![/quote]

thanks a lot blue, same to you Charleh ^^. Oh, and I didn’t get CS3 its just the 30-Day trial. Flash cost a hell lot of $$$ which I don’t have. I’m currently working on some item graphics in Photoshop. They are coming along great. I’ll post a new version of the game with updated graphics in no time.

Ah dogpoop, never had to bump this topic before but here it goes:

BUMP

PS: I updated a new problem.

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?