Web Site

The web site is now live at www.vedamatics.com

Monday, February 7, 2011

Working Code - Main.fla

What works:



stop();

import com.greensock.*;
import com.greensock.easing.*;

//import the tween styles
import fl.transitions.Tween;
import fl.transitions.easing.*;



/* -------------Loading the Swf files ------------------- */

//Loader files to load SWF files into the main file
var swfLoader:Loader = new Loader();
var preLoader:preLoad_mc = new preLoad_mc();
//on the above line preLoader is the instance name which is given!

//using our loader to load an external file
function loadFile(filePath:String)
{
addChild(preLoader);
preLoader.x = 400;
preLoader.y = 350;
swfLoader.load(new URLRequest(filePath));

//add event listener that gathers the progress of the loading
swfLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS,progInfo);
swfLoader.contentLoaderInfo.addEventListener(Event.COMPLETE,finishLoad);
//new Tween(object, property, function(ease), begin, finish, duration, useSeconds)
// alpha begin will be at 0 and then end will be at 1
var swfTween = new Tween(swfLoader,"alpha",None.easeOut,0,1,1,true);
//var swfTween = new Tween(swfLoader,"x",Strong.easeOut,900,0,2,true);

}

function progInfo(event:ProgressEvent):void
{
/* Reference for simple loader of numbers of bytes
var bytes:Number = event.bytesLoaded;
preLoader.load_text.text = bytes + " bytes loaded..."*/
var percent:Number = Math.round(event.bytesLoaded/event.bytesTotal * 100);
preLoader.load_text.text = percent + "%";
preLoader.prog_bar.scaleX = percent/100;

}

function finishLoad(event:Event):void
{
removeChild(preLoader);
load_area_mc.addChild(swfLoader);

}

/* ----------- Menu ---------------- */

var tl:TimelineMax = new TimelineMax({paused:true});

tl.insert(TweenMax.to(floater_mc, 2, {bezierThrough:[{x:430, y:631}, {x:670, y:580}], orientToBezier:true, ease:Linear.easeNone}))

uAbout_mc.gotoAndPlay("on");
uHistory_mc.gotoAndPlay("off");
uSutras_mc.gotoAndPlay("off");
uTutorials_mc.gotoAndPlay("off");
uQuiz_mc.gotoAndPlay("off");

about_btn.addEventListener(MouseEvent.CLICK, goAbout);

function goAbout(e:MouseEvent):void{
tl.tweenTo(0);
uAbout_mc.gotoAndPlay("on");
uHistory_mc.gotoAndPlay("off");
uSutras_mc.gotoAndPlay("off");
uTutorials_mc.gotoAndPlay("off");
uQuiz_mc.gotoAndPlay("off");

}

history_btn.addEventListener(MouseEvent.CLICK, goHistory);
function goHistory(e:MouseEvent):void{
tl.tweenTo(tl.duration *.25);
uAbout_mc.gotoAndPlay("off");
uHistory_mc.gotoAndPlay("on");
uSutras_mc.gotoAndPlay("off");
uTutorials_mc.gotoAndPlay("off");
uQuiz_mc.gotoAndPlay("off");

}

sutras_btn.addEventListener(MouseEvent.CLICK, goSutras);
function goSutras(e:MouseEvent):void{
tl.tweenTo(tl.duration *.5);
loadFile("assets/swfs/sutras.swf");
uAbout_mc.gotoAndPlay("off");
uHistory_mc.gotoAndPlay("off");
uSutras_mc.gotoAndPlay("on");
uTutorials_mc.gotoAndPlay("off");
uQuiz_mc.gotoAndPlay("off");
}


tutorials_btn.addEventListener(MouseEvent.CLICK, goTutorials);
function goTutorials(e:MouseEvent = null):void{
tl.tweenTo(tl.duration *.75);
loadFile("assets/swfs/tutorials.swf");
uAbout_mc.gotoAndPlay("off");
uHistory_mc.gotoAndPlay("off");
uSutras_mc.gotoAndPlay("off");
uTutorials_mc.gotoAndPlay("on");
uQuiz_mc.gotoAndPlay("off");

}

quiz_btn.addEventListener(MouseEvent.CLICK, goQuiz);
function goQuiz(e:MouseEvent = null):void{
tl.tweenTo(tl.duration);
loadFile("assets/swfs/quiz.swf");
uAbout_mc.gotoAndPlay("off");
uHistory_mc.gotoAndPlay("off");
uSutras_mc.gotoAndPlay("off");
uTutorials_mc.gotoAndPlay("off");
uQuiz_mc.gotoAndPlay("on");
}


/* ------------------ End Menu -------------------------------- */

/* ---------------- Intro ---------------- */

//for user to choose to go to Tutorials or Quiz from Intro
var userChoice:Boolean = true;

//used Event dispatch in bg_mc last frame
bg_mc.addEventListener("bgDone", bgDone);

function bgDone(e:Event):void
{
trace("bg done");
if (userChoice == true){
goTutorials();
} else{
goQuiz();
}
}


intro_mc.visible=true;
intro_mc.old_btn.addEventListener(MouseEvent.CLICK, goTutOld);
function goTutOld(e:MouseEvent):void{
intro_mc.visible=false;
bg_mc.play();
userChoice=true;

}

intro_mc.new_btn.addEventListener(MouseEvent.CLICK, goQuestion);
function goQuestion(e:MouseEvent):void{
intro_mc.visible=false;
question_mc.play();
}

question_mc.a_btn.addEventListener(MouseEvent.CLICK, goA);
function goA(e:MouseEvent):void{
intro_mc.visible=false;
question_mc.visible=false;
bg_mc.play();
userChoice=false;
}

question_mc.b_btn.addEventListener(MouseEvent.CLICK, goB);
function goB(e:MouseEvent):void{
intro_mc.visible=false;
question_mc.visible=false;
bg_mc.play();
userChoice=true;
}

No comments:

Post a Comment