Chapter 8 Example 3
♥0 |
Line 26 |
Modified 2009-06-12 03:28:31 |
MIT License
archived:2017-03-10 21:37:13
ActionScript3 source code
/**
* Copyright actionscriptbible ( http://wonderfl.net/user/actionscriptbible )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/f1OE
*/
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
}
}
}