This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.playflock.game.screens.mainScreen.panels.monster | |
{ | |
import flash.display.Bitmap; | |
import flash.display.DisplayObject; | |
import flash.display.Sprite; | |
/** | |
* При установки скэйлов всегда центрирует содержащий в себе спрайт | |
*/ | |
public class CenterPivotSprite extends Sprite |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.temp | |
{ | |
import flash.display.DisplayObject; | |
import flash.display.Sprite; | |
import flash.events.MouseEvent; | |
import flash.geom.Rectangle; | |
public class ScrollView extends Sprite implements IBaseResizable |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static function onAddedToStage(target:DisplayObject, callback:Function):void | |
{ | |
if (target.stage) | |
{ | |
onAdded(); | |
} | |
else | |
{ | |
target.addEventListener(Event.ADDED_TO_STAGE, onAddedToStage); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//AS3 тоже полон неоднозначностей | |
_parentWindow.header.height + _parentWindow.padding + _parentWindow.gap/2; | |
//Кто бы мог подумать, что padding это Point. И вместо того, чтобы ругнутья - он преобразуется в NaN |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//How faster get class of an object in as3? | |
[trace] TIMER one: Time passed: 226 | |
[trace] TIMER two: Time passed: 1224 | |
[trace] TIMER three: Time passed: 104 | |
[inline] | |
public static function getClass1(obj:Object):Class { | |
return obj.constructor; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 1) Одинаковые ли по логике эти два варианта? | |
* 2) Какой из этих вариантов читабельнее? | |
* 3) Если потребуется сделать проверку еще на один source (SOURCE_ALWAYS_OVERWRITE), какой вариант легче будет модифицировать? | |
* 4) Можно ли переписать этот код более читабелнее/универсальнее? | |
*/ | |
//вариант 1 | |
if (source == SOURCE_ALWAYS_OVERWRITE) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
times = function(n, iterator) { | |
var accum = Array(Math.max(0, n)); | |
for (var i = 0; i < n; i++) accum[i] = iterator.call(); | |
return accum; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Рекурсивно обходит детей у MovieClip и ищет все содержащиеся в нем MovieClip. | |
* Среди них ищет максимальное значение totalFrames | |
* @param container - MovieClip | |
* @return maxFrames - максимальное значение totalFrames | |
*/ | |
public static function getTotalFrames(container:DisplayObjectContainer):int | |
{ | |
var maxFrames:int = 0; | |
if (container.numChildren == 0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function getItemByLevel(levelID:int):LevelLibItem | |
{ | |
var item:LevelLibItem; | |
//Если это зафоршенный уровень - сразу возвращаем | |
item = _forcedLevels[levelID]; | |
if (item != null) | |
{ | |
return item; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |