thankx 4 reply here is the code...
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="library://ns.adobe.com/flex/mx"
xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:classes="classes.*"
xmlns:commerce="commerce.*"
xmlns:components="components.*"
xmlns:popups="popups.*"
creationComplete="application_creationCompleteHandler(event)"
layout="absolute"
width="100%" height="100%"
preinitialize="Spring.getInstance().initApplication()">
<fx:Style source="../styles/Style.css" />
<fx:Metadata>[Name]</fx:Metadata>
<fx:Script>
<![CDATA[
import classes.*;
import commerce.*;
import components.*;
import flash.media.*;
import flash.sampler.getInvocationCount;
import flash.utils.getTimer;
import mx.collections.ArrayCollection;
import mx.collections.ArrayList;
import mx.controls.Alert;
import mx.effects.Pause;
import mx.events.FlexEvent;
import mx.states.AddItems;
import org.granite.tide.Component;
import org.granite.tide.events.TideFaultEvent;
import org.granite.tide.events.TideResultEvent;
import org.granite.tide.spring.Context;
import org.granite.tide.spring.Identity;
import org.granite.tide.spring.Spring;
import org.osmf.utils.URL;
import popups.*;
import styles.*;
[Embed(source="/assets/ex1.jpg")]
[Bindable]
public var journalImage:Class;
[Embed(source="/assets/ex2.jpg")]
[Bindable]
public var natureImage:Class;
[Embed(source="/assets/ex3.jpg")]
[Bindable]
public var finalAccountImage:Class;
[Embed(source="/assets/ex4.jpg")]
[Bindable]
public var BRSImage:Class;
[Inject] [Bindable]
public var identity:Identity;
[In]
public var fileController:Component;
[In]
public var loginService:Component;
[Bindable]
private var message:String;
private var tideContext:Context =
Spring.getInstance().getSpringContext();
public var localHostAddress:String;
public var serveQuestion:ServeQuestion;
public var isHelpVisible:Boolean;
private var journalSolution:JournalQuestion;
private var natureSolution:Nature;
private var brsSolution:BRSQuestion;
protected function login_clickHandler(event:Event):void
{
identity.login(username.text, password.text,
loginResult, loginFault);
}
private function loginFault(event:TideFaultEvent):void
{
message = event.fault.faultString;
}
private function loginResult(event:TideResultEvent):void
{
loginService.logUser(onLoginLogResult,
onLoginLogFault);
}
private function
onLoginLogResult(event:TideResultEvent):void
{
var user:UserCA = event.result as UserCA;
caTitle.lblWelcome.text="Welcome !! "
+user.profile.firstName;
localHostAddress =
"http://"+user.profile.enrollmentNumber+":8080/commerce/vid/";
tideContext.studentsService.serveQuestion(onServeQuestionResult,
onServeQuestionFault);
}
private function
onLoginLogFault(event:TideFaultEvent):void
{
Alert.show("Error in maintaining login log" );
}
protected function
journalHelpIco_clickHandler(event:MouseEvent):void
{
if(isHelpVisible)
{
journal.hidePlayer();
journal.player.stop();
journal.player.visible = false;
isHelpVisible =false;
}
else if(journalSolution.help!=null &&
journal.questionAttempt>2)
{
journal.player.visible = true;
isHelpVisible = true;
journal.player.source=localHostAddress+"journal/"+journalSolution.help.helpContent;
}
}
protected function
natureHelpIco_clickHandler(event:MouseEvent):void
{
if(isHelpVisible)
{
nature.player.visible = false;
isHelpVisible =false;
}
else
if(natureSolution.natureHelp.helpContent!="Not Available")
{
nature.player.visible = true;
isHelpVisible = true;
nature.player.source=localHostAddress+"nature/"+natureSolution.natureHelp.helpContent;
}
}
private function
onHelpResult(event:TideResultEvent):void
{
journal.player.source = event.result as URL;
}
private function
onServeQuestionResult(event:TideResultEvent):void
{
caTitle.clock.startTimer();
caTitle.logoutIco.visible = true;
caTitle.lblWelcome.visible = true;
showResult.visible = true;
serveQuestion = event.result as ServeQuestion;
if(serveQuestion.QuestionExercise=="error")
{
Alert.show("error in last
attempt");
}
else
if(serveQuestion.QuestionExercise=="finish")
{
Alert.show("Congrats You have
conquered all questions !!");
}
else
if(serveQuestion.QuestionExercise=="Journal Entry")
{
setJournalImage();
loginForm.visible = false;
journal.visible = true;
journalSolution =
serveQuestion.journalQuestion;
journal.next.addEventListener("click" ,journalNext_clickHandler);
journal.feedJournal(journalSolution);
clock.startTimer();
}
else
if(serveQuestion.QuestionExercise=="Nature Practice")
{
setNatureImage();
loginForm.visible = false;
journal.visible = false;
nature.visible = true;
natureSolution =
serveQuestion.nature;
nature.next.addEventListener("click" ,natureNext_clickHandler);
nature.feedNature(natureSolution);
clock.startTimer();
}
else
if(serveQuestion.QuestionExercise=="BRS")
{
setBRSImage();
loginForm.visible = false;
journal.visible = false;
nature.visible = false;
brs.visible = true;
brsSolution =
serveQuestion.bRSQuestion;
brs.next.addEventListener("click" ,bRSNext_clickHandler);
brs.feedReconciliation(brsSolution);
//nature.feedNature(natureSolution);
clock.startTimer();
}
}
private function
journalNext_clickHandler(event:Event):void
{
journal.evaluateAnswer();
if(journal.questionAttempt>2)
{
journal.helpIco.addEventListener("click",journalHelpIco_clickHandler);
}
if(journal.solved)
{
var beep:Sound = new Sound(new
URLRequest("beep.mp3"));
beep.play(1,1);
var attempt:Attempt = new Attempt();
attempt.duration =
Number(clock.getSeconds());
attempt.journalQuestion =
journalSolution;
attempt.attempt =
journal.questionAttempt;
tideContext.studentsService.serveNextQuestion(attempt,onServeQuestionResult,
onServeQuestionFault);
}
}
private function
natureNext_clickHandler(event:Event):void
{
nature.evaluateAnswer();
if(nature.questionAttempt>2)
{
nature.helpIco.addEventListener("click",natureHelpIco_clickHandler);
}
if(nature.solved)
{
var beep:Sound = new Sound(new
URLRequest("beep.mp3"));
beep.play(1,1);
var attempt:Attempt = new Attempt();
attempt.duration =
Number(clock.getSeconds());
attempt.nature = natureSolution;
attempt.attempt =
nature.questionAttempt;
tideContext.studentsService.serveNextQuestion(attempt,onServeQuestionResult,
onServeQuestionFault);
}
}
protected function
bRSNext_clickHandler(event:MouseEvent):void
{
var correct:Boolean = true;
if(brs.validateBRS())
{
brs.attempts++;
brs.attempt.text = brs.attempts+"";
for(var
i:int=1;i<=brs.reconciliationRowCount;i++)
{
var
recRow:ReconciliationStudentComponent =
brs.adminContainer.getChildByName("reconcil" + i) as
ReconciliationStudentComponent;
var ansBrs:BRSAnswer =
brsSolution.bRSAnswers[i];
if(
(recRow.addOrSub.selectedValue as String) != ansBrs.addOrSub)
{
correct = false;
Alert.show(""+i);
break;
}
}
if(correct)
{
//var beep:Sound = new
Sound(new URLRequest("beep.mp3"));
//beep.play(1,1);
Alert.show("correct attempt");
var attempt:Attempt = new
Attempt();
attempt.duration =
Number(clock.getSeconds());
attempt.bRSQuestion =
brsSolution;
attempt.attempt = brs.attempts;
Alert.show("sadfasd sdfasd");
tideContext.studentsService.serveNextQuestion(attempt,onServeQuestionResult,
onServeQuestionFault);
}
else
{
Alert.show("Wrong Attempt");
}
}
}
private function
onServeQuestionFault(event:TideFaultEvent):void
{
Alert.show( "faultCode: " +
event.fault.faultCode +
"\n\nfaultString: " + event.fault.faultString, "FAULT" );
}
public function setJournalImage():void
{
globalWall.setStyle("backgroundImage",
journalImage);
}
public function setNatureImage():void
{
globalWall.setStyle("backgroundImage",
natureImage);
}
public function setFinalAccountImage():void
{
globalWall.setStyle("backgroundImage",
finalAccountImage);
}
public function setBRSImage():void
{
globalWall.setStyle("backgroundImage",BRSImage);
}
protected function
application_creationCompleteHandler(event:FlexEvent):void
{
caTitle.logoutIco.visible = false;
caTitle.lblWelcome.visible = false;
caTitle.logoutIco.addEventListener("click"
,logout_clickHandler);
reportCard.backToExercise.addEventListener("click" , serveQuestionAndShow );
}
protected function
serveQuestionAndShow(event:Event):void
{
reportCard.visible = false;
tideContext.studentsService.serveQuestion(onServeQuestionResult,
onServeQuestionFault);
}
protected function
logout_clickHandler(event:MouseEvent):void
{
loginService.logoutUser(onlogoutUserResult,onlogoutFault);
}
private function
onlogoutUserResult(event:TideResultEvent):void
{
navigateToURL(new
URLRequest('commerce.html'),"_self");
/*
ExternalInterface.call("window.open","","_self");
ExternalInterface.call("window.close");
**/
}
private function
onlogoutFault(event:TideFaultEvent):void
{
/*
var urlString:String =
"javascript:window.opener = self; self.close();";
var request:URLRequest = new
URLRequest(urlString);
navigateToURL(request, "_self");
*/
navigateToURL(new
URLRequest('commerce.html'),"_self") ;
}
protected function
showResult_clickHandler(event:MouseEvent):void
{
tideContext.prepareResultService.getMyScoreCard(onPrepareResult,onPrepareFault);
}
public function
onPrepareResult(event:TideResultEvent):void
{
journal.visible = false;
nature.visible = false;
reportCard.visible = true;
var resultScore:ScoreCard = event.result as
ScoreCard;
var resultArrayCollection:ArrayCollection = new
ArrayCollection();
var resultData:ArrayCollection =
resultScore.todayAttempts as
ArrayCollection;
for(var m:int=0;m<resultData.length;m++)
{
var id:int = resultData[m].id
var serialNo:String = (m+1)as String
var question:String;
if(resultData[m].journalQuestion!=null)
{
question =
resultData[m].journalQuestion.question as String;
}
else if(resultData[m].nature!=null)
{
question =
resultData[m].nature.particular as String;
}
var attempt:int = resultData[m].attempt;
var duration:int =
resultData[m].duration;
var marks:int = resultData[m].marks;
resultArrayCollection.addItem({Id:id,
SerialNo:(m+1), Question:
question, Attempt:attempt, Duration:duration, Marks: marks });
}
reportCard.scoreArray =
resultArrayCollection;
reportCard.question.text = "Question
Solved : "+resultScore.questions ;
reportCard.duration.text = "Duration :
"+resultScore.duration ;
reportCard.marks.text = "Marks : " +
resultScore.marks;
reportCard.totalQuestion.text = "Total
Question :
"+resultScore.totalQuestion ;
reportCard.totalDuration.text = "Total
Duration :
"+resultScore.totalDuration ;
reportCard.totalMarks.text = "Total
Marks : " + resultScore.totalMarks;
reportCard.result = resultData;
}
public function
onPrepareFault(event:TideFaultEvent):void
{
Alert.show( "faultCode: " +
event.fault.faultCode +
"\n\nfaultString: " + event.fault.faultString, "FAULT" );
}
]]>
</fx:Script>
<s:BorderContainer id="globalWall" x="0" y="0" width="100%"
height="100%" backgroundImage="@Embed(source='assets/login.jpg')"
borderVisible="false">
<mx:Panel id="loginForm"
title="Login"
horizontalAlign="center"
verticalGap="0" paddingTop="8" paddingBottom="8"
verticalAlign="middle" layout="vertical" x="324" y="253"
height="193">
<mx:Form>
<mx:FormItem label="Username">
<mx:TextInput id="username" />
</mx:FormItem>
<mx:FormItem label="Password">
<mx:TextInput id="password"
displayAsPassword="true"
enter="login_clickHandler(event)"/>
</mx:FormItem>
</mx:Form>
<mx:Label text="{message}"/>
<mx:Image id="loginIco"
source="@Embed(source='icons/log_in.png')"
click="login_clickHandler(event)" buttonMode="true" />
</mx:Panel>
<components:CATitle id="caTitle" x="0" y="17" />
<mx:LinkButton id="showResult" label="That's it"
click="showResult_clickHandler(event)" y="48" x="875"
visible="false"/>
<components:ReportCard id="reportCard" visible="false" x="25"
y="80"
width="97%" />
<components:JournalEntryStudent id="journal" visible="false" x="0"
y="60" />
<components:NaturePracticeStudent id="nature" visible="false"
y="60" />
<components:ReconciliationStudent id="brs" visible="false"
x="0" y="60" />
<components:TimerControl id="clock" visible="false"/>
<popups:PopUpCourse visible="false" />
<!-- <s:Button click="button_clickHandler(event)" /> -->
</s:BorderContainer>
</mx:Application>
--
You received this message because you are subscribed to the Google Groups "Flex
India Community" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/flex_india?hl=en.

