dcsimg
A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Selecting Items from an Inventory

  1. #1
    Registered User
    Join Date
    Dec 2010
    Posts
    1

    Exclamation Selecting Items from an Inventory

    So you start off with all of the items in the inventory. You do not have to collect them.

    I have 8 MovieClips on the stage each with a different instance name. I made a class called Rebound and linked all the inventory MoivieClips to the Rebound class as the base class. they each have their own unique class.

    What I'm trying to do is select one of them. when you release the mouse off the movie clip (MOUSE_UP)

    it goes to frame 2 of its movieclip and making a variable I made up called isSelected = true.

    but when you click another item in the inventory I want it to deselect the item you clicked first so it goes back to frame 1 and isSelected = false. The problem I'm having is that it selects the first item when you click it. But when I click another the first stays on frame 1 and isSelected stays true. So if I click all 8 in a row they all become selected.

    here's the class





    Code:

    package {

    import flash.display.MovieClip;
    import flash.events.MouseEvent;

    public class Rebound extends MovieClip {

    public var isSelected:Boolean;

    public function Rebound():void {
    this.addEventListener(MouseEvent.MOUSE_UP, starting);
    }

    public function starting(e:MouseEvent):void {
    this.isSelected = false;
    this.gotoAndStop(1);
    e.currentTarget.gotoAndStop(2);
    e.currentTarget.isSelected = true;
    }

    }

    }




    I thought this. called on every movieclip of the Rebound class?

    So instead of this. if there is something that can choose all of the movieclips that belong to the Rebound class I think I could use that instead. If there is such thing.

    Help would be much appreciated. Thanks.

  2. #2
    :
    Join Date
    Dec 2002
    Posts
    3,518
    Code:
    package {
    	import flash.display.MovieClip;
    	import flash.events.MouseEvent;
    
    	public class Rebound extends MovieClip{
    		public static var currSelected:Object;
    
    		public function Rebound() {
    			this.addEventListener(MouseEvent.MOUSE_UP, starting);
    		}
    		public function starting(e:MouseEvent):void {
    			if (currSelected != null){
    				currSelected.gotoAndStop(1)
    			};
    			e.currentTarget.gotoAndStop(2);
    			currSelected = e.currentTarget;
    		}
    	}
    }

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