A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: Help getting from timeline code to classes..

  1. #1
    Senior Member
    Join Date
    Sep 2000
    Posts
    272

    Help getting from timeline code to classes..

    Greetings,

    I am writing as I am hoping to get away from timeline coding and into classes, but can't seem to get there.

    Here is what I have:

    Functions like this in frame 1, layer 1, that extends the entire timeline which consists of 21 frames:

    Code:
    var qFunc:Number;
    var ansN:Number;
    var ansB:Number;
    var Score:Number = 0;
    var q:Object = new Object();
    var qSnd:Array = new Array();
    var NItems:Number;
    function nextQuest()
    {
    	this["Q" + qFunc]();
    	listen_btn.enabled = true;
    	nextAudio();
    }
    And functions like this on subsequent frames of the main timeline on layer 2:
    Code:
    // this allows for questions and info to be presented to user. As user progresses, the timeline playhead advances to another frame with similar code, just different values for the qFunc and NItems vars and the Q functions.
    
    stop();
    ClearAllHandler();
    qFunc = 1;
    NItems = 10;
    Score = 0;
    enableListenBtn();
    
    Q1();
    function Q1()
    {
    	ansN = 2;
    }
    function Q2()
    {
    
    	ansN = 1;
    }
    function Q3()
    {
    
    	ansN = 2;
    }
    
    //etc...
    
    //On the next frame there is this:
    
    stop();
    ClearAllHandler();
    qFunc = 11;
    NItems = 10;
    Score = 0;
    enableListenBtn();
    
    Q11();
    function Q11()
    {
    	ansN = 2;
    }
    function Q12()
    {
    
    	ansN = 1;
    }
    function Q13()
    {
    
    	ansN = 2;
    }
    
    // and so on for a total of 21 frames with code on each
    I have considered placing all the main functions in a document class and separate class files for each set of question functions. Not having enough experience with class files except for simple one-offs with a single function, this has been a real brain buster for me.

    Any advice will be greatly appreciated.

  2. #2
    Senior Member Steven FN's Avatar
    Join Date
    Mar 2010
    Location
    CA, USA
    Posts
    276
    I would suggest using a reusable function for the bulk of it. Depending on how your quiz is setup.
    I've made XML quizzes in the past, that use only a few functions to process the XML and functions of the quiz - right/wrong checking, scoring, etc.
    But it looks like all your questions are all on different frames in the main timeline. Either way you can still write a fairly simple set of functions to make things more manageable.
    I know this doesn't really help you in any way but i just thought i'd give you my advice.

    Also, having each set of questions in its own class file, seems inefficient. Well, i do advocate coding in the FLA, but depending on the project size, i think it is unnecessary unless you have over 100 questions and a large variety of different question types - multiple choice, fill-in, matching, pairing, essay, etc.

  3. #3
    Senior Member
    Join Date
    Sep 2000
    Posts
    272
    Thanks for the input and advice. I will probably use XML for the question data as you mentioned.

    Cheers!

  4. #4
    Senior Member
    Join Date
    Sep 2000
    Posts
    272
    Thanks for the input and advice. I will probably use XML for the question data as you mentioned.

    Cheers!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center