Sorry Statement Below Should Say "if Statements..."
---
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Many IF Statements Or One Sine Statement?
Hi, for my game i have a rotating man that moves in one of 16 directions. Now would it be better (in performance terms) to use 8 IF statements to control his movement or just one Sine calculation??
Bit of a conumdrum for me...
Loading Data From XMl File And Uses It To Run An If Statement. If Statement Fails.
[Flash CS3 (Flash 8 available as well)]
[Actionscript V2 (AS3 Not available for this project. End result must be in AS2. Plus I haven't learned AS3 yet)]
Hi
Sorry about running two posts so close together, but I couldn't change the other one to reflect the changes I've made in my problem.
The 1st post dealt with my theory that my IF statement wasn't written correctly, and so failed. But I've since disproved that.
Okay here is the situation.
I isolated elements from a larger app that I'm putting together and the problem still followed.
The Flash movie contains 2 Text files, one Component button, and 1 component checkbox.
The purpose of the application is to load an XML file(works)
Populate 2 text fields with information from the XML file(works)
Compare the two text fields, if they contain the same information then the checkbox, via AS is told to be selected. (Heres the problem);
Heres the code:
Code:
runCode_btn.onPress = function() {
data_xml = new XML();
data_xml.ignoreWhite = true;
data_xml.onLoad = function(success) {
if (success) {
//point to the first node with information
var track_xml = data_xml.firstChild;
//loop through each node
while (track_xml != null) {
//print out each node
test1 = track_xml.toString();
//point to the next node
track_xml = track_xml.nextSibling;
//Runs my code
//Define the contents of two text fields located in the movie
textOne = data_xml.firstChild.childNodes[3].firstChild;
textTwo = data_xml.firstChild.childNodes[5].firstChild;
trace("data_xml.firstChild.childNodes[3].firstChild = " + data_xml.firstChild.childNodes[3].firstChild);
trace("data_xml.firstChild.childNodes[5].firstChild = " + data_xml.firstChild.childNodes[5].firstChild);
/*dummyYes = data_xml.firstChild.childNodes[5].firstChild;
dummyNo = data_xml.firstChild.childNodes[6].firstChild;
dummyMaybeEmail = data_xml.firstChild.childNodes[3].firstChild;
dummyMaybeFax = data_xml.firstChild.childNodes[4].firstChild;*/
//Checks between the two text fields for a match
if (textOne == textTwo) {
trace("It is selected!" + textOne + " " + textTwo);
check_fax.selected = true;
} else {
trace("Ir is NOT selected!" + textOne + " " + textTwo);
check_fax.selected = false;
};
}
} else {
trace("error reading file");
}
delete data_xml;
};
data_xml.load("XML/dummy2 - email.xml");
};
After you read the code, you'll have noticed the trace commands I stuck in there.
They send this to the output panel:
Code:
data_xml.firstChild.childNodes[3].firstChild = 1
data_xml.firstChild.childNodes[5].firstChild = 1
Ir is NOT selected!1 1
So as far as I can see, it reads the XML file with no problems, it loads the text fields with no problem. But for some reason the IF statement refuses to recognize that both the XML nodes contain the same information.
If I alter the code like so:
Code:
textOne = 1;
textTwo = 1;
Then the IF statement works. It sees that the two text fields are identical in content, and the checkbox is selected.
So whats wrong with the Data from the XML file?
I haven't a clue.
I tried converting from a string to a Numeral using:
Code:
newText = Number(textOne);
But that didn't work, it just produced "NaN" when traced.
I tried populating the XML file with text versus numbers, still no luck.
What came from the trace:
Code:
data_xml.firstChild.childNodes[3].firstChild = hi
data_xml.firstChild.childNodes[5].firstChild = hi
Ir is NOT selected!hi hi
The idea behind this app is that its an electronic form. The user fills it out, the information is then sent to a newly created XML file, months later the open the XML file in flash, and Flash fills out text fields and check and or unchecks Checkboxes based on the XML data.
CheckBoxes are mandatory.
But I don't see how I'll be able to use them if i can't create and condition statements based on the loaded Data.
I'd really appreciate some help and suggestions with this, I think I'm out of ideas.
Thanks
-Lem
Problem With Continue Statement And Label Statement
What am I doing wrong?
ActionScript Code:
var a = {
a:[1,2,3,4,5,6,7,8,9,0],
b:[1,2,3,4,5,6,7,8,9,0],
c:[1,2,3,4,5,6,7,8,9,0],
d:[1,2,3,4,5,6,7,8,9,0],
e:[1,2,3,4,5,6,7,8,9,0],
f:[1,2,3,4,5,6,7,8,9,0],
g:[1,2,3,4,5,6,7,8,9,0]
}
outerLoop: for(var i in a){
trace(i);
for(var j in a[i]){
trace(' '+j);
continue outerLoop;
}
}
Quote:
1039: Target of continue statement was not found.
Converting 'If Else' Statement To A 'switch' Statement
I am attempting to convert the following If statement to a Switch statement and I'm unclear as to the details of the execution of it. If someone could help me with this I would be very grateful. Here is the If statement followed by the shell of my attempted switch statement. TIA.
var spotOne:Boolean = true;
var spotTwo:Boolean = false;
var spotThree:Boolean = false;
var spotFour:Boolean = false;
btn.onRelease = function() {
f (spotOne) {
ball.slideTo(450, 100, 1);
spotOne = false;
spotTwo = true;
} else if (spotTwo) {
ball.slideTo(450, 150, .5);
spotTwo = false;
spotThree = true;
} else if (spotThree) {
ball.slideTo(100, 150, 1);
spotThree = false;
spotFour = true;
} else {
ball.slideTo(100, 100, 1);
spotFour = false;
spotOne = true;
}
};
---------------------------------
(attempt at conversion to switch)
var spotOne:Boolean = true;
var spotTwo:Boolean = false;
var spotThree:Boolean = false;
var spotFour:Boolean = false;
btn.onRelease = function() {
var location:Number = ?
switch(location) {
case spotOne:
ball.slideTo(450, 100, 1);
spotOne = false;
spotTwo = true;
break;
case spotTwo:
ball.slideTo(450, 150, .5);
spotTwo = false;
spotThree = true;
break;
case spotThree:
ball.slideTo(100, 150, 1);
spotThree = false;
spotFour = true;
break;
case spotFour:
ball.slideTo(100, 100, 1);
spotFour = false;
spotOne = true;
break;
}
If Statements - Help Me
I have built this code to determine whether a button has been clicked to send it to a specific frame.
Trace(thisClick);
//Traces variable to return value as a test to me
if (thisClick=2) {
gotoAndPlay ("viewing");
} else {
stop ();
}
thisClick is returned as 0 but still the if statement runs.
For some reason Flash runs the code even though the variable thisClick is not equal to 2.
I have found that I must use this code instead but it is not as accurate and I would like to know why it is happening.
if (thisClick<>0) {
gotoAndPlay ("viewing");
} else {
stop ();
}
Should I use an else if ??
Thanks!
Help With If Statements
Basically for some reason I'm having problems with if statements - for some reason Flash wont allow me to use else if's it keeps saying it cant find matching if even though there is one directly above it - with correct amount of brackets andno syntax errors thoughout the script.
Other problem this is an extract of the code - i've traced it and it doesnt do the comparison correctly when sgoto = 1 it goes through the ==2 statemt too.
I've tried eq "1", ==1 and (eval(sgoto == 1))
but it still doesnt work any help would be greatly appreciated!!!
/:randomised = new Array();
for (var c = 0; c<5; c++) {
var rand = random(2);
trace ("rand "+rand);
trace ("selection array"+selection);
trace ("contents"+selection[rand]);
/:randomised[c] = selection[rand];
}
sgoto = /:randomised[0]; //take the first one
trace("goto!" + sgoto);
//theone = 0;
if (sgoto == 1) //equals a PROBLEM HERE
{
trace (sgoto +"==1");
theone = /:aArray[/:nextone];
trace("theone!"+ theone);
_root.cloud1.gotoAndStop(theone + 1);
_root.picture.gotoAndStop(theone +1);
start();
_root.gotoAndStop (3);
}
if (sgoto == 2) //equals e WANTED TO USE ELSE IF HERE
{
trace (sgoto +"==2");
var theone = /:eArray[/:nextone];
trace("theone!"+ theone);
_root.cloud1.gotoAndStop(theone + 1);
_root.picture.gotoAndStop(theone +1);
start();
_root.gotoAndStop (3);
}
Or Statements
hi there hope you can help.
I have an input box which users type a name into and a function which then uses that name to create a seperate section.
BUT, if they type for instance "Bob" I want it to not do the function.
Normally this would be fine as i would do:
Code:
if (input_text ne "Bob"){
gotoAndPlay("myfunction")
}
the problem is that if someone types "bob" or "bOb" or "BoB" etc etc it does not get stopped by the error check.
It gets more complicated.... the "not allowed" words are longer than bob, between 3 and 6 letters long and there are around four of them so it would ridiculous to have to enter all combinations of the words in order to put them in to the error checkin thing.
Any ideas????
If Then Statements?
OK, I want a button to have a telltarget action to play a movie within an instance. But, I only want it to play if a specific frame within that movie has been loaded. And vice versa -- I don't want it to play, if that frame has not been loaded.
-- I'm a designer, and far too unfamiliar with Actionscripts. Can anyone help????????
And Statements
Hello,
I have 2 input text fields in the same screen. One is called begindate and the other is enddate.
I want to be able to click on a button which will validate if the begindate = 01/01/01 and the enddate=12/31/01 and then goes to another frame.
My problem is AND and && give me errors when trying to use them.
How do I set up an AND statement with the data given?
thank you.
2 'if' Statements?
how can i script 2 'if' statements. I want two conditions to be met in order for one action to take place.
if this AND this happen then do that. otherwise. . .
If Then Statements Help
Hey there.
I need to do the following...
If (on roll out) button has not been clicked, play movie clip 1.
Else If (on roll out) button has been clicked, play movie clip2 instead and not movie clip 1.
How do I do this in Flash 5? I have no idea!
Thanks in advance,
Chris.
If Statements?
this is for the detection of a users bandwidth. i'm not familiar with the "if" statement. what i want to do is send the user to the page optimized for their bandwidth. so in the script below where would i put in...
getURL ("broadband_user.html", "_blank");
for broadband users and
getURL ("narrowband_user.html", "_blank");
for narrowband users?
*****the script*****
if (Number(/timer:time)>=15) {
time1 = "NarrowBand";
} else if (Number(/timer:time)<=15) {
time1 = "BroadBand";
}
time2 = 115/eval("/timer:time");
stop ();
********************
thanks for your help - matthew
If Statements....
I am interested if someone could tell me the code for:
I am looking for code for flash to reconize when a spaceship's shild has reached zero, to goto a different scene.
The code should be something like this...
if (variable) = 0 then goto scene 2
____________________________________________
Thanks,
Grant
If Statements
Does anyone know how to word an if statement checking to see if a movie is loaded into a level and if so to tell that movie in the level to go to and play a specific frame?
i.e.:
if there is a movie loaded in level2
tell it to go to and play frame 15
Please Help With If Statements
very simple question.......
//On the main timeline i declare a variable-
directionchange = 0;
//On a layer above is a movie clip named arrow-
//On a layer above i add this code-
if (_root.directionchange = 1) {
arrow._rotation += 45;
}
//finally a button on stage with-
On (release) {
_root.directionchange = 1;
}
//i want to control the rotation of the arrow with the value of a variable, but when you test this it ignores the if statement and rotates as soon as it loads.......Please, any assistance here?
Help With If Statements?
OK,
Im making a site for me animations, I upload daily and stuff and just recently I added an Archives page...I would like to have this one area load a movie and have two arrows on either side to navigate between them. So far I have it so it loads the movie, and you can go one movie up or one movie down with the buttons, but I dont know exactly how to get it to go beyond that...any help would be much apreciated!!
Help With If Statements?
OK,
Im making a site for me animations, I upload daily and stuff and just recently I added an Archives page...I would like to have this one area load a movie and have two arrows on either side to navigate between them. So far I have it so it loads the movie, and you can go one movie up or one movie down with the buttons, but I dont know exactly how to get it to go beyond that...any help would be much apreciated!!
If Statements
First off I have a button that when I roll over it it tells an mc to move to a certain location. What I want to know is if I have all ready rolled over it and the mc is in its other location, how would I tell that same button that if I rollover it and the mc is in that location not to do anything? Otherwise, if I roll over it again it jumps to the first frame and moves again, looks tacky...
Any help would be great, thanks william
Else If Statements
Maybe someone can help me figure this out...
Below is my code. It is a movie to detect keypresses. Basically what it is intended to do is the following:
-if a person presses Ctrl/C (nested below), Q1=correct.
-If a person presses anything but that combo, Q1 is incorrect.
This means I have to check first for any key press other than ctrl, and mark that as incorrect.
The tricky part is then tracking if the person does hit ctrl, I have to make sure that everything but ctrl followed by c is incorrect (ei, ctrl/a, ctrl/b, ctrl/d are all incorrect - only ctrl/c is correct).
Any ideas on how to do this? Seems like when I nest the two key downs and add and else statement, the second keydown is ignored. Below is my script:
onClipEvent (keyDown) {
pressed = Key.getCode();
if (Key.isDown(17)) {
if (Key.isDown(88)) {
_root.Q1 = "true";
_root.NextFrame();
}
}
}
Thanks!
If Statements
I'm using Flash MX.
Apologies in advance for the how basic this problem is.
I have a navigation menu, that I want the user to have control over with a button called "menu". The nav. menu is a MC called "buttons". When the user clicks 'menu', I want to use an if statement to determine where the 'buttons' MC is, and whether to push it off stage or pull it on stage.
So, for example, to begin with the menu is hidden. When the user clicks 'menu', the menu slides onto the stage, when the user clicks 'menu' again, the menu should slide off stage.
This is this code I am using:
on (release) {
if (_x._root.buttons = -740) {
setProperty("buttons", _x, 5);
} else {
setProperty("buttons", _x, -740);
}
}
This allows the menu to show up on 1st click, but does not remove the menu on 2nd click. What am I doing wrong?
Also, I know my code is inconsistent - can someone help me clean it up a little?
Eventually, I want to tween this menu with actionscript, how would I go about doing this?
Thanks in advance for your help.
Sid.
HELP On IF Statements Please
Please can someone help me out, I need an action script that will allow me to do the following:
*I have a number of drop down lists with numbers in them
*I want a number displayed in an uneditable box which changes when you pick a different number in the drop down box next to it!
*One drop down box to one uneditable outcome box!
Please can someone help me out! ASAP! Thanks in advance!
If Statements
Awright guys
right i amm trying to acumplish the same effect that can be found @ http://www.egomedia.com(NEW), The way the windows r minamized and maximized. I have it working fine but i have run into a small snag. When the windows r minimized they overlap each other when @ the same _x and _y but i have code setup to chack wether x_ is true or false, Wether or not it is available. have a look @ the code below
Code:
onClipEvent (enterFrame) {
if (_root.win1mx == "1") {// Checks to see if the min button has been pressed
_x += (_root.x1-_x)/_root.speed;//move
_y += (30-_y)/_root.speed;
_root.x1mx;// Makes x1 true(unavailable)
}
if (_root.x1mx) {// If not available goto x2
_x += (_root.x2-_x)/_root.speed;//
_y += (30-_y)/_root.speed;
_root.x2mx;// Makes x2 true(unavailable)
}
if (_root.x2mx) {// If not available goto x3
_x += (_root.x3-_x)/_root.speed;
_y += (30-_y)/_root.speed;
_root.x3mx;// Makes x3 true(unavailable)
}
}
x1=10 x2=110 x3= 220, are vairables postions along _x.
x1mx, x2mx, x3mx, are vairables to check and see if x1, x2, x3 are taken
I have this code on 3 clips
I hope someone can help me with this.
Cheers guys
If Else Statements
I would really appriciate any help with a math tutorial I am building. basically I have three input fields. All input fields need to be correct to move to the next answer.
here is what I have. What is wrong?
on (release) {
if (fac1 = 40)
if (fac2 = 3)
if (fac3 = 7) {
var GB = "Congratulations, click the Next button";
} else {
var GB = "try again";
}
}
If And Else Statements
I'm a bit stuck on what should be a simple problem:
Basically i'm trying to access the score to perform varying progressions in a movieclip. At the moment I'm using the trace command to make sure the right messages are being sent.
I'm using this code in an actions clip placed off stage:
onClipEvent (enterFrame) {
if (_root.score>4) {
trace ("level3");
}
if (_root.score>2) {
trace ("level2");
}
if (_root.score<2) {
trace ("level1");
}
}
If/else Statements
Okay, I'm back for some help.
I'm new to if/else statements and need a point in the right direction.
Here's what I need to do.
Let's say I have an 'about' button that onPress loads 'about.swf' into a target area (another mc). How do I tell the button that 'if' the swf is loaded, that go and stop at a label on its timeline (my buttons are MCs).
Also, do you need to have an 'else'?
Cheers. YP
If / Else If Statements
Could someone please tell me what I am doing wrong here? I have tried everyway that I could think of to get the statement to recognize the text being inputted into the text box, but nothing works.
Here is the script;
on (release, keyPress "<Enter>") {
if (passEnter.text eq "merlin"){
_level0:OtherSign.text = "Kerry LeBlanc";
}
else if (passEnter.text = "paws"){
_level0:OtherSign.text = "Jackie Sayer";
}}
The text box instance is named passEnter, I have tried using the variable name which is pw, I have tried substituting "=" for eq. None of it works, please help me to see what stupid little thing I am missing.
TIA
Kerry
Using If Statements...
Hello,
I have a button inside of a movie clip that I have made, and I was wondering if there was some kind of if statement or command so if my button was clicked on a certain frame of the movie, it would then go to a certain frame inside of my movie clip. I don't know if this is possible or not, but I'd thought I'd ask anyways. Thanks
How Do You Use 'with' Statements
Can someone give me quick instructions on how to use 'with' statements? I'm trying not to use 'telltarget' but when i use 'with' i get 'Target: trailing garbage found' what's up with that?
Thanks in advance for any help.
If Statements
Hi,
I am programming some MC buttons and got a line of code to get my MC (home) to play backwards when mouse leaves button.
on (rollout) {
home.rewind = false
}
all i want to do is add an if statement so
on (rollout) {
if home.(frame number is less than or equal to 10?) then
home.rewind = false
Just don't know any of the action script terminology.
cheers,
will
If Statements
i've done coldfusion about a year ago, so I know concept of the in then statements, wondering if my idea will work though.
thinking of how to do a back button that affects a single movieclip. Basically, it'll say, if this MC's current frame is x, or x-x(a range), then go here on PRESS/RELEASE. wondering along the lines how to do this, trying it out without success, saw this action from menu.
ifFrameLoaded () {
}
wondering if i can put it under a on (Press) , ifFRameLoaded(14) then do a gotoandPlay(7) type thing. if you got tips on better how to do it, thanks, till then, i'm havin fun with errors =-)
oh, and main thing is, that i want to do it, so that there are multiple if's, basically 10-12 if's with half that many actions. in CF it was cfif's and cfelseif's.
thanks
OR Statements
Why doesn't my code work??
// Checks to see what day it is and do the according
if (_level0.themday == "Monday" || "Tuesday" || "Wednesday" || "Thursday" || "Friday") {
gotoAndPlay(3);
} else if (_level0.themday == "Saturday" || "Sunday") {
_level0.melboff = "CLOSED";
gotoAndPlay(1);
}
If Else Statements..
Hi, i need help in my Flash MX actionscript. I would like to create a command that helps to counter check if the input type is the correct or the expected username.. Such that when its not correct it will therefore not go&play the next frame. Requesting the user to re-enter the correct username.. Thanks.
If, Else Statements.
This has now become something i need to learn.
-part 1-
how can I use if, else statements to check for variable values (i.e. if X equals 1502, goto frame 1; if X equals 9876 goto frame 2; else do nothing)
If needed, I will post the file so far
-part 2-
how can I use if, else statements to limit the area in which an object can travel (see 'one dimentional mouse trails').
*sigh* when will I be able to answer questions rather than ask them.
-Z
If Statements
Hey, i was just wondering how to create an if statement that checks to see if a movie has been loaded into a level then takes one of two actions if it true - if you know what i mean?? lol
any help will be awesome
cheers
If Statements
hey there, got a little proble with this if statement - what i'm trying to do here is create a button that checks to see if a external swf has been loaded into a level if it has already been loaded but the user has already clicked to "close" it which actually set visible to false when they go to click on the same button to "reopen" it the button just sets the visible=true to that level and if the movie hasnt been loaded at all then it will just load the movie into a level - if you know what i mean - anyways this is the script i got so far it's not workin at the mo hopefully one of you guys can help out
---------------------------------------------------
on (press) {
if (level6){
level6._visible=true;
} else {
loadMovieNum("links.swf", 6);
}
}
If Statements
I have 5 different sections of my scene and each section has a different menu that slides in. When you click on a button to go to another section of the scene, I want it to play that menu sliding down, then the next sections menu sliding up.
I guess you would use an If statement that says if A is true then go play Adown then go to the next section. I tried getting it to work but had no success. I tried telling it when each condition was true then did an if statement but i guess I did it wrong.
So first it has to determine which menu is up at that moment, tell that menu to go to its corresponding menudown, and then go to the section in the gotoplay statement.
Could somebody help me please!
If Else Statements
Hello,
I was wondering if anyone could help me out with the scripting of an If Then Else statement. What I have going on is this, I have a button that loads an external .swf into a target movieclip using:
loadMovie("c.swf",_root.target4);
but I don't want the swf to reload if the button is pressed again, I know i need to script something like:
button.onRelease = function(){
If movie is loaded
do nothing
else
loadMovie("c.swf",_root.target4);
}
Its been a while since I've done any actionscripting so if any one could help me out with the correct syntax, I would greatly appreciate it.
thanks
Using If Statements...
hi guys, im having a problem. when I run this with the vars coming from a text file, i get all the values including undefined, where it should just over look them and give me ones with the value bigger or equal to 1. I think i might be writing it incorrectly. any help would be appreciated
for (i=1; i<= menutotal; i++) {
if (_global.menu["subText"+i] >= 1 ) {
trace(_global.menu["subText"+i]);
}
}
thanks,
-Nick
If Else & Statements
Hello,
I'm looking to create a movie where the user will type a word into a box. If the word is correct the movie will jump to another scene and play, if it is incorrect, a reply will pop up. I have coding that tells me how to do this with numbers... can someone please help me figure out how to adjust this to text? The part in bold is where I think I am having problems. Should it be "text" instead of number? Thanks!
Quote:
_global.age = function() {
a = Number(input);
if (a = Jump) {
gotoAndPlay("scene=1", "1");
*help (if Statements) *help
hello, i'm a long time lurker first time poster, and i love this flashkit board.
i'm trying to update my stupid old site and have upgraded from flash mx to mx 2004...
this code worked in mx as far as i remember...
on (release) {
if (3dmovie_mc._currentframe > 1) {
3dmovie_mc.gotoAndPlay(13);
}
}
of course now it doesn't. i can't really figure out why...
this is what the debugger tells me...
**Error** Scene=Scene 1, layer=buttons, frame=22:Line 2: ')' expected
if (3dmovie_mc._currentframe > 1) {
**Error** Scene=Scene 1, layer=buttons, frame=22:Line 3: Syntax error.
3dmovie_mc.gotoAndPlay(13);
all i want is for my button to check if the movie clip is past the first frame and if it is tell it to go to the 13th frame. i'm sure it's something simple i just haven't learned yet or am forgetting.
any help would be greatly appreciated, thanks.
-jeremy
If Statements Help
on(rollOver) {
homerollover.gotoAndPlay(2);
}
on(rollOut) {
homerollover.gotoAndPlay(12);
}
on(release) {
homerollover.gotoAndPlay(22);
gotoAndPlay(2);
if (biorollover._currentframe = 28) {
biorollover.gotoAndPlay(29);
}
}
now when you click on say Home, then it tells the movie clip home rollover to play animation starting on frame 22 and stopping on frame 28
so I have it show what page your on
now when you click on a different button I want whatever button you previously clicked to play the animation starting on frame 29 and ending on frame 35 (which basically is the reverse of the animation starting on frame 22)
so above I tried to say that if the Bio button had previously been clicked and thus ended up on frame 28 (showing your on the bio page) then when you click Home it will play the animation on the Home button but will play the reverse animation for Bio
But that script isnt working, if you click it when Bio isnt at frame 28 then it plays the animation on frame 29 anyway, and when Bio is on frame 28 then when you click Home it doesnt do anything to Bio
'with' Statements
I am trying to find out if there's any way to list targets to apply a with statement's properties to.
I've tried the following: though only ever the last target in the chain is recognised and have the properties associated with it:
code: with (vert1,vert2,vert3,vert4) {
_y = 12
_height = 360
}
and
with ((vert1) && (vert2) && (vert3) && (vert4)) {
_y = 12
_height = 360
}
and
with ((vert1) || (vert2) || (vert3) || (vert4)) {
_y = 12
_height = 360
}
in cases 1 and 2, 'vert4' gains the y and height properties, whereas in the last instance, vert1 gets them.
i Need ALL of them! :P
Please Help
If Else Statements
I'm making a turn based fighting game, and in this part of the programming, I'm trying to take what ever attack the user selected (attack,defend), and make it affect how much HP is taken away when attacked by the enemy. Here is the code I have, and for some reason, it just dosn't work? -
code:
stop();
hitchance = random(3);
this.enemymc.gotoAndPlay(2);
if (hitchance == 2){
if(defense == 5){
playerhealth = playerhealth - 5;
this.p1bars.healthbar._xscale = playerhealth;
}
else if(defense == 0){
playerhealth = playerhealth - 10;
this.p1bars.healthbar._xscale = playerhealth;
}
}
Now, in the if statements, the defense var. was defined by the user clicking a button and selecting to attack or defend. Here is that code-
code:
on(release){
defense = 0;
this._parent.player.gotoAndPlay(2);
gotoAndStop(7);
hitchance = random(3);
if (hitchance == 1) {
this._parent.enemyhealth = this._parent.enemyhealth - 5;
}
}
Now the defense button-
code:
on(release){
defense = 5;
gotoAndStop(7);
this._parent.player.gotoAndPlay(74);
}
Can someone PLEASE explain why this isn't working, I'm guessing I just don't know how else if statements work... lol...
Thanks in advanced
EDIT: Changed your [ color ] tags to [ as ] tags. - jbum
Can You Have Too Many If/else Statements?
Is it possible, or more importantly UNWISE, to have too many if/else statements?
I am working on a site that is heavily animated and I needed to have a several checks to see if mc_a, mc_b . .. . mc_z. are at certain points on their resepective timelines.
Is there limits to these types of statemetns? Are they CPU hogs?
Thanks for you anyone's 2 cents.
If Statements...
X is set to 1, but this is not working. Why not?
if (x=1) {
_root.MC1.gotoAndPlay("go");
}
Thanks!
Help With If Statements
I have some text fields where the user must fill in their height and weight. Depending on the result i have told flash to play various parts of the movie using if statements.
However i'd like flash to play an 'error checking' section of the movie if any of the text fields have not been filled in by the user.
As im fairly new to actionscripting, how do i tell flash to do this?
Any help much appreciated
If Statements
I'm having trying to get some if statements to work. How do I set it up where I have an if statement, and if that is met, then I have another if/else, but if the first if statement isn't met, I want the mc to go to a specific spot.
I'm working on this mc that follows the mouse (x direction only). If the mouse is between 50 and 706, the other if/else statement needs to run. If the mouse is less than 50, I need the mc to be in one position, and if the mouse is greater than 706, the mc needs to go to a different position.
Any ideas?
p.s. Here's the code that I already have for the mc to follow the mouse. The mc is 100 wide so the -50 is to track to the center of the MC.
onClipEvent (enterFrame) {
mx=_root._xmouse-50;
if (mx<_x) {
dx=_x-mx;
}
else {
dx=mx-_x;
}
moveSpeedx=dx/2;
if (mx<_x) {
_x=_x-moveSpeedx;
}
else {
_x=_x+moveSpeedx;
}
}
Help With If Statements
Im trying to load variables with a true or false value from a text file. If the value is true, I want it to set the alpha properties of certain buttons to 100%. I don't think im coding my if statements properly as regardless of the variable value, it sets them to 100%.
Anyone know a good tutorial that might cover this? Or could show me what the code should look like?
|