hey everybody,
I’m having a bit of trouble with my code, but I can’t spot what the problem is. Basically, I’ve got a load of buttons, and, when they press a button, I want the current content to fade out and move out the way afterwards, and new content to move into place and then fade in. But, it won’t work. :puzzle:
here it all is, sorry if it’s not as clean as it should be, but I’m new to all this coding stuff:
import mx.transitions.Tween;
import mx.transitions.easing.*;
stop();
var currentPage:String = "About Us";
var changePage:String = "About Us";
btn_AboutUs.onRelease = function () {changePage = "About Us";};
btn_TheTeam.onRelease = function () {changePage = "The Team";};
btn_Sales.onRelease = function () {changePage = "Sales";};
btn_Lettings.onRelease = function () {changePage = "Lettings";};
btn_PropertySearch.onRelease = function () {changePage = "Property Search";};
btn_VirtualTours.onRelease = function () {changePage = "Virtual Tours";};
btn_OnlineRegistration.onRelease = function () {changePage = "Online Registration";};
btn_RequestValuation.onRelease = function () {changePage = "Request Valuation";};
btn_Links.onRelease = function () {changePage = "Links";};
btn_ContactUs.onRelease = function () {changePage = "Contact Us";};
if (currentPage != changePage) {
switch (currentPage) {
case "About Us":
alphaTween = new Tween(content_aboutus, "_alpha", Regular, 100, 0, 1, true);
content_aboutus._x = -1000;
break;
case "The Team":
alphaTween = new Tween (content_theteam,"_alpha",Regular,100,0,1,true);
content_theteam._x = -1000;
break;
case "Sales":
alphaTween = new Tween (content_sales,"_alpha",Regular,100,0,1,true);
content_sales._x = -1000;
break;
case "Lettings":
alphaTween = new Tween (content_lettings,"_alpha",Regular,100,0,1,true);
content_lettings._x = -1000;
break;
case "Property Search":
alphaTween = new Tween (content_propertysearch,"_alpha",Regular,100,0,1,true);
content_propertysearch._x = -1000;
break;
case "Virtual Tours":
alphaTween = new Tween (content_virtualtours,"_alpha",Regular,100,0,1,true);
content_virtualtours._x = -1000;
break;
case "Online Registration":
alphaTween = new Tween (content_onlineregistration,"_alpha",Regular,100,0,1,true);
content_onlineregistration._x = -1000;
break;
case "Request Valuation":
alphaTween = new Tween (content_requestvaluation,"_alpha",Regular,100,0,1,true);
content_requestvaluation._x = -1000;
break;
case "Links":
alphaTweenOut = new Tween (content_links,"_alpha",Regular,100,0,1,true);
content_links._x = -1000;
break;
case "Contact Us":
alphaTweenOut = new Tween (content_contactus,"_alpha",Regular,100,0,1,true);
content_contactus._x = -1000;
break;
default:
break;
};
alphaTweenOut.onMotionFinished = function () {
switch (changePage) {
case "About Us":
content_aboutus._alpha = 0;
content_aboutus._x = 70;
alphaTweenIn = new Tween (content_aboutus,"_alpha",Regular,0,100,1,true);
break;
case "The Team":
content_theteam._alpha = 0;
content_theteam._x = 70;
alphaTweenIn = new Tween (content_theteam,"_alpha",Regular,0,100,1,true);
break;
case "Sales":
content_sales._alpha = 0;
content_sales._x = 70;
alphaTweenIn = new Tween (content_sales,"_alpha",Regular,0,100,1,true);
break;
case "Lettings":
content_lettings._alpha = 0;
content_lettings._x = 70;
alphaTweenIn = new Tween (content_lettings,"_alpha",Regular,0,100,1,true);
break;
case "Property Search":
content_propertysearch._alpha = 0;
content_propertysearch._x = 70;
alphaTweenIn = new Tween (content_propertysearch,"_alpha",Regular,0,100,1,true);
break;
case "Virtual Tours":
content_virtualtours._alpha = 0;
content_virtualtours._x = 70;
alphaTweenIn = new Tween (content_virtualtours,"_alpha",Regular,0,100,1,true);
break;
case "Online Registration":
content_onlineregistration._alpha = 0;
content_onlineregistration._x = 70;
alphaTweenIn = new Tween (content_onlineregistration,"_alpha",Regular,0,100,1,true);
break;
case "Request Valuation":
content_requestvaluation._alpha = 0;
content_requestvaluation._x = 70;
alphaTweenIn = new Tween (content_requestvaluation,"_alpha",Regular,0,100,1,true);
break;
case "Links":
content_links._alpha = 0;
content_links._x = 70;
alphaTweenIn = new Tween (content_links,"_alpha",Regular,0,100,1,true);
break;
case "Contact Us":
content_contactus._alpha = 0;
content_contactus._x = 70;
alphaTweenIn = new Tween (content_contactus,"_alpha",Regular,0,100,1,true);
break;
default:
break;
};
alphaTweenIn.onMotionFinished = function() {
changePage = currentPage;
};
};
};
can anyone spot anything wrong with it? All the cases in the switch statements are the same, except for the instance name, as each refers to different pieces of content…