View Full Version : Another Problem
c00lryguy
12-01-2004, 02:56 PM
ok i have a dynamic textbox with the instance name "qual" and the text says "High" and two buttons,up and down
i want it so when you press up the quality goes up and qual says the next quality
but when i press up it just goes best but when i go down it goes to medium and no further
in up i have:
on (release) {
if(_root.qual.text = "Low") {
_root.qual.text = "Medium";
_root._quality = "MEDIUM";
}
if(_root.qual.text = "Medium") {
_root.qual.text = "High";
_root._quality = "HIGH";
}
if(_root.qual.text = "High") {
_root.qual.text = "Best";
_root._quality = "BEST";
}
}
and in down i have
on (release) {
if(_root.qual.text = "Best") {
_root.qual.text = "High";
_root._quality = "HIGH";
}
if(_root.qual.text = "High") {
_root.qual.text = "Medium";
_root._quality = "MEDIUM";
}
if(_root.qual.text = "Medium") {
_root.qual.text = "Low";
_root._quality = "LOW";
}
}
what am i doing wrong?
The Brown Cow
12-01-2004, 03:00 PM
I used to make this mistake all the time... it's really confusing...
You're setting the quality to LOW, and then immediately checking to see if the quality is LOW, and setting it to MEDIUM. Then you check if the quality is MEDIUM, and set it to HIGH. Then you check if the quality is HIGH, and set it to BEST.
You need to use else if...
on (release) {
Â# Â#if (_root.qual.text = "Low") {
Â# Â#Â# Â#_root.qual.text = "Medium";
Â# Â#Â# Â#_root._quality = "MEDIUM";
Â# Â#} else if (_root.qual.text = "Medium") {
Â# Â#Â# Â#_root.qual.text = "High";
Â# Â#Â# Â#_root._quality = "HIGH";
Â# Â#} else if (_root.qual.text = "High") {
Â# Â#Â# Â#_root.qual.text = "Best";
Â# Â#Â# Â#_root._quality = "BEST";
Â# Â#}
}
That way, only one code block can run each time the button is clicked.
c00lryguy
12-01-2004, 03:02 PM
oh, i didnt know ther was else if in flash
thank you
edit:
hmm it doesnt work, now it doesnt even change to Best
c00lryguy
12-01-2004, 03:16 PM
http://c00lryguy.250x.com/car4.swf
look at the quality box on the left,its really weird
EDIT: sorry for double posting, i thought i was editing :X
crusty
12-01-2004, 03:20 PM
Yeah...
First of all, it looks really sloppy, and second, it doesn't work.
:?
c00lryguy
12-01-2004, 03:20 PM
erm, its a work in progress
eatmorchikin6464
12-01-2004, 03:27 PM
Just so you know, the BG moves the wrong way.
The Brown Cow
12-01-2004, 03:28 PM
Ah, it's the classic = instead of ==.
on (release) {
Â# Â#if (_root.qual.text == "Low") {
Â# Â#Â# Â#_root.qual.text = "Medium";
Â# Â#Â# Â#_root._quality = "MEDIUM";
Â# Â#} else if (_root.qual.text == "Medium") {
Â# Â#Â# Â#_root.qual.text = "High";
Â# Â#Â# Â#_root._quality = "HIGH";
Â# Â#} else if (_root.qual.text == "High") {
Â# Â#Â# Â#_root.qual.text = "Best";
Â# Â#Â# Â#_root._quality = "BEST";
Â# Â#}
}
c00lryguy
12-01-2004, 03:37 PM
Just so you know, the BG moves the wrong way.
I knew it looked weird, thanks
thanks, brown cow
EDIT: grr, EVIL, FLASH IS EVIL!
here's the fla: http://c00lryguy.250x.com/car2.fla
I see no reason it wouldnt work
Nexus
12-01-2004, 03:46 PM
There is another way you can go about doing this.
When you are checking to see if the same value is equal to a certain value, you can use a switch statement to make it easier to read.
on(release){
switch( _root._quality){
case "LOW":
_root.qual.text = "Medium"
_root._quality = "MEDIUM"
break;
case "MEDIUM":
_root.qual.text = "High"
_root._quality = "HIGH"
break;
case "HIGH":
_root.qual.text = "Best"
_root._quality = "BEST"
break;
case "BEST":
_root.qual.text = "Low"
_root._quality = "LOW"
break;
}
}
That does the same thing as the shorter if statement version, but I personally in this case find it easier to read.
c00lryguy
12-01-2004, 03:55 PM
w00t! thank you! it finally works ^.^
c00lryguy
12-01-2004, 04:15 PM
god im so bad a this >.> <.<
another problem
i want to make a continous background when i move but i cant seem to get it right
on the ground movieclip, second layer i have
onClipEvent (enterFrame) {
_root.ground.duplicateMovieClip(ground,ground2,0);
ground2._x = ground._x + ground.width;
_root.ground.duplicateMovieClip(ground,ground3,0);
ground3._x = ground._x - ground.width;
}
the bg just goes over over everything else like is on the first layer, and it doesnt follow the next
MercuryLime
12-01-2004, 05:43 PM
Have all your roots? Maybe _root.ground2._x etc?
The Brown Cow
12-01-2004, 05:51 PM
The layers issue is because movie clips attached through actionscript are placed at a higher depth than those created manually.
You can swapDepths() up the other clips, or you may be able to attach the background to a sufficiently low (negative) depth to put it behind the cars and stuff.
arkhan
12-01-2004, 05:51 PM
add the lines at start
ground = _root.ground
ground2 = _root.ground2
ground3 = _root.ground3
you can use this so you dont have to type everything everytime..
vBulletin® v3.7.3, Copyright ©2000-2009, Jelsoft Enterprises Ltd.