Skip to content

Instantly share code, notes, and snippets.

@DapperFox
Created February 5, 2014 21:10
Show Gist options
  • Save DapperFox/8833172 to your computer and use it in GitHub Desktop.
Save DapperFox/8833172 to your computer and use it in GitHub Desktop.
Read for workout and lifting
// Reads workout from readWorkout.php
public function readWorkouts(kind:int)
{
var workoutLoader:urlLoader = new URLLoader;
var workoutVariables:URLVariables = new URLVariables;
var workoutURL:urlRequest = new urlRequest(path + "readWorkout.php");
workoutVariables.uid = userId;
workoutVariables.kind = kind;
workoutURL.data = workoutVariables;
workoutLoader.load(workoutURL);
workoutLoader.addEventListener(Event.COMPLETE, displayWorkouts);
}
// Displays what has been read from readWorkouts
// Callback function of displayLoader
public function displayWorkouts(e:Event)
{
var workoutData = e.target.data;
var workoutArray = workoutData.split('&');
for(var i:int = 0; i < workoutArray.length-1; i++)
{
var valuesArray = workoutArray[i].split[','];
// 0 is type, 1 is intensity, 2 is date
trace(valuesArray[0] + valuesArray[1] + valuesArray[2]);
// todo make text box in flash
// Add text box to page here with values
}
}
// Reads workout from readWorkout.php
public function readLifting()
{
var liftingLoader:urlLoader = new URLLoader;
var liftingVariables:URLVariables = new URLVariables;
var liftingURL:urlRequest = new urlRequest(path + "readLifting.php");
liftingVariables.uid = userId;
liftingURL.data = liftingVariables;
liftingLoader.load(liftingURL);
liftingLoader.addEventListener(Event.COMPLETE, displayLifting);
}
// Displays what has been read from readLifting
// Callback function of displayLoader
public function displayLifting(e:Event)
{
var liftingData = e.target.data;
var liftingArray = liftingData.split('&');
var numOfEntries = liftingArray.length-1;
var spacing = 0;
for(var i:int = 0; i < numOfEntries; i++)
{
// todo add to stage
var valuesArray = liftingArray[i].split[','];
// 0 is muscle, 1 is sets, 2 is reps, 3 is poundage, 4 is date
trace(valuesArray[0] + valuesArray[1] + valuesArray[2] + valuesArray[3], valuesArray[4]);
var liftingBox = new informationDisplay_mc;
liftingBox.text = valuesArray[0] + ' ' + valuesArray[1] + ' ' + valuesArray[2] + ' ' + valuesArray[3] + ' ' + valuesArray[4];
// todo make text box in flash
// Add text box to page here with values
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment