Showing posts with label 10. Show all posts
Showing posts with label 10. Show all posts

Friday, February 27, 2015

Top 10 Learning Sites for Yours T10LS


"Education is what remains after one has forgotten what one has learned in school."
- Albert Einstein

"See, heres the thing, though. I dont want 99 mind mapping resources, tools, and tips. I want one. That works. Really well. "
- Stephen Downes



CLUELESS?
To cut the crap short, and get to the point... It is amazing how many educators (that I have crossed path with) until today (Yes, already 2010!), who are clueless or know little about the amazing world of Open Educational Resources (OER)/Open Courseware (OCW) and learning tools. There are probably many reasons for that, so I am not going to go into that.

But, what I find even more shocking and troubling is educators who are also clueless about the amazing learning possibilities (tools and resources) within their own field/area/specialization/learning domain. I just hope you are not one of them.

No doubt we cant know and do everything, and there will always be new tools and resources blazing through in an ever growing global learning sharing stream. But, we should have some idea, or be open to explore new and innovative learning possibilities within our learning domain(s), because our students deserve it (or they will eventually desert us...).



WHAT TO DO?
So, how can we motivate or inspire educators to find and explore these new learning possibilities?

Peer pressure? Peer recommendation? Now, we are getting closer (I think!). Of course mambo jumbo lists are useful (e.g. OER), but for a busy educator it might be.... No time for that! Stephen Downess quote above makes sense!

But, what if we filtered out the juiciest learning resources and tools, and stamped our validation for use (or recommendation). Now, that would be interesting, wouldnt it? Instead of 1000, 100, it is narrowed down to digestible portions (unless you are Takeru Kobayashi!).

To set a digestible portion criteria, we could use the magical number of seven, but I am going to suggest no more than 10 for whatever... Anyway, we dont have to be too rigid on such things, but just be reminded that Less is often more (especially for learning). Look whos talking :)

For example, I am looking for excellent resources or tools to explore critical thinking, where to start? I know Stephen Downes is facilitating a Critical Literacies Online Course, and has published a widely used Guide to the Logical Fallacies. So, wouldnt it be great to have a juicy Top 10 (or anything less, or perhaps a bit more!) list of excellent critical thinking resources recommended by Stephen Downes as a starting point.

Of course, there are many more sites to explore, but having a great starting point validated or recommended by an expert wont harm anyone (would it?).

So, lets think bigger! What if more experts shared their filtered and recommended learning resource lists for their particular specializations or areas. Imagine great contextualized learning start points for Psychology, Medicine, Biology, Law, English, Creative thinking, critical thinking...(perhaps a bit more micro) you name it. Now, wouldnt that be useful?



MY TOP 10 LEARNING SITES FOR PERSONAL LEARNING
Here are 10 amazing learning resources to explore for personal learning, especially if you are into e-learning and learning (Not ranking, just numbering):
  1. Einztein
    A wonderful starting point to find free online courses with a bit of spice from top Universities. Also, the Academic Porthole is a great starting point, as it also includes OER guides to several learning domains.

  2. iTunes U
    Here you can find more than 250,000 free lectures, videos, films, and other resources from many of the top Universities around the world. Since I am using an IPhone (and IPod), it is such a wonderful resource to feed me with recorded lectures for my long traffic jams every working day.

  3. YouTube EDU and Academic Earth
    YouTube has aggregated all of the videos from its college and university partners - including luminaries like Stanford, Harvard, and Dartmouth - in one place. Academic Earth is an educational video website with the goal of enhancing the usability and expanding the awareness of OER, focusing first on video lectures. Since most of its resources are aggregated from YouTube, I have mashed both into one. Also, you can even grade the lectures (A to F) on Academic Earth. Cool!

  4. TED Talks
    Hundreds of inspiring talks by the some of the most innovative and amazing thinkers and doers the world has to offer. And 95.5% of these talks are 20 minutes or shorter, meaning they are perfect for mobile learning. How on earth can we ignore such a resource (after discovering it)?

  5. OLDaily (Stephen Downes)
    If you are looking for the latest news, trends, reflections, etc. in the (online) learning world, Stephen Downes is the ultimate synthesizer (that I have come across) of what is going on. I love the way he reflects and extracts the essence (or what he finds interesting) of all the articles, sites, tools, resources, etc. he discovers in his daily online newsletter (excluding weekends!). You might also want to also check out his homepage to discover all the other stuff he is doing, including his other excellent reflective blog (Half an Hour) and video recordings of all his presentations. While talking about Stephen Downes, we cannot ignore George Siemens and his elearnspace. He is the mastermind (together with Stephen Downes) behind Connectivism, the only learning theory that makes sense in the online learning world. His reflections and ramblings will keep you updated with e-learning, knowledge management, networks, technology, community development, and corporate learning.

  6. Centre for Learning & Performance Technologies (Jane Hart)
    If you want to find or know more about learning tools and how to use them to facilitate online learning that sizzles, then this site will serve you amazingly well. Janes E-Learning Pick of the Day is awesomely useful, and you wont be disappointed with her Tools Directory and Top Tools for Learning 2010. In addition, I love the fact that she provides us with a weekly round-up of the new learning tools added to the tools directory. Besides that you just have to check out her social media guides:

    • Introduction to social media for learning
    • Social Media for Workplace Learning
    • How to use Twitter for Social Learning
    • How to use Facebook for Social Learning

    These social media guides are simply a goldmine for anyone who is clueless, or wants to learn how to implement social learning in their teaching and learning environments. Also, dont miss her 100 Featured Learning Professionals, which will provide you with information, inspiration and/or interaction on a range of educational and workplace learning topics from around the world - via their blog, on Twitter or on other social networks. A life time worth of learning!

  7. The Rapid eLearning Blog (Tom Kuhlmann)
    When you think about improving your rapid e-Learning, instructional design, PowerPoint or graphic creation skills, Tom Kuhlmanns Rapid eLearning blog provides you with a lot of great advice, tips, examples and short-cuts. Also, dont forget to get his free elearning ebook while you’re there. In short, this blog is easily my favorite Rapid e-Learning learning blog! No doubt about that!

  8. ELearningLearning (Tony Karrer)
    It is not really a list, but an amazing aggregator of excellent workplace or corporate learning blogs and posts filtered out by Tony Karrer. Just subscribe to this one, and you are basically subscribing to tons of great corporate or workplace learning blogs out there. Actually, it is a blog post repository in itself, and you will find the indexing, Monthly top featured posts, best from.., etc. very exciting (Well at least I did!). It uses the Browse My Stuff technology to create this topic hub. Topic Hubs are sites that aggregates content from a variety of sources, organizes that content around keywords in the topic domain, and supports both manual and social curation of that content.

  9. Kapp Notes (Karl Kapp)
    If you want a blog that explores 3D learning, Second Life and learning games in general, this blog is certainly one of the best that I have come across.

  10. iLearn technology (Kelly Tenkely)
    This blog is dedicated to giving teachers practical tips for integrating technology into the classroom. The learning stories are short, sweet and digestible. Perfect for the busy educator. Kelly you rock!

Besides these awesome learning sites, there are tons of other outstanding bloggers, sites, tutorials, learning games and tools to explore, but having a good starting, or knowing what sites that consume most of my online learning time should not be any harm.



YOUR TOP 10 LEARNING SITES FOR _________?
Alright, that was my top 10 learning sites for personal learning. What about you? Do you have any amazing sites to share from your learning domain? If you are interested to participate, simply share your Top 10 list through your blog, or using any learning tool convenient for you. Then, either blast me a comment with a URL to your list, or perhaps tweet the URL to the list using the following Twitter hashtag:

#T10LS

If many of you want to participate, I will setup a wiki (using Google Sites), whereby we all can collaborate to build. Actually, it would have been cool if someone like Jane Hart could use her magic to create something similar to the Top Tools for Learning 2010 for learning sites. Now, that would be awesome!

If no one is interested, too bad! At least you can enjoy my top 10 (personal) learning sites list above. Perhaps, whatever I have said, already exists. What do you think? :)
Read more »

Saturday, February 14, 2015

C program to print numbers from 1 to 10 using for loop


#include<stdio.h>
#include<conio.h>

void main()
{
int i;
clrscr(); //to clear the screen

for(i=1;i<=10;++i)
{
printf("%d",i);
printf("
");

}

getch(); //to stop the screen
}
Read more »

Thursday, February 5, 2015

KirSizer Flex AIR Image Sizer app Part 10

In todays tutorial we will add support for working with not just separate files from the selected list, but also folders.

First of all go to the beginResize() function and in the if(canProceed) statement set progressBars progress to 0 manually, and call nextAction() instead of resizeNext().

if (canProceed) {
contentStack.selectedIndex = 3;
var timer:Timer = new Timer(400, 1);
timer.addEventListener(TimerEvent.TIMER_COMPLETE, onTimer);
timer.start();
function onTimer(evt:TimerEvent):void {
buttonError.enabled = false;
buttonReturn.enabled = false;
logArea.text = "";
logArea.appendText("Beginning resizing of " + totalFiles + " files...
");
currentNum = 0;
totalErrors = 0;
progressBar.setProgress(0, totalFiles);
nextAction();
}
}

Now comes the complicated part.

Each object in the selectedFiles array is either a file or a folder. Right now, the currentNum value represents which object is currently being resized, and since we only resized files, currentNum also represented the number of the file that was being resized, so we could use it as the current value in progressBar. Now, well just increase a value unrelated to currentNum and apply it to progressBar.

Since an object in this array can be either file or a folder, we need to check what it is in resizeNext(). It will receive a boolean value (true if its a folder, false if its a file), and we can use that to execute approporiate code. For files, we increase currentNum and set file object to the one in selectedFiles under currentNum-1 index. For folders, we use a global folderArray (values to which are applied beforehand and are the image files in the current folder, will explain this shortly) and take the last element from this array and use it as the file. We also remove the last file from this array and basically keep doing the same thing until folderArray is empty. When its empty, only then we increase currentNum and move on to the next object in selectedFiles.

In nextAction() function, we check if the folderArray is empty. If it is not, we call resizeNext(true) (we actually call resizeNext(isFolder) later, but we set isFolder to true so that the true value is passed). Then we check if the next element in the queue is a folder and folderArrays length is currently 0. If it is so, we loop through the children of this array and add image files to folderArray. Then we set isFolder to true and call resizeNext(isFolder).

Also, in nextAction() function we compare currentNum to selectedFiles.length instead of totalFiles.

The program workflow is represented in this scheme:



The nextAction() function with updates:

private function nextAction():void {
if (currentNum < selectedFiles.length) {
var isFolder:Boolean = false;
// if its a folder, create a global array that stores all image files of the folder
if (folderArray.length > 0) isFolder = true;
if (selectedFiles.length > currentNum && selectedFiles[currentNum].type == 1 && folderArray.length == 0) {
isFolder = true;
folderArray = [];
var folder:File = new File(selectedFiles[currentNum].path);
var allContent:Array = folder.getDirectoryListing();
for (var i:int = 0; i < allContent.length; i++) {
if (allContent[i].isDirectory == false && (allContent[i].extension.toLowerCase() == "png" || allContent[i].extension.toLowerCase() == "jpg" || allContent[i].extension.toLowerCase() == "jpeg")) {
folderArray.push(allContent[i]);
}
}
}
resizeNext(isFolder);
}else {
logArea.appendText("Operation complete!");
buttonError.enabled = true;
buttonReturn.enabled = true;
}
}

The updated resizeNext() function:

private function resizeNext(isFolder:Boolean):void {
var file:File;
var canProceed:Boolean = true;
var loader:Loader;
var currentProgress:int = progressBar.value + 1;
progressBar.setProgress(currentProgress, totalFiles);

// if its a file
if (!isFolder){
currentNum++;
file = new File(selectedFiles[currentNum - 1].path);
}

// if its a folder
if (isFolder) {
file = folderArray.pop();
if (folderArray.length == 0) currentNum++;
}

logArea.appendText("#" + currentProgress + " (" + file.name + ")
");

// Error: file not found
if (!file.exists) {
canProceed = false;
logArea.appendText("ERROR: File not found
");
totalErrors++;
nextAction();
}


// Error: bad extension
if (file.exists && file.extension.toLowerCase() != "png" && file.extension.toLowerCase() != "jpg" && file.extension.toLowerCase() != "jpeg") {
canProceed = false;
logArea.appendText("ERROR: Incorrect extension
");
totalErrors++;
nextAction();
}

// load image
if (canProceed) {
loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoadComplete);
loader.load(new URLRequest(file.url));
}

// start timer
function onLoadComplete(evt:Event):void {
var timer:Timer = new Timer(500, 1);
timer.addEventListener(TimerEvent.TIMER_COMPLETE, onTimer);
timer.start();
}

function onTimer(evt:TimerEvent):void {
// new name
var newName:String = nameInput.text.replace("%initialName%", file.name.substr(0, file.name.lastIndexOf(.)));
newName = newName.replace("%num%", currentNum);

// new extension
var newExtension:String;
if (formatCombo.selectedIndex == 0) newExtension = file.extension;
if (formatCombo.selectedIndex == 1) newExtension = "jpg";
if (formatCombo.selectedIndex == 2) newExtension = "png";

// new size
var currentW:int = loader.content.width;
var currentH:int = loader.content.height;
var newW:int;
var newH:int;
var ratio:Number;

if (actionCombo.selectedIndex == 0) {
if (widthMeasure.selectedIndex == 0) newW = newWidth.value/100 * currentW;
if (widthMeasure.selectedIndex == 1) newW = newWidth.value;
if (heightMeasure.selectedIndex == 0) newH = newHeight.value/100 * currentH;
if (heightMeasure.selectedIndex == 1) newH = newHeight.value;
}

if (actionCombo.selectedIndex == 1) {
ratio = currentW / currentH;
if (widthMeasure.selectedIndex == 0) newW = newWidth.value/100 * currentW;
if (widthMeasure.selectedIndex == 1) newW = newWidth.value;
newH = newW / ratio;
}

if (actionCombo.selectedIndex == 2) {
ratio = currentW / currentH;
if (heightMeasure.selectedIndex == 0) newH = newHeight.value/100 * currentH;
if (heightMeasure.selectedIndex == 1) newH = newHeight.value;
newW = newH * ratio;
}

if (actionCombo.selectedIndex == 3) {
ratio = currentW / currentH;
newW = newWidth.value;
newH = newW / ratio;
if (newH > newHeight.value) {
newH = newHeight.value;
newW = ratio * newH;
}
}

// log
logArea.appendText("Resized from " + currentW + "x" + currentH + " to " + newW + "x" + newH + "
");
logArea.appendText("Renamed to " + newName + "." + newExtension + "
");

nextAction();
}

}

Full code:

<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
width="300" height="460"
showStatusBar="false" title="KirSizer" creationComplete="init();">

<fx:Declarations>
<mx:ArrayCollection id="measures">
<fx:String>%</fx:String>
<fx:String>px</fx:String>
</mx:ArrayCollection>
<mx:ArrayCollection id="actions">
<fx:String>Fixed width, fixed height</fx:String>
<fx:String>Fixed width, proportional height</fx:String>
<fx:String>Proportional width, fixed height</fx:String>
<fx:String>Proportional sizes to fit specified sizes</fx:String>
</mx:ArrayCollection>
<mx:ArrayCollection id="formats">
<fx:String>Same format as initial file</fx:String>
<fx:String>Convert all to JPG</fx:String>
<fx:String>Convert all to PNG</fx:String>
</mx:ArrayCollection>
<mx:Fade id="fadeIn" alphaFrom="0" alphaTo="1" duration="300"/>
<mx:Fade id="fadeOut" alphaFrom="1" alphaTo="0" duration="300"/>
<mx:TitleWindow id="waitWindow" title="Please wait" width="240" height="70" showCloseButton="false">
<s:Group width="100%" height="100%">
<s:Label top="10" left="10" id="waitLabel" width="220" color="0x000000" />
</s:Group>
</mx:TitleWindow>
</fx:Declarations>

<fx:Style>
@namespace s "library://ns.adobe.com/flex/spark";
@namespace mx "library://ns.adobe.com/flex/mx";

#contentStack{
backgroundColor: #313131;
}

s|Label{
color: #fcfcfc;
}

s|Button{
chromeColor: #636363;
}

mx|ComboBox{
chromeColor: #636363;
color: #fcfcfc;
contentBackgroundColor: #000000;
rollOverColor: #aaaaaa;
selectionColor: #ffffff;
}

#logArea{
contentBackgroundColor: #111111;
focusedTextSelectionColor: #0000ff;
fontFamily: "Courier New";
color: #aaaaaa;
}
</fx:Style>

<fx:Script>
<![CDATA[
import flash.display.Loader;
import flash.events.Event;
import flash.events.FileListEvent;
import flash.events.KeyboardEvent;
import flash.events.TimerEvent;
import flash.filesystem.File;
import flash.net.FileFilter;
import flash.net.URLRequest;
import flash.utils.Timer;
import mx.collections.ArrayCollection;
import mx.effects.easing.Linear;
import mx.controls.Alert;
import mx.events.CloseEvent;
import mx.events.FlexEvent;
import mx.events.StateChangeEvent;
import mx.managers.PopUpManager;

[Bindable]
private var selectedFiles:ArrayCollection = new ArrayCollection([]);
private var totalFiles:int;
private var currentNum:int;
private var totalErrors:int;
private var folderArray:Array = [];

private function init():void {
addEventListener(KeyboardEvent.KEY_DOWN, keybDown);
}

private function keybDown(evt:KeyboardEvent):void {
if (evt.ctrlKey && evt.keyCode == 65) {
var arr:Array = [];
for (var i:int = 0; i < selectedFiles.length; i++) {
arr.push(i);
}
tileList.selectedIndices = arr;
}
}

private function actionChange():void{
switch (actionCombo.selectedIndex) {
case 0:
newWidth.enabled = true;
widthMeasure.enabled = true;
newHeight.enabled = true;
heightMeasure.enabled = true;
break;
case 1:
newWidth.enabled = true;
widthMeasure.enabled = true;
newHeight.enabled = false;
heightMeasure.enabled = false;
break;
case 2:
newWidth.enabled = false;
widthMeasure.enabled = false;
newHeight.enabled = true;
heightMeasure.enabled = true;
break;
case 3:
newWidth.enabled = true;
widthMeasure.enabled = false;
newHeight.enabled = true;
heightMeasure.enabled = false;
widthMeasure.selectedIndex = 1;
heightMeasure.selectedIndex = 1;
}
}

private function addFiles():void {
var file:File = new File();
file.browseForOpenMultiple("Select JPG or PNG files", [new FileFilter("Pictures", "*.jpg;*.jpeg;*.png")]);
file.addEventListener(FileListEvent.SELECT_MULTIPLE, filesSelected);
}

private function filesSelected(evt:FileListEvent):void {
PopUpManager.addPopUp(waitWindow, this);
PopUpManager.centerPopUp(waitWindow);
waitLabel.text = "Selecting files...";
var timer:Timer = new Timer(100, 1);
timer.addEventListener(TimerEvent.TIMER_COMPLETE, onWait);
timer.start();
function onWait(ev:TimerEvent):void {
doFiles(evt.files);
PopUpManager.removePopUp(waitWindow);
}
}

private function addFolder():void {
var file:File = new File();
file.browseForDirectory("Select a directory");
file.addEventListener(Event.SELECT, folderSelected);
}

private function folderSelected(evt:Event):void {
var file:File = evt.currentTarget as File;
Alert.show("Do you want to select subfolders too?", "Recursive selection?", Alert.YES | Alert.NO, null, warningClose);

function warningClose(ev:CloseEvent):void {
if (ev.detail == Alert.YES) {
startFolder(file, true);
}
if (ev.detail == Alert.NO) {
startFolder(file, false);
}
}
}

private function startFolder(file:File, recurs:Boolean):void {
PopUpManager.addPopUp(waitWindow, this);
PopUpManager.centerPopUp(waitWindow);
waitLabel.text = "Selecting folders...";
var timer:Timer = new Timer(100, 1);
timer.addEventListener(TimerEvent.TIMER_COMPLETE, onWait);
timer.start();
function onWait(ev:TimerEvent):void {
doFolder(file, recurs);
PopUpManager.removePopUp(waitWindow);
}
}

private function doFiles(files:Array):void {
for (var i:int = 0; i < files.length; i++) {
var alreadySelected:Boolean = false;
for (var u:int = 0; u < selectedFiles.length; u++) {
if (selectedFiles[u].type == 0 && selectedFiles[u].path == files[i].nativePath) {
alreadySelected = true;
}
}
if (!alreadySelected) selectedFiles.addItem({type:0, path:files[i].nativePath});
}
updateTotalFiles();
}

private function doFolder(file:File, isRecursive:Boolean):void {
var picturesInFolder:int = 0;
var childFiles:Array = file.getDirectoryListing();
for (var i:int = 0; i < childFiles.length; i++) {
if (childFiles[i].extension == "png" || childFiles[i].extension == "jpg" || childFiles[i].extension == "jpeg") {
picturesInFolder++;
}
if (childFiles[i].isDirectory && isRecursive) {
doFolder(childFiles[i], true);
}
}
if (picturesInFolder > 0) {
var alreadySelected:Boolean = false;
for (var a:int = 0; a < selectedFiles.length; a++) {
if (selectedFiles[a].type == 1 && selectedFiles[a].path == file.nativePath) {
alreadySelected = true;
}
}
if (!alreadySelected) selectedFiles.addItem( { type:1, path:file.nativePath, name:file.name, num:picturesInFolder } );
updateTotalFiles();
}
}

private function updateTotalFiles():void {
totalFiles = 0;
for (var i:int = 0; i < selectedFiles.length; i++) {
if (selectedFiles[i].type==1) {
totalFiles += selectedFiles[i].num;
}else {
totalFiles++;
}
}
labelSelected.text = totalFiles + " files selected";
}

private function removeSelected():void {
while (tileList.selectedItems.length > 0) {
selectedFiles.removeItemAt(tileList.selectedIndices[0]);
}
updateTotalFiles();
}

private function beginResize():void {
var canProceed:Boolean = true;
if (selectedFiles.length == 0) {
canProceed = false;
Alert.show("No files or folders are selected.", "Cant start resizing!");
}
if (nameInput.text.indexOf(%initialName%) < 0 && nameInput.text.indexOf(%num%) < 0) {
canProceed = false;
Alert.show("No wildcards were used in the name field! They are essential for each output file to have an unique name.", "Cant start resizing!");
}
var testName:String = nameInput.text.replace("%initialName%", "");
testName = testName.replace("%num%", "");
if(testName.indexOf(/)>=0 || testName.indexOf("\")>=0 || testName.indexOf(?)>=0 || testName.indexOf(%)>=0 ||
testName.indexOf(*)>=0 || testName.indexOf(:)>=0 || testName.indexOf(|)>=0 || testName.indexOf(")>=0 ||
testName.indexOf(<) >= 0 || testName.indexOf(>) >= 0 || testName.indexOf(.) >= 0) {
canProceed = false;
Alert.show("Illegal characters in the name field! Make sure file name field does not contain these characters: / ? % * : | " < > . ", "Cant start resizing!");
}
if (canProceed) {
contentStack.selectedIndex = 3;
var timer:Timer = new Timer(400, 1);
timer.addEventListener(TimerEvent.TIMER_COMPLETE, onTimer);
timer.start();
function onTimer(evt:TimerEvent):void {
buttonError.enabled = false;
buttonReturn.enabled = false;
logArea.text = "";
logArea.appendText("Beginning resizing of " + totalFiles + " files...
");
currentNum = 0;
totalErrors = 0;
progressBar.setProgress(0, totalFiles);
nextAction();
}
}
}

private function resizeNext(isFolder:Boolean):void {
var file:File;
var canProceed:Boolean = true;
var loader:Loader;
var currentProgress:int = progressBar.value + 1;
progressBar.setProgress(currentProgress, totalFiles);

// if its a file
if (!isFolder){
currentNum++;
file = new File(selectedFiles[currentNum - 1].path);
}

// if its a folder
if (isFolder) {
file = folderArray.pop();
if (folderArray.length == 0) currentNum++;
}

logArea.appendText("#" + currentProgress + " (" + file.name + ")
");

// Error: file not found
if (!file.exists) {
canProceed = false;
logArea.appendText("ERROR: File not found
");
totalErrors++;
nextAction();
}


// Error: bad extension
if (file.exists && file.extension.toLowerCase() != "png" && file.extension.toLowerCase() != "jpg" && file.extension.toLowerCase() != "jpeg") {
canProceed = false;
logArea.appendText("ERROR: Incorrect extension
");
totalErrors++;
nextAction();
}

// load image
if (canProceed) {
loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoadComplete);
loader.load(new URLRequest(file.url));
}

// start timer
function onLoadComplete(evt:Event):void {
var timer:Timer = new Timer(500, 1);
timer.addEventListener(TimerEvent.TIMER_COMPLETE, onTimer);
timer.start();
}

function onTimer(evt:TimerEvent):void {
// new name
var newName:String = nameInput.text.replace("%initialName%", file.name.substr(0, file.name.lastIndexOf(.)));
newName = newName.replace("%num%", currentNum);

// new extension
var newExtension:String;
if (formatCombo.selectedIndex == 0) newExtension = file.extension;
if (formatCombo.selectedIndex == 1) newExtension = "jpg";
if (formatCombo.selectedIndex == 2) newExtension = "png";

// new size
var currentW:int = loader.content.width;
var currentH:int = loader.content.height;
var newW:int;
var newH:int;
var ratio:Number;

if (actionCombo.selectedIndex == 0) {
if (widthMeasure.selectedIndex == 0) newW = newWidth.value/100 * currentW;
if (widthMeasure.selectedIndex == 1) newW = newWidth.value;
if (heightMeasure.selectedIndex == 0) newH = newHeight.value/100 * currentH;
if (heightMeasure.selectedIndex == 1) newH = newHeight.value;
}

if (actionCombo.selectedIndex == 1) {
ratio = currentW / currentH;
if (widthMeasure.selectedIndex == 0) newW = newWidth.value/100 * currentW;
if (widthMeasure.selectedIndex == 1) newW = newWidth.value;
newH = newW / ratio;
}

if (actionCombo.selectedIndex == 2) {
ratio = currentW / currentH;
if (heightMeasure.selectedIndex == 0) newH = newHeight.value/100 * currentH;
if (heightMeasure.selectedIndex == 1) newH = newHeight.value;
newW = newH * ratio;
}

if (actionCombo.selectedIndex == 3) {
ratio = currentW / currentH;
newW = newWidth.value;
newH = newW / ratio;
if (newH > newHeight.value) {
newH = newHeight.value;
newW = ratio * newH;
}
}

// log
logArea.appendText("Resized from " + currentW + "x" + currentH + " to " + newW + "x" + newH + "
");
logArea.appendText("Renamed to " + newName + "." + newExtension + "
");

nextAction();
}

}

private function nextAction():void {
if (currentNum < selectedFiles.length) {
var isFolder:Boolean = false;
// if its a folder, create a global array that stores all image files of the folder
if (folderArray.length > 0) isFolder = true;
if (selectedFiles.length > currentNum && selectedFiles[currentNum].type == 1 && folderArray.length == 0) {
isFolder = true;
folderArray = [];
var folder:File = new File(selectedFiles[currentNum].path);
var allContent:Array = folder.getDirectoryListing();
for (var i:int = 0; i < allContent.length; i++) {
if (allContent[i].isDirectory == false && (allContent[i].extension.toLowerCase() == "png" || allContent[i].extension.toLowerCase() == "jpg" || allContent[i].extension.toLowerCase() == "jpeg")) {
folderArray.push(allContent[i]);
}
}
}
resizeNext(isFolder);
}else {
logArea.appendText("Operation complete!");
buttonError.enabled = true;
buttonReturn.enabled = true;
}
}
]]>
</fx:Script>

<mx:ViewStack id="contentStack" width="100%" height="100%" >
<s:NavigatorContent width="100%" height="100%" hideEffect="fadeOut" showEffect="fadeIn">
<s:VGroup width="100%" height="100%" paddingLeft="10" paddingTop="10" paddingRight="10" paddingBottom="10">
<s:Label id="labelSelected">0 files selected</s:Label>
<mx:TileList id="tileList" width="282" height="100%" dataProvider="{selectedFiles}" itemRenderer="TileRenderer" columnWidth="60" rowHeight="60" columnCount="4" allowMultipleSelection="true" selectionColor="0xff0000" rollOverColor="0xff8888" />
<s:Button label="Add folder" width="100%" click="addFolder();" />
<s:Button label="Add files" width="100%" click="addFiles();" />
<s:Button label="{Remove + tileList.selectedItems.length + items}" width="100%" enabled="{tileList.selectedItems.length>0}" click="removeSelected();" />
<s:Button label="Continue" width="100%" click="contentStack.selectedIndex = 1;" />
</s:VGroup>
</s:NavigatorContent>
<s:NavigatorContent width="100%" height="100%" hideEffect="fadeOut" showEffect="fadeIn">
<s:VGroup width="100%" height="100%" paddingLeft="10" paddingTop="10" paddingRight="10" paddingBottom="10">
<s:Button label="Return to file selection" width="100%" click="contentStack.selectedIndex = 0;" />

<s:Label>Resize options:</s:Label>

<mx:ComboBox width="100%" id="actionCombo" height="22" dataProvider="{actions}" selectedIndex="0" editable="false" change="actionChange();"
openEasingFunction="Linear.easeOut" closeEasingFunction="Linear.easeIn" openDuration="300" closeDuration="300"/>
<s:HGroup verticalAlign="middle">
<s:Label width="50">Width:</s:Label>
<s:NumericStepper id="newWidth" height="22" width="150" minimum="1" value="100" maximum="{(widthMeasure.selectedIndex==0)?(100):(4000)}" />
<mx:ComboBox id="widthMeasure" height="22" width="50" dataProvider="{measures}" selectedIndex="0" editable="false"
openEasingFunction="Linear.easeOut" closeEasingFunction="Linear.easeIn" openDuration="300" closeDuration="300"/>
</s:HGroup>

<s:HGroup verticalAlign="middle">
<s:Label width="50">Height:</s:Label>
<s:NumericStepper id="newHeight" height="22" width="150" minimum="1" value="100" maximum="{(heightMeasure.selectedIndex==0)?(100):(4000)}"/>
<mx:ComboBox id="heightMeasure" height="22" width="50" dataProvider="{measures}" selectedIndex="0" editable="false"
openEasingFunction="Linear.easeOut" closeEasingFunction="Linear.easeIn" openDuration="300" closeDuration="300"/>
</s:HGroup>

<s:Label/>

<s:Label>Output file names:</s:Label>
<s:HGroup verticalAlign="middle">
<s:TextInput id="nameInput" width="240" text="%initialName%" />
<s:Button width="35" label="?" click="contentStack.selectedIndex = 2;" />
</s:HGroup>

<s:Label/>

<s:Label>Output destination:</s:Label>
<s:HGroup verticalAlign="middle">
<s:RadioButton id="oldDestination" label="Same directory" groupName="destinationGroup" selected="true" />
<s:RadioButton id="newDestination" label="Specified directory" groupName="destinationGroup" />
</s:HGroup>
<s:HGroup verticalAlign="middle" width="100%">
<s:TextInput width="100%" enabled="{newDestination.selected}" text="Select destination..." editable="false" />
<s:Button width="80" label="Browse" enabled="{newDestination.selected}"/>
</s:HGroup>

<s:Label/>

<s:Label>Output format:</s:Label>
<mx:ComboBox width="100%" height="22" id="formatCombo" dataProvider="{formats}" selectedIndex="0" editable="false"
openEasingFunction="Linear.easeOut" closeEasingFunction="Linear.easeIn" openDuration="300" closeDuration="300"/>

<s:Label/>

<s:Label>Output JPG quality:</s:Label>
<s:HSlider width="100%" minimum="1" maximum="100" value="100" />

<s:Label/>

<s:Button label="Resize" width="100%" click="beginResize();" />
</s:VGroup>
</s:NavigatorContent>
<s:NavigatorContent width="100%" height="100%" hideEffect="fadeOut" showEffect="fadeIn">
<s:VGroup width="280" top="10" left="10">
<s:VGroup width="100%" height="410" gap="20">
<s:Label fontSize="20" width="100%" fontWeight="bold">Output file names</s:Label>
<s:Label width="100%">You can build names for output files using provided wildcards and combining them with text.</s:Label>
<s:Label width="100%">For example, "%initialName%_new" will generate names like "pic_new.jpg", "img_new.png", etc.</s:Label>
<s:Label width="100%">Available wildcards are:</s:Label>
<s:Label fontSize="18" width="100%" fontWeight="bold">%initialName%</s:Label>
<s:Label width="100%">Puts the initial name of the file thats being resized.</s:Label>
<s:Label fontSize="18" width="100%" fontWeight="bold">%num%</s:Label>
<s:Label width="100%">Gives each file a unique id number starting from 1.</s:Label>
</s:VGroup>
<s:Button label="Back" width="100%" click="contentStack.selectedIndex = 1;" />
</s:VGroup>
</s:NavigatorContent>
<s:NavigatorContent width="100%" height="100%" hideEffect="fadeOut" showEffect="fadeIn">
<s:VGroup width="280" height="440" top="10" left="10">
<s:Label width="100%" color="0xff3333" fontWeight="bold">Do not add, remove or rename selected files.</s:Label>
<mx:ProgressBar id="progressBar" width="100%" mode="manual" label="Resizing %1/%2" color="0xffffff" />
<s:TextArea id="logArea" editable="false" width="100%" height="100%" />
<s:HGroup>
<s:Button id="buttonError" label="Save error log" width="136" />
<s:Button id="buttonReturn" label="Return" click="contentStack.selectedIndex = 0;" width="136" />
</s:HGroup>
</s:VGroup>
</s:NavigatorContent>
</mx:ViewStack>
</s:WindowedApplication>

Thanks for reading!
Read more »