Skip to content

Instantly share code, notes, and snippets.

View matt-curtis's full-sized avatar

Matt Curtis matt-curtis

View GitHub Profile
@matt-curtis
matt-curtis / AppSwitcher.as
Created March 26, 2014 13:23
Application Subclass for...switching between application instances...
package
{
import flash.events.Event;
import mx.controls.SWFLoader;
import mx.core.Application;
import mx.managers.SystemManager;
public class AppSwitcher extends Application
{
@matt-curtis
matt-curtis / gist:0ba79643a7412b1dd64a
Last active August 29, 2015 14:07
XPath + Text Nodes
var getNodeTreeXPath = function(node){
// Built from Firebug source -
// https://github.com/firebug/firebug/blob/235efff40332f85cb34b55f2da0de6bf98d083e4/extension/content/firebug/lib/xpath.js
var paths = [], nodePath, element = node;
// If text node find its place among its siblings
if(element.nodeType == Node.TEXT_NODE){
var siblings = node.parentElement.childNodes;
var nodeIndex = Array.prototype.indexOf.call(siblings, node)+1;
@matt-curtis
matt-curtis / Fireworks CSXS Notes.md
Last active August 29, 2015 14:12
Fireworks CSXS Notes

Building CSXS extensions for Fireworks with Adobe Flash Builder 4.x

1.) Fireworks does not have it's own CSWSBlaBlaLib to encapsulate DOM manipulation from AS3. You can only use this to execute JS functions (defined in your CSXS manifest.xml)

CSInterface.instance.evalScript("jsFunctionName", ..params);

This method is even more fun than the MMExecute method you'd be using if you were writing a normal panel, becuase all return objects have to be an XML string. I'm not kidding you. XML. You know, the markup format that is most well known for its use in RSS feeds.

@matt-curtis
matt-curtis / Complete Fireworks Event List.md
Created January 5, 2015 14:50
Complete Fireworks Event List (as of CS6)

Events not mentioned in the official documentation have an asterick beside them.

IsFwCallbackInstalled*
onFwEnterSymbolEdit*
onFwStopMovie
onFwStartMovie
onFwWidgetLibraryChange*
onFwWindowFocusChange*
onFwSystemColorChanged*

onFwDocumentSave

@matt-curtis
matt-curtis / gist:d9b46b59834dc781cd6e
Last active August 29, 2015 14:15
Fireworks Errata, Part 2

Weird $ Variable. On further inspection seems to be a light implemtation of a variable from ExtendScript?? http://jongware.mit.edu/idcs6js/pc_%24.html

$.evalFile(filename:String, timeout:int) // not sure if fw cares about timeout
$.getenv(str:String) // gets enviroment variables...interesting

Fireworks Document

dom.saveAllAsync()
dom.saveDocumentAsync()
dom.saveDocumentAsAsync(doc, saveAsCmd:Boolean)
@matt-curtis
matt-curtis / MCTextFormatConverter.h
Created March 14, 2015 16:22
HTML to Attributed String & Attributed String to HTML
#import <Foundation/Foundation.h>
@interface MCTextFormatConverter : NSObject
+ (NSString*) convertTextInResponderToHTML:(UIView<UITextInput>*)view convertSelectionOnly:(BOOL)convertSelectionOnly;
+ (NSAttributedString*) htmlToAttributedString:(NSString*)html;
@end
@matt-curtis
matt-curtis / NSFetchedResultsController+UICollectionView.m
Last active August 29, 2015 14:24
NSFetchedResultsController & UICollectionView using blocks (Moved Items & Deleted/Inserted Sections Fix)
@interface YourNSFetchedResultsControllerDelegate () <NSFetchedResultsControllerDelegate>
@end
@implementation YourNSFetchedResultsControllerDelegate {
UICollectionView *_collectionView;
NSMutableArray *_collectionViewUpdatesQueue;
@matt-curtis
matt-curtis / Resizer.cocoascript.js
Last active August 29, 2015 14:26
Script for use with the default Sketch iOS App Icon Template. Takes the selected layer and duplicates it to the other artboard sizes.
var original = context.selection.firstObject();
var originalArtboard = original.parentArtboard();
var artboards = context.document.artboards();
var enumerator = artboards.objectEnumerator();
var artboard;
while((artboard = enumerator.nextObject())){
if(artboard.isEqual_(originalArtboard)) continue;
@matt-curtis
matt-curtis / shape-layer-to-marquee.js
Last active December 3, 2015 16:58
(Sketch) Convert a shape layer to a marquee. Select both bitmap and shape layer and run the plugin.
var document = context.document;
// Find first bitmap and shape in selection
var bitmapLayer = document.selectedLayersOfClass(MSBitmapLayer)[0];
if(!bitmapLayer) return;
var shapeLayer = document.selectedLayersOfClass(MSShapeGroup)[0];
@matt-curtis
matt-curtis / gist:5703839
Last active December 18, 2015 01:28
Get all text/html in rectangle or CSS3 Column
var getAllTextInColumn = function(rect){
/*
rect should be the size and x,y of the column
*/
if(document.caretPositionFromPoint){
var caretRangeStart = document.caretPositionFromPoint(rect.left, rect.top);
var caretRangeEnd = document.caretPositionFromPoint(rect.left+rect.width-1, rect.top+rect.height-1);
} else if(document.caretRangeFromPoint){
var caretRangeStart = document.caretRangeFromPoint(rect.left, rect.top);