Flash Advisor logo
:: Desktop Shortcut
:: Flash Help
Advice from Experts

Closed Thread
Results 1 to 4 of 4
  1. #1

    Default Inventory System

    Ok Im making a RPG game: (Here it is in development) (arrow keys to move)

    http://www.imgupload.co.uk/uploads/b...d95764a4ef.swf

    In the frame I have:

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


    Among other stuff - and on items which can be picked up I have:

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


    - Yay that works fine. But now when I try to Have it so you click a "Inventory" button the inventory pops up - I get this:

    http://www.imgupload.co.uk/uploads/e...5d05bdde1e.swf

    Code on the Items:

    onClipEvent (enterFrame) {
    if (_root.character.hitTest (this)) {
    _root.inventory.addToslot (this);
    }
    }


    Code on the two frames of the inventory MC:

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


    I now longer have that script on the main page. And the two Items are inside the inventory MC

    What should happen?
    Upon touching the two items - they should both go into inventory whenever its popped up or closed. (and you can turn the inventory off and on without it messing up)

    What Happens:
    Touching the two items with the invent closed does nothing - if you turn it on then and touch them - nothing happens.
    But if you touch the items for the first time with the inventory open - they go into the invent - but they dont close when the inventory closes.

    I think part of it is to do with the mc inventory having two frames - with the script on both frames - presumably I could use attachMC which Im new at.

    Making the items disspear with the inventory when closed could be solve (i think_ with just _root.item = false; or something.

    Help please?

  2. # ADS
    Join Date
    Always
    Posts
    Many
     
  3. #2
    Join Date
    May 2004
    Location
    U.S.A.
    Posts
    2,890

    Default

    Hi,

    What comes to mind offhand is not using two frames for your inventory movieclip but rather a single frame and toggle the _visible or _alpha property to reveal it when necessary. If your movieclip is on frame 2 when you try to add to the inventory, frame 1 will not pick up the data. One other thing, code is much easier to edit and manage if on the first keyframe of the main timeline. Frame code vs object code has been discussed in many threads in this forum. There are numerous advantages of using Frame code over Object code. The only real difference is that frame code applies it's actionscript to objects by instance name as opposed to residing directly on the object itself.

    NTD
    A mind once stretched by a new idea never regains its original dimensions.
    - Oliver Wendell Holmes

  4. #3

    Default

    Hmm I cant to alpha because that would mess up other aspects of the game.
    But on the button would I have something like;

    _root.inventory _visible = false;

    or:

    _root.inventory _toggleVisible

    Ill try it.

  5. #4

    Default

    http://www.imgupload.co.uk/uploads/5...6a26495bcd.swf

    The only problem is that even with the items with:

    onClipEvent (enterFrame) {
    if (_root.character.hitTest (this)) {
    _root.inventory.addToslot (this);
    }
    }

    the items still have to be in the inventory clip - so they disspear even when not in the inventory! Anyway to solve this? I think I need to do something with parent..

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Sponsors
Create Speaking Characters for your website and Flash movies. 15 Day Free Trial