Welcome to Dream.In.Code
Become an Expert!

Join 136,901 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,733 people online right now. 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
27 Jul, 2008 - 09:15 PM
Post #1

New D.I.C Head
*

Joined: 11 Jul, 2008
Posts: 31

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
+Quote Post

BetaWar
RE: Xscale Doing Something When It Reaches 0 (going To Frame Or Something)
27 Jul, 2008 - 09:24 PM
Post #2

#include <soul.h>
Group Icon

Joined: 7 Sep, 2006
Posts: 2,032



Thanked: 82 times
Dream Kudos: 1175
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
+Quote Post

cadeownz
RE: Xscale Doing Something When It Reaches 0 (going To Frame Or Something)
27 Jul, 2008 - 09:43 PM
Post #3

New D.I.C Head
*

Joined: 11 Jul, 2008
Posts: 31

OMG thanx againg ur awsome!!!
User is offlineProfile CardPM
+Quote Post

BetaWar
RE: Xscale Doing Something When It Reaches 0 (going To Frame Or Something)
27 Jul, 2008 - 09:46 PM
Post #4

#include <soul.h>
Group Icon

Joined: 7 Sep, 2006
Posts: 2,032



Thanked: 82 times
Dream Kudos: 1175
My Contributions
No problem, just glad to have helped smile.gif
User is offlineProfile CardPM
+Quote Post

cadeownz
RE: Xscale Doing Something When It Reaches 0 (going To Frame Or Something)
27 Jul, 2008 - 10:37 PM
Post #5

New D.I.C Head
*

Joined: 11 Jul, 2008
Posts: 31

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
+Quote Post

BetaWar
RE: Xscale Doing Something When It Reaches 0 (going To Frame Or Something)
28 Jul, 2008 - 08:55 PM
Post #6

#include <soul.h>
Group Icon

Joined: 7 Sep, 2006
Posts: 2,032



Thanked: 82 times
Dream Kudos: 1175
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
+Quote Post

cadeownz
RE: Xscale Doing Something When It Reaches 0 (going To Frame Or Something)
1 Aug, 2008 - 12:12 AM
Post #7

New D.I.C Head
*

Joined: 11 Jul, 2008
Posts: 31

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
+Quote Post

BetaWar
RE: Xscale Doing Something When It Reaches 0 (going To Frame Or Something)
1 Aug, 2008 - 02:39 PM
Post #8

#include <soul.h>
Group Icon

Joined: 7 Sep, 2006
Posts: 2,032



Thanked: 82 times
Dream Kudos: 1175
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
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/3/08 09:37PM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month