rss twitter

Redefining the ENTER-key in textfields

This one’s showing how to redefine the ENTER-key in textfields to prevent it from breaking lines.

Read more »

The constructor returns a value!?

Actionscript:
  1. public function create(templateID:int):* {
  2.     return new Template(templateID).get;
  3. }

Read more »

Check, if value exists in Array

This article shows how you can easily check if a specific value already exists in an Array in Actionscript 3.

Actionscript:

Actionscript:
  1. var doesExist:Boolean;
  2. var rndInt:int;
  3. var rndArr:Array = new Array();
  4.  
  5. var timer:Timer = new Timer(200, 15);
  6.     timer.addEventListener(TimerEvent.TIMER, fillArray);
  7.     timer.start();
  8.  
  9. function fillArray(event:TimerEvent):void {
  10.     rndInt = Math.floor(Math.random() * 15);
  11.     doesExist = rndArr.every(checkExisting);
  12.     doesExist ? rndArr.push(rndInt) : fillArray(null);
  13.     trace(rndArr);
  14. }
  15.  
  16. function checkExisting(element:*, index:int, arr:Array):Boolean {
  17.     return (element != rndInt);
  18. }

IF statement shortform

Actionscript:

Actionscript:
  1. if(_scrollable) {
  2.    _maskwidth = _positions.width - _spacer;
  3. } else {
  4.    _maskwidth = _positions.width;
  5. }

Actionscript:

Actionscript:
  1. _maskwidth = _scrollable ? _positions.width - _spacer : _positions.width;

Powered by WordPress | Free T-Mobile Phones for Sale | Thanks to Palm Pre Blog, Video Game Music and Get Six Pack Abs