SwishTalk.com
 

Go Back   SwishTalk.com > .:: THE HELP DESK ::. > » SWiSH Max4 General Help

Reply
 
Thread Tools Display Modes
#1   check pressed button (including xml file?)  

Name: 
petruccios
Status: Offline
Rank: SWiSHer
Posts: 6
Old 02-27-2012, 07:26 PM Reply With Quote


Hey everyone, I've been looking all over the forum but I can't find anything to help me understand what is happening with my file!!
I'm trying to create a simple quiz game,however the questions should be loaded from an external xml file. The thing is, while each question and each answer is correctly loaded the "if" condition doesn't seem to work!!

Let me explain a while..

Code:
 catalogue.onLoad = function(success) {
        if (success) {
             
             // Load label/answer on button 1
             b1.lb1 = this.firstChild.childNodes[_root.record].attributes.ans1;

             // Load label/answer on button 2
             b2.lb2 = this.firstChild.childNodes[_root.record].attributes.ans2;

             // Load variable of correct answer to check
             check1 = this.firstChild.childNodes[_root.record].attributes.var1;

             // Load variable of wrong answer to check
             check2 = this.firstChild.childNodes[_root.record].attributes.var2;

            record++
        }
    }
So far all good, my program loads the variables correctly. However I'm trying to find a way to see which of these buttons was pressed (and I can't find any way to do it.. )

So since i'm guessing that value "check1" is associated with button1,I'm trying to use an "if" statement to test the value of this variable. However, my if statement doesn't go beyond checking value "check1"..

Code:
 onFrame (51)  {
    
   if (check1==1 && check2==0) {
       gotoSceneAndPlay("Scene_4", 1 ); //correct answer
    }
  else 
    {
     gotoSceneAndPlay("Scene_5", 1)}; // wrong answer
}
Is this the correct way to do it or is there a way for me to check which button was pressed according to a variable assigned to the external xml file so that if I want to change the game's contents I'll only edit the xml file?

Hope that wasn't confusing..sorry for the long post,I'm really new to SwishMax and I'm going crazy with this problem..




               
 
View Public Profile Send a private message to petruccios Find all posts by petruccios Add petruccios to Your Contacts
#2    
 
cycle1500's Avatar

Name: 
cycle1500
Status: Offline
Rank: Oberlin, Ohio, USA
Posts: 1,495
Mood: MEAN: Do's not play well
Old 02-28-2012, 02:14 AM Reply With Quote


First off I tell all new people here it helps to zip or rar all you files and upload them so they can be checked. It is a lot easier to find and correct something with it in front of us then trying to guess what is there.

So upload you files.

Wayne


               
__________________
The Hairy One
Wayne helps those that helps themselves.
 
View Public Profile Send a private message to cycle1500 Find all posts by cycle1500 Add cycle1500 to Your Contacts
#3    

Name: 
petruccios
Status: Offline
Rank: SWiSHer
Posts: 6
Old 02-28-2012, 03:53 AM Reply With Quote


Thank you for the reply Wayne. I have uploaded the swi file along with the xml file I'm using.

The main idea is for the admin of the game to be able to change the questions only by editing the xml file instead of the whole swi file,but I can't find a way to check for the correct answer..I'd be really thankful if you could suggest a solution!




Attached Files
File Type: rar game.rar (232.7 KB, 18 views)
               
 
View Public Profile Send a private message to petruccios Find all posts by petruccios Add petruccios to Your Contacts
#4   reply  
 
cycle1500's Avatar

Name: 
cycle1500
Status: Offline
Rank: Oberlin, Ohio, USA
Posts: 1,495
Mood: MEAN: Do's not play well
Old 02-28-2012, 05:31 AM Reply With Quote


I have reworked it to a point so this should help out.

Wayne


Attached Files
File Type: zip game_alpha.zip (872.4 KB, 17 views)
               
__________________
The Hairy One
Wayne helps those that helps themselves.
 
View Public Profile Send a private message to cycle1500 Find all posts by cycle1500 Add cycle1500 to Your Contacts
#5    

Name: 
petruccios
Status: Offline
Rank: SWiSHer
Posts: 6
Old 02-28-2012, 05:41 AM Reply With Quote


Thank you Wayne! However, from what I see it was my mistake in the explanation of the problem. The problem wasn't in terms of displaying the total number of correct answers in the last Scene.

The problem is this: once the program is completed and exported into .swf , the user should be able to change the contents of the answers only by editing the xml file. However, I can't find a way to tell the program to use the xml file to check which of these two answers is the correct one..


               
 
View Public Profile Send a private message to petruccios Find all posts by petruccios Add petruccios to Your Contacts
#6    
 
cycle1500's Avatar

Name: 
cycle1500
Status: Offline
Rank: Oberlin, Ohio, USA
Posts: 1,495
Mood: MEAN: Do's not play well
Old 02-28-2012, 06:51 AM Reply With Quote


Your first problem was that the buttons you faded in was not showing the answers. You can not put a effect on this type of text box. It needs to be on stage when XML is called.

As for the user being able to change the contents of the answers. The XML will need to be changed and uploaded to the folder where your other files are. I really think you want a choise of answers for a question, when question series is passed then a new set of questions will pop up.

That means you files as they stand will have to be totally reworked. If this is what you are looking for I am sure I can work up an example for you.
Just let me know that is what you want.

Wayne


               
__________________
The Hairy One
Wayne helps those that helps themselves.
 
View Public Profile Send a private message to cycle1500 Find all posts by cycle1500 Add cycle1500 to Your Contacts
#7    

Name: 
petruccios
Status: Offline
Rank: SWiSHer
Posts: 6
Old 02-28-2012, 06:54 AM Reply With Quote


Actually I'm really new to SwishMax so I'm still trying to understand how it works..the main idea behind this is what I described on my previous post: the question and the answers should be loaded from the xml. This way,once the complete game is uploaded to the website folder, I will only need to edit the xml file to change the contents of the game rather than the swi file. Though I still can't find a way for the program to check which answer is correct.

If you could work up a simple example for me to understand I will be extremely thankful!!


               
 
View Public Profile Send a private message to petruccios Find all posts by petruccios Add petruccios to Your Contacts
#8    
 
cycle1500's Avatar

Name: 
cycle1500
Status: Offline
Rank: Oberlin, Ohio, USA
Posts: 1,495
Mood: MEAN: Do's not play well
Old 02-28-2012, 07:11 AM Reply With Quote


Ok put this away for a short while and in the next couple days I will have a complete game set up so you can follow along and learn.

Later

Wayne


               
__________________
The Hairy One
Wayne helps those that helps themselves.
 
View Public Profile Send a private message to cycle1500 Find all posts by cycle1500 Add cycle1500 to Your Contacts
#9    

Name: 
petruccios
Status: Offline
Rank: SWiSHer
Posts: 6
Old 02-28-2012, 07:13 AM Reply With Quote


You're a saviour Wayne!! Thanks a lot!


               
 
View Public Profile Send a private message to petruccios Find all posts by petruccios Add petruccios to Your Contacts
#10   quiz and xml  
 
cycle1500's Avatar

Name: 
cycle1500
Status: Offline
Rank: Oberlin, Ohio, USA
Posts: 1,495
Mood: MEAN: Do's not play well
Old 02-29-2012, 10:28 AM Reply With Quote


Ok here is the whole shot.
Now you will have a lot of studing to do, but it can be figured out.
All that is needed is to change the xml. Just pay attention to the structure.

Have Fun
Enjoy

Wayne


Attached Files
File Type: zip quiz_xml.zip (604.7 KB, 15 views)
               
__________________
The Hairy One
Wayne helps those that helps themselves.
 
View Public Profile Send a private message to cycle1500 Find all posts by cycle1500 Add cycle1500 to Your Contacts
#11    

Name: 
petruccios
Status: Offline
Rank: SWiSHer
Posts: 6
Old 02-29-2012, 10:29 AM Reply With Quote


I can't thank you enough for your help Wayne!! I'll study it and I'm sure I'll find out everything!


               
 
View Public Profile Send a private message to petruccios Find all posts by petruccios Add petruccios to Your Contacts
Advertisement:





Thread Tools
Display Modes

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

Forum Jump