Skip to content

Instantly share code, notes, and snippets.

View esidegallery's full-sized avatar

Timothy John esidegallery

  • e side gallery
  • Swansea, UK
View GitHub Profile
@esidegallery
esidegallery / NativeDragSource.as
Last active December 6, 2021 16:15
A Feathers drag source for native drag events. The DragData object is populated with the same formats and data as the native drag's Clipboard object. The IDropTarget instances can check the format and data of dragEnter event, and if it's an accepted native format, should call DragDropManager.acceptDrag() and set NativeDragManager.dropAction.
package feathers.utils
{
import feathers.dragDrop.DragData;
import feathers.dragDrop.DragDropManager;
import feathers.dragDrop.IDragSource;
import flash.desktop.Clipboard;
import flash.desktop.NativeDragActions;
import flash.desktop.NativeDragManager;
import flash.display.Sprite;
@esidegallery
esidegallery / Timer.as
Last active February 1, 2018 11:41
Starling Timer
package starling.extensions
{
import starling.animation.DelayedCall;
import starling.animation.Juggler;
import starling.core.Starling;
import starling.events.EventDispatcher;
[Event(name="timer", type="starling.events.Event")]
[Event(name="timerComplete", type="starling.events.Event")]
public class Timer extends EventDispatcher
@esidegallery
esidegallery / StarlingCallLater.as
Last active October 19, 2017 17:40
StarlingCallLater
package starling.extensions.starlingCallLater
{
import starling.core.Starling;
import starling.display.Stage;
import starling.events.Event;
public class StarlingCallLater
{
/**
* 2D Array of vectors containing FunctionReference instances.
@esidegallery
esidegallery / ExtendedImageLoader.as
Created June 26, 2017 10:22
Adds texturePreferredWidth and texturePreferredHeight properties to feathers.controls.ImageLoader so that PoT textures can work with all scaleMode and maintainAspectRatio values.
package feathers.controls
{
import flash.geom.Rectangle;
import feathers.layout.HorizontalAlign;
import feathers.layout.VerticalAlign;
import starling.display.Quad;
import starling.utils.RectangleUtil;
import starling.utils.ScaleMode;
@esidegallery
esidegallery / ExtendedListItemRenderer.as
Last active June 26, 2017 10:40
Adds an iconProperties function to DefaultListItemRenderer, which returns an object of properties to be applied to the ImageLoader created by iconLoaderFactory. The function is expected to have the following signature: function(item:Object):Object
package feathers.controls.renderers
{
import starling.display.DisplayObject;
public class ExtendedListItemRenderer extends DefaultListItemRenderer
{
private var _iconPropertiesFunction:Function;
public function get iconPropertiesFunction():Function
{
return _iconPropertiesFunction;
@esidegallery
esidegallery / VideoTextureImageLoader.as
Last active June 8, 2022 13:06
Feathers (Starling) ImageLoader designed to display a video texture whose coded height is different from its display height.
package feathers.controls
{
import feathers.layout.HorizontalAlign;
import feathers.layout.VerticalAlign;
import flash.display.BitmapData;
import flash.display3D.textures.VideoTexture;
import flash.geom.Point;
import flash.geom.Rectangle;
@esidegallery
esidegallery / gist:9e25b12bbfb5dcdeb3fdf4e9be2802b6
Last active April 13, 2023 15:53
starling.display::DisplayObject.drawToBitmapData() Windows Fix
override public function drawToBitmapData(out:BitmapData = null, color:uint = 0, alpha:Number = 0.0):BitmapData
{
var painter:Painter = Starling.painter;
var stage:Stage = Starling.current.stage;
var viewPort:Rectangle = Starling.current.viewPort;
var stageWidth:Number = stage.stageWidth;
var stageHeight:Number = stage.stageHeight;
var scaleX:Number = viewPort.width / stageWidth;
var scaleY:Number = viewPort.height / stageHeight;
var backBufferScale:Number = painter.backBufferScaleFactor;