Welcome to Dream.In.Code
Getting Help is Easy!

Join 109,558 Programmers for FREE! Ask your question and get quick answers from experts. There are 1,377 online right now! We've got more than 500 tutorials and 2,000 snippets. Join and find out why Dream.In.Code is the #1 programming help community on the internet! Registration is fast and FREE... Join Now!



Xscale doing something when it reaches 0 (going to frame or something)

 
Reply to this topicStart new topic

Xscale doing something when it reaches 0 (going to frame or something)

cadeownz
post 27 Jul, 2008 - 10:15 PM
Post #1


New D.I.C Head

*
Joined: 12 Jul, 2008
Posts: 30

hey iv got a code for a health bar and i want it to do something (go to a frame or something) when it reaches 0 .
heres the code . . .
CODE
onClipEvent(enterFrame){
    this._xscale= _root.Ehp;
    if(_root.Ehp<=0) {
        _root.Ehp=0;
}
    this._xscale= _root.Ehp;
    if(_root.Ehp>=100) {
        _root.Ehp=100;
}
}

thanks in advance. . .
User is offlineProfile CardPM

Go to the top of the page


BetaWar
post 27 Jul, 2008 - 10:24 PM
Post #2


#include <soul.h>

Group Icon
Joined: 7 Sep, 2006
Posts: 1,266



Thanked 38 times

Dream Kudos: 775
My Contributions


try

CODE
onClipEvent(enterFrame){
  if(_root.Ehp<0){
    _root.Ehp = 0;
  }
  else if(_root.Ehp>100){
    _root.Ehp = 100;
  }
  this._xscale = _root.Ehp;
  if(this._xscale == 0){
    //DO ACTIONS FOR DEATH HERE
  }
}


Hope tha thelps.
User is offlineProfile CardPM

Go to the top of the page

cadeownz
post 27 Jul, 2008 - 10:43 PM
Post #3


New D.I.C Head

*
Joined: 12 Jul, 2008
Posts: 30

OMG thanx againg ur awsome!!!
User is offlineProfile CardPM

Go to the top of the page

BetaWar
post 27 Jul, 2008 - 10:46 PM
Post #4


#include <soul.h>

Group Icon
Joined: 7 Sep, 2006
Posts: 1,266



Thanked 38 times

Dream Kudos: 775
My Contributions


No problem, just glad to have helped smile.gif
User is offlineProfile CardPM

Go to the top of the page

cadeownz
post 27 Jul, 2008 - 11:37 PM
Post #5


New D.I.C Head

*
Joined: 12 Jul, 2008
Posts: 30

ok how do you make it go to another movieclips specified frame? if its possible? i tryed to make it go to my enemy by going enemy.gotoAndPlay(2); but nothing happened can someone/BetaWar shed some light?
User is offlineProfile CardPM

Go to the top of the page

BetaWar
post 28 Jul, 2008 - 09:55 PM
Post #6


#include <soul.h>

Group Icon
Joined: 7 Sep, 2006
Posts: 1,266



Thanked 38 times

Dream Kudos: 775
My Contributions


You will want to look into the position of the 'enemy' mc. If it is on root you will be able to call it through _root.enemy if it is in another movieclip you will have to call it through something more like _root.OTHERMC.enemy. In short yes, you can tell another mc to change its frame, you just have to make sure that all the instance names match up to create the path to the mc you are wanting to edit.

Also make sure that you are placing _root in front of the MC location. If you have 2 mcs on the main stage frame 1 and have one named 'a' and the other named 'b' and b having these actions:

CODE

onClipEvent(enterFrame){
    a._alpha -= 1;
}


Nothing happens, but if you have this instead:

CODE
onClipEvent(enterFrame){
    _root.a._alpha -= 1;
}


It works.

That is because when you have just the a._alpha it is looking inside of mc 'b' for mc 'a' and not in root for mc 'a' which means that it finds nothing unless you put it there.

Hope that makes since smile.gif and sorry it took so long for me to get back to you.
User is offlineProfile CardPM

Go to the top of the page

cadeownz
post 1 Aug, 2008 - 01:12 AM
Post #7


New D.I.C Head

*
Joined: 12 Jul, 2008
Posts: 30

dude, YOU ARE FREAKIN AWSUM!!!!
ur like a flash legend my rpg is going along nicely now thnx to u, ur awsum my rpg wouldnt exist 2day if it wernt 4 u.
Oh and do u play halo? i got halo3 xbox live im lvl 40 (colonol G2) and all acheivments,, my gamertag is "Detailed"
Yeah thnx 4 all ur help sorry if this is relly late havnt bin on l8ly
User is offlineProfile CardPM

Go to the top of the page

BetaWar
post 1 Aug, 2008 - 03:39 PM
Post #8


#include <soul.h>

Group Icon
Joined: 7 Sep, 2006
Posts: 1,266



Thanked 38 times

Dream Kudos: 775
My Contributions


That is fine, no problem.

I do play Halo on occassion, if you want there is a whole topic with gamertags and stuff located here:
http://www.dreamincode.net/forums/showtopic45156.htm

I haven't really played much for matchmaking (or ranked playlists) and am only like lvl 2 (or something) but I haev beaten the game and stuff, most of the time when I play now I try to make new maps and have fun on them.
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 9/7/08 11:15PM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month