PDA

View Full Version : loadmovie command not working in if statement


cocoonfx
12-07-2007, 08:57 PM
Hello Chaps


I have been building a little flash widget for a site, i can get the form part to work correctly no problems, but i want to have a small little .swf to play within the widget if a condition is meant. I.e if i enter the details in the form it does a calculation say = 28. Some text appears and then i want the swf to appear related to this condition. However when i type a number into one of the form fields the swf starts to play and when the form actually equals 28 the .swf disappears.

My code is as follows:

kgs = 0;
cm = 0;
_root.onEnterFrame = function() {
var cal:Number = Number(cm*cm);
var b:Number = Number(kgs/cal*10000);
bmi = Math.floor(b);

if (bmi>=5 && bmi<20.00) {
txt = "Status: Underweight You should not lose any further weight and should consider increasing your consumption of a healthy diet to increase your BMI reading.";
}
if (bmi>=21 && bmi<=25.00) {
txt = "Status: Congratulations your BMI result is showing you within the healthy range.You should maintain your weight, take regular exercise and seek a consultation on a healthy weight maintenance program.";
}
if (bmi>=26 && bmi<=30.00) {
txt = "Status: Overweight -- You are a little over the recommended weight for your height. If the weight has been creeping on slowly then now is a good time to have a serious re-think before it becomes a problem. Seek a consultation.";
loadMovie("mt.swf",this.target);

}
if (bmi>=31.00 && bmi<=40.00) {
txt = "Status: Clinically obese 1 You need to take a serious look at your lifestyle. Determine your waist circumference by placing a measuring tape snugly around your waist. Risk factors for heart disease and other diseases increase with a waist measurement of over 40 inches in men and over 35 inches in women.";
}
if (bmi>=40.00 && bmi<=100.00) {
txt = "Status: Extreme Obesity Advise urgent check up with doctor and then under doctor advice commence an immediate health program to reduce weight and improve overall fitness. Seek an immediate consultation.";
}
if (bmi>=100.00) {
txt = "Please enter your height in centimeters and your weight in KGs i.e Height = 181 and Weight = 92.3";
}
};
stop();

Any ideas on how to make this work?

davidj
12-07-2007, 09:22 PM
would it not be better to send the play head to another frame and load the movie on that frame


if (bmi>=26 && bmi<=30.00) {
txt = "Status: Overweight -- You are a little over the recommended weight for your height. If the weight has been creeping on slowly then now is a good time to have a serious re-think before it becomes a problem. Seek a consultation.";

goto_and_stop(2)

}


then in frame2 load your movie

cocoonfx
12-07-2007, 11:23 PM
Yes that would work....

I will do that but there must also be away to get the if statement to work.... :grin:

Thanks DJ

davidj
12-08-2007, 08:21 AM
im not sure but i would do it my way