A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: making a simple power bar

  1. #1
    Member
    Join Date
    Feb 2002
    Posts
    53

    Lightbulb

    Hi,

    I want to add a simple power bar to one of my games. I want it to scroll up and down quickly and stop somewhere between 0-100% when the player presses a button or clicks the mouse. It needs to work on a relatively slow frame rate - ie. 15fps.

    I tried drawing a rectangle and using a " onClipEvent (enterFrame)... _xscale++ " type script, but this makes the rectabgle scroll up and down much too slowly.

    Can anyone briefly outline a better way of doing it ???

    Thanks in advance ...

    Ben

  2. #2
    Gross Pecululatarian Ed Mack's Avatar
    Join Date
    Dec 2001
    Location
    UK
    Posts
    2,954
    Make a 100 px bar, and put this code in it:

    Make sure the bar is aligned to the left of the little circle marking the middle of the MC

    Code:
    onClipEvent (load) {
    	speed = 10;
    }
    onClipEvent (enterFrame) {
    	if (_xscale+speed>100 || _xscale+speed<0) {
    		speed *= -1;
    	}
    	_xscale += speed;
    }
    onClipEvent (mouseDown) {
    	// Do whatever. Power = _xscale;	
    }

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