forked from: Chapter 8 Example 3
forked from Chapter 8 Example 3 (diff: 1)
ActionScript3 source code
/**
* Copyright onedayitwillmake ( http://wonderfl.net/user/onedayitwillmake )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/oxBA
*/
// forked from actionscriptbible's Chapter 8 Example 3
package {
import com.actionscriptbible.Example;
public class ch8ex3 extends Example {
public function ch8ex3() {
//a Pez dispenser (stack)
var pez:Array = new Array();
pez.push("cherry");
pez.push("orange");
pez.push("lemon");
pez.push("grape");
trace(pez); //cherry,orange,lemon,grape
var candy:String = pez.pop();
trace(candy); //grape
trace(pez); //cherry,orange,lemon
//a queue for movie tickets somewhere in Manhattan (queue)
var queue:Array = new Array();
queue.push("Anja");
queue.push("James");
queue.push("Will");
trace(queue); //Anja,James,Will
var person:String = String(queue.shift());
trace(person); //Anja
trace(queue); //James,Will
//this operation does not quite follow "first in, first out"
queue.unshift("Cheater");
trace(queue); //Cheater,James,Will
}
}
}
