Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

Coding Forum


You are currently viewing our Coding Forum as a guest. Please register to participate.
Login



Reply
Actionscript - What have I done wrong?
Old 11-08-2008, 06:39 AM Actionscript - What have I done wrong?
magicvw's Avatar
Extreme Talker

Posts: 233
Name: Vicky
Location: Brit in Bulgaria
Trades: 1
I'm still learning the basics, so please excuse the simple question!

I have this actionscript up in a Flash 8 frame:

stop();
var percent=(points/90)*100;
var greeting1 = "";
var greeting2 = "";

if (percent<66) {
greeting1 ="Bad Luck.";
greeting2 ="You failed. You need 66% to pass.";
}
if ((percent>=66) or (percent<=80)){
greeting1 = "Good Try!";
greeting2 = "You passed!";
}

if ((percent>=80) or (percent<=90)){
greeting1 = "Very Good Work!";
greeting2 = "You passed with Merit!";
}

if (percent>=90){
greeting1 = "Excellent Job!";
greeting2 = "You passed with Distinction!";
}

trace (percent);


When I test it out, a percent of 0% returns the greetings "very good work" and "you passed with merit". Please tell me why! This is doing my head in! Am I doing this completely wrong? Tx!
__________________

Please login or register to view this content. Registration is FREE



Please login or register to view this content. Registration is FREE
magicvw is offline
Reply With Quote
View Public Profile Visit magicvw's homepage!
 
 
Register now for full access!
Old 11-08-2008, 07:42 AM Re: Actionscript - What have I done wrong?
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,519
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
The logical OR operator in actionscript is "||" (OR was deprecated the last time I programmed in AS)
and your logic was a little wonky it needs to be a logical AND

so the logic would read "if (greater than OR equal to 66) AND (less than 80) then" otherwise everything more than 66 would match the "greater than 66" comparison.

reworked and tidied code.
Code:
if (percent<66) {
greeting1 ="Bad Luck.";
greeting2 ="You failed. You need 66% to pass.";
} else if ((percent>=66) && (percent<80)){
greeting1 = "Good Try!";
greeting2 = "You passed!";
} else if ((percent>=80) && (percent<90)){
greeting1 = "Very Good Work!";
greeting2 = "You passed with Merit!";
} else if (percent>90){
greeting1 = "Excellent Job!";
greeting2 = "You passed with Distinction!";
}
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 11-08-2008, 09:21 AM Re: Actionscript - What have I done wrong?
magicvw's Avatar
Extreme Talker

Posts: 233
Name: Vicky
Location: Brit in Bulgaria
Trades: 1
Thanks so much chrishirst! It works now
__________________

Please login or register to view this content. Registration is FREE



Please login or register to view this content. Registration is FREE
magicvw is offline
Reply With Quote
View Public Profile Visit magicvw's homepage!
 
Old 11-10-2008, 05:25 PM Re: Actionscript - What have I done wrong?
magicvw's Avatar
Extreme Talker

Posts: 233
Name: Vicky
Location: Brit in Bulgaria
Trades: 1
Here is the finished article - just in case you were interested!

http://www.mymusictheory.com/grade1/...grade-one.html

It's only the second bit of Flash I've attempted so it's very very clunky - I hope it works properly!
__________________

Please login or register to view this content. Registration is FREE



Please login or register to view this content. Registration is FREE
magicvw is offline
Reply With Quote
View Public Profile Visit magicvw's homepage!
 
Reply     « Reply to Actionscript - What have I done wrong?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.19510 seconds with 12 queries