#import <Foundation/Foundation.h>

@interface RemotePreferences : NSObject {
NSMutableData *incomingData;
}

@end

@implementation RemotePreferences

-(id)init {

self = [super init];

if (self) {

NSURL *url = [NSURL URLWithString: @"http://example.com/configs.plist"];
NSURLRequest *request = [NSURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:30.0];
__unused NSURLConnection *fetchConn = [[[NSURLConnection alloc] initWithRequest:request delegate:self] autorelease];

}

return self;

}

- (void)connection:(NSURLConnection *)sender didReceiveData:(NSData *)data {

if (!incomingData) {
incomingData = [[NSMutableData alloc] init];
}

[incomingData appendData:data];

}

- (void)connectionDidFinishLoading:(NSURLConnection *)sender {

NSDictionary *prefsDict = [[[NSDictionary alloc] init] autorelease];
prefsDict = [NSPropertyListSerialization propertyListFromData:incomingData mutabilityOption:NSPropertyListImmutable format:nil errorDescription:nil];

[[NSUserDefaults standardUserDefaults] registerDefaults:prefsDict];

// NSLog(@"NSUserDefaults dump: %@", [[NSUserDefaults standardUserDefaults] dictionaryRepresentation]);

}

- (void)connection:(NSURLConnection *)sender didFailWithError:(NSError *)error {
NSLog(@"connection failed: %@", [error localizedDescription]);
}

-(void)dealloc {
FuncLog();

[super dealloc];

[incomingData release];
incomingData = nil;

}

//- (NSURLRequest *)connection:(NSURLConnection *)c willSendRequest:(NSURLRequest *)req redirectResponse:(NSURLResponse *)res {}
//- (void)connection:(NSURLConnection *)sender didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)ch {}
//- (NSCachedURLResponse *)connection:(NSURLConnection *)sender willCacheResponse:(NSCachedURLResponse *)cachedResponse{}

@end

Credit where credit is due, originally found here:
http://www.rblab.com/blog/2009/07/as3-snippet-convert-seconds-to-wwddhhmmss/

function convertTime(number:Number):String
{
number = Math.abs(number);
var values:Array = new Array(5);
values[0] = Math.floor(number / 86400 / 7);// weeks
values[1] = Math.floor(number / 86400 % 7);// days
values[2] = Math.floor(number / 3600 % 24);// hours
values[3] = Math.floor(number / 60 % 60);// mins
values[4] = Math.floor(number % 60);// secs

var stopage:Boolean = false;
var cutIndex:Number = -1;

for (var i:Number = 0; i < values.length; i++)
{
if (values[i] < 10)
{
values[i] = "0" + values[i];
}
if (values[i] == "00" && i < (values.length - 2) && !stopage)
{
cutIndex = i;
}
else
{
stopage = true;
}
}
values.splice(0, cutIndex + 1);

return values.join(":");
}

<script src=”assets/js/swfobject.js”></script>
<script type=”text/javascript”>

$(window).load(function(){

var seednum = 10000000;
var unique = “?q=” + Math.round(Math.random() * 1337 * seednum);
var swfFilePath = “index.swf” + unique;

var so = new SWFObject(swfFilePath,”cfm”,”100%”,”100%”,”9″,”#fff”);
so.addParam(“wmode”,”opaque”);
so.addParam(“scale”,”noscale”);
so.addParam(‘allowScriptAccess’,'always’);
so.write(“cfm”);

});

</script>

<div id=”cfm”>Flash goes here</div>

public class Main extends Sprite {

private static var _instance:Main;
public static function get instance():Main { return _instance; }

public function Main() {
_instance = this;
// etc...
}

// etc...
}

Then you access the Main instance like this:

public class Other {
public function Other() {
Main.instance.usefulInstanceMethod();
}
}

original source:

http://stackoverflow.com/questions/370222/accessing-the-document-class-in-as3

syntax: glob

###
.DS_Store
*.mp4
*.mov

# Backup files left behind by the Emacs editor.
*~

# Lock files used by the Emacs editor.
.\#*

# Temporary files used by the vim editor.
.*.swp

# Temporary files used by TestMate
._*

# build directories
**/build/*
build/*

# tmp directory
**/tmp/*
tmp/*

# XCode user data
**.pbxuser
**.mode?v?
**.perspectivev?

# documentation
**.docset/*

# for those crazies using svn and hg at the same time
*.svn*

# switch to regexp syntax.
syntax: regexp
.git/

self.tabBarController.selectedIndex = 3;
[self.tabBarController.selectedViewController viewDidAppear:YES];

if inside a custom tabbarcontroller doing this

//call viewWillDisappear in the current view
[self.selectedViewController viewWillDisappear:YES];

//change view
self.selectedIndex = tabID;

//call viewDidAppear in the current view
[self.selectedViewController viewDidAppear:YES];

DO NOT use on live/production site.

ob_start();
var_dump($something_anything);
$yourResultingString = ob_get_clean();

Was not written to be used on a real timestamp, was written to be used counting up from 0.

int tmp = secondCount;

int _Days = tmp / (60 * 60 * 24);
tmp -= _Days * (60 * 60 * 24);
int _Hrs = tmp / (60 * 60);
tmp -= _Hrs * (60 * 60);
int _Min = tmp / 60;
tmp -= _Min * 60;
int _Sec = tmp;

NSString *displayString = [NSString stringWithFormat:@"%02i:%02i:%02i:%02i", _Days, _Hrs, _Min, _Sec];

-(void)callJavascriptFunctionInAllWebViews {

if ([[scrollView subviews] count] > 0) {

for (UIWebView *subWebView in [scrollView subviews]) {
NSString *jsCommand = [NSString stringWithFormat:@"whateverJSFunction();"];
[subWebView stringByEvaluatingJavaScriptFromString:jsCommand];
}

}

}

in where-ever.h
extern const CGRect kMY_RECT;

in where-ever.m
const CGRect kMY_RECT = { { 0.0f, 39.0f }, { 768.0f, 432.0f } };

use
somethingWithA.frame = kMY_RECT;

© 2012 James Border Suffusion theme by Sayontan Sinha