Flash AS3 commenting

code working fully but struggling to understand the functions

Page 1 of 1

3 Replies - 2266 Views - Last Post: 22 April 2010 - 06:33 AM

#1 [email protected]   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 21-April 10

Flash AS3 commenting

Posted 21 April 2010 - 08:31 AM

hi there, i have been looking at this quiz code a friend helped me with however i am looking to comment the code to enable me to get a fuller and better understanding of it, any help would be appreicated as the commenting needs to be correct to aid me to fully understand how my code is working - there is another layer in the scene with code and another frame in the layer with code on - and all works fine, jus the commenting im struggling with.

cheers thanks alot - code attactched

stop();


//setting up of variables and setting their starting state
//also setting movie clip visabilty to false - not showing
var qno=0;var rnd1; var rnd2;
tick.visible=false;cross.visible=false;
var right_answers=0;var wrong_answers=0;



//the code below shows enables both the order of the set questions and the order of the answer

function change_question()
{
	if(tick.visible){right_answers++;}
	if(cross.visible){wrong_answers++;}
	if(qno==questions.length){gotoAndPlay(2);}else{
	tick.visible=false;cross.visible=false;
	rnd1=Math.ceil(Math.random()*3);
	rnd2=Math.ceil(Math.random()*questions.length)-1;
	q.text=questions[rnd2];
	if(questions[rnd2]=="x"){change_question();}
	questions[rnd2]="x";
	enable_disable(1);
	if(rnd1==1){opt1.text=answers[rnd2][0];opt2.text=answers[rnd2][1];opt3.text=answers[rnd2][2];}
	if(rnd1==2){opt1.text=answers[rnd2][2];opt2.text=answers[rnd2][0];opt3.text=answers[rnd2][1];}
	if(rnd1==3){opt1.text=answers[rnd2][1];opt2.text=answers[rnd2][2];opt3.text=answers[rnd2][0];}
	}}
	
function enable_disable(a){
	if(a==0){shade1.mouseEnabled=false;shade2.mouseEnabled=false;shade3.mouseEnabled=false;}
	if(a==1){shade1.mouseEnabled=true;shade2.mouseEnabled=true;shade3.mouseEnabled=true;}}
	
change_question();

next_b.addEventListener(MouseEvent.CLICK, ButtonAction1);
function ButtonAction1(eventObject:MouseEvent) {qno++;change_question();} 

shade1.addEventListener(MouseEvent.CLICK, ButtonAction2);
shade2.addEventListener(MouseEvent.CLICK, ButtonAction3);
shade3.addEventListener(MouseEvent.CLICK, ButtonAction4);

function ButtonAction2(eventObject:MouseEvent) {enable_disable(0);if(rnd1==1){tick.visible=true;tick.y=shade1.y}else{cross.visible=true;cross.y=shade1.y}}
function ButtonAction3(eventObject:MouseEvent) {enable_disable(0);if(rnd1==2){tick.visible=true;tick.y=shade2.y}else{cross.visible=true;cross.y=shade2.y}}
function ButtonAction4(eventObject:MouseEvent) {enable_disable(0);if(rnd1==3){tick.visible=true;tick.y=shade3.y}else{cross.visible=true;cross.y=shade3.y}}

stop();



Admin Edit: Please use code tags when posting your code. Code tags are used like so => :code:

Thanks,
PsychoCoder :)

Is This A Good Question/Topic? 0
  • +

Replies To: Flash AS3 commenting

#2 booleanops   User is offline

  • New D.I.C Head
  • member icon

Reputation: 2
  • View blog
  • Posts: 24
  • Joined: 18-June 09

Re: Flash AS3 commenting

Posted 21 April 2010 - 05:39 PM

Hi catters929,

Are you asking the syntax for adding a single line comment using //

// like this

or a block comment using /* and */ like

/*setting up of variables and setting their starting state
also setting movie clip visibility to false - not showing*/

or are you asking for someone to comment that code and tell you how it works?
Was This Post Helpful? 0
  • +
  • -

#3 PsychoCoder   User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1660
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: Flash AS3 commenting

Posted 21 April 2010 - 05:43 PM

Let me rephrase your question so everyone can understand it:

Quote

I found this code and want to turn it in for my assignment but the teacher wants us to comment our code. Since I didn't write this I cannot comment it so can someone here do it for me so I don't get an F on the assignment please

Was This Post Helpful? 0
  • +
  • -

#4 W3bDev   User is offline

  • D.I.C Regular
  • member icon

Reputation: 42
  • View blog
  • Posts: 379
  • Joined: 15-March 09

Re: Flash AS3 commenting

Posted 22 April 2010 - 06:33 AM

LOL... awesome Psycho.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1