joannah00
asked on
How do I control the x,y range using a symbol?
I have two buttons. The "Right" button each time it is clicked moves a tiny symbol (tinysquare2) to the right 5 pixels; the Left" button moves the symbol to the left 5 pixels. I have been able to restrain it between two points (x axis: 252 and 347) but it jumps to the middle position once it reaches the furthest point instead of moving from that current position in the far right or far left. How to get it to move left from the furthest right position instead of it jumping to the middle then moving to the left?
Right Button:
on (press) {
if (VOL.text=="VOL"){
turn2._alpha = 100;
Turnknob2.text = "Right >";
tinysquare2._x += 5;
};
if (tinysquare2._x >= 347.1) {
tinysquare2._x = 347.1;
};
if (tinysquare2._x <= 252.2) {
tinysquare2._x = 252.2;
};
}
Left Button:
on (press) {
if (VOL.text=="VOL"){
turn2._alpha = 100;
Turnknob2.text = "< Left";
tinysquare2._x -= 5;
};
if (tinysquare2._x >= 347.1) {
tinysquare2._x = 347.1;
};
if (tinysquare2._x <= 252.2) {
tinysquare2._x = 252.2;
};
}
Right Button:
on (press) {
if (VOL.text=="VOL"){
turn2._alpha = 100;
Turnknob2.text = "Right >";
tinysquare2._x += 5;
};
if (tinysquare2._x >= 347.1) {
tinysquare2._x = 347.1;
};
if (tinysquare2._x <= 252.2) {
tinysquare2._x = 252.2;
};
}
Left Button:
on (press) {
if (VOL.text=="VOL"){
turn2._alpha = 100;
Turnknob2.text = "< Left";
tinysquare2._x -= 5;
};
if (tinysquare2._x >= 347.1) {
tinysquare2._x = 347.1;
};
if (tinysquare2._x <= 252.2) {
tinysquare2._x = 252.2;
};
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
This suggests that the clip is also controlled from somewhere esle. Kindly share your fla.
Warm Regards
Deepanjan Das
http://deepanjandas.wordpress.com
Warm Regards
Deepanjan Das
http://deepanjandas.wordpress.com
Post your fla so that we can take a look into it
ASKER
Thank you for your help. Unfortunately I cannot post the project since it contains sensitive material but I do think deepanjandas has a good point. There are three conditions for the same button symbol. When the symbol is pressed three things could happen depending on what the text inside the VOL.text dynamic field displays. The following is placed in the ActionScript for the button symbol.
//If the text displays Brightness "BRT" this happens:
on (press) {
if (VOL.text=="BRT"){
turn._alpha = 100;
Turnknob1.text = "Right >";
black_screen._alpha -= 5;
};
if (black_screen._alpha <= 45){
black_screen._alpha == 45;
black_screen._alpha += 5;
}
if (black_screen._alpha >= 100){
black_screen._alpha == 100;
black_screen._alpha -= 5;
}
}
//If the text displays balance "BAL" this happens:
on (press) {
if (VOL.text=="BAL"){
turn._alpha = 100;
Turnknob1.text = "Right >";
tinysquare1._x += 50;
};
if (tinysquare1._x >= 228) {
tinysquare1._x = 228;
};
if (tinysquare1._x == 129.5) {
tinysquare1._x += 50;
};
}
//If the text displays volume"VOL" this happens:
on (press) {
if (VOL.text=="VOL"){
turn._alpha = 100;
Turnknob1.text = "Right >";
tinysquare1._x += 5;
};
if (tinysquare1._x >= 228) {
tinysquare1._x = 228;
};
if (tinysquare1._x <= 129.5) {
tinysquare1._x = 129.5;
tinysquare1._x += 5;
};
}
After reading deepanjandas' post I think there are conflicting actions going on with my code. Maybe the semicolons are misplaced so that the three conditions are not separating? The BAL and BRT work very well. It's the VOL that keeps jumping to the middle position.
//If the text displays Brightness "BRT" this happens:
on (press) {
if (VOL.text=="BRT"){
turn._alpha = 100;
Turnknob1.text = "Right >";
black_screen._alpha -= 5;
};
if (black_screen._alpha <= 45){
black_screen._alpha == 45;
black_screen._alpha += 5;
}
if (black_screen._alpha >= 100){
black_screen._alpha == 100;
black_screen._alpha -= 5;
}
}
//If the text displays balance "BAL" this happens:
on (press) {
if (VOL.text=="BAL"){
turn._alpha = 100;
Turnknob1.text = "Right >";
tinysquare1._x += 50;
};
if (tinysquare1._x >= 228) {
tinysquare1._x = 228;
};
if (tinysquare1._x == 129.5) {
tinysquare1._x += 50;
};
}
//If the text displays volume"VOL" this happens:
on (press) {
if (VOL.text=="VOL"){
turn._alpha = 100;
Turnknob1.text = "Right >";
tinysquare1._x += 5;
};
if (tinysquare1._x >= 228) {
tinysquare1._x = 228;
};
if (tinysquare1._x <= 129.5) {
tinysquare1._x = 129.5;
tinysquare1._x += 5;
};
}
After reading deepanjandas' post I think there are conflicting actions going on with my code. Maybe the semicolons are misplaced so that the three conditions are not separating? The BAL and BRT work very well. It's the VOL that keeps jumping to the middle position.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for the help. I had to fix a few compilation code errors that Flash gave me with the code above but the symbol is still jumping to the middle and now the brightness lightens a few shades even if the VOL.text is not set to "BRT". I think the answer is here but I need to clean up the code better with the proper use of semicolons and else if statements.
There can be errors as just copied your code and pasted it to show you the format for the conditions you should use.
I assume that you are setting the conditions as mentioned. As still it is jumping, you need to share the code for me to suggest further.
Warm Regards
Deepanjan Das
http://deepanjandas.wordpress.com
I assume that you are setting the conditions as mentioned. As still it is jumping, you need to share the code for me to suggest further.
Warm Regards
Deepanjan Das
http://deepanjandas.wordpress.com
ASKER
It stopped jumping once I cleaned up the code by eliminating the extra lines that didn't correspond to the direction the button was supposed to move the symbol. I had to separate the three conditions, though. But the brightness still lightens one alpha shade when VOL.text=="BAL" and "VOL". Should I end each on(press) section with the semi colon? What does the semi colon do exactly? It seems to not make a difference. So this being the right button the code goes like this:
on (press) {
if (VOL.text=="BRT"){
turn._alpha = 100;
Turnknob1.text = "Right >";
black_screen._alpha -= 5;
}
if (black_screen._alpha <= 45){
black_screen._alpha == 45;
black_screen._alpha += 5;
}
}
on (press) {
if (VOL.text=="BAL"){
turn._alpha = 100;
Turnknob1.text = "Right >";
tinysquare1._x += 50;
}
if (tinysquare1._x >= 232.6) {
tinysquare1._x = 232.6;
}
}
on (press) {
if (VOL.text=="VOL"){
turn._alpha = 100;
Turnknob1.text = "Right >";
tinysquare1._x += 5;
}
if (tinysquare1._x >= 232.6) {
tinysquare1._x = 232.6;
}
}
on (press) {
if (VOL.text=="BRT"){
turn._alpha = 100;
Turnknob1.text = "Right >";
black_screen._alpha -= 5;
}
if (black_screen._alpha <= 45){
black_screen._alpha == 45;
black_screen._alpha += 5;
}
}
on (press) {
if (VOL.text=="BAL"){
turn._alpha = 100;
Turnknob1.text = "Right >";
tinysquare1._x += 50;
}
if (tinysquare1._x >= 232.6) {
tinysquare1._x = 232.6;
}
}
on (press) {
if (VOL.text=="VOL"){
turn._alpha = 100;
Turnknob1.text = "Right >";
tinysquare1._x += 5;
}
if (tinysquare1._x >= 232.6) {
tinysquare1._x = 232.6;
}
}
ASKER