iPad UIImageView image-based animation alternative

I’ve been troubleshooting a project that animates 24 different sets of png images. Each set containing around 30 images. The App would eventually crash when run on an iPad after running through about half a dozen of the animations. Eventually running into a memory limit. In my search for solutions, I ran into Mo DeJong’s PNGAnimatorDemo, which completely solved the memory limit problem.

The example project he provides runs the animation full frame by default so I had to modify some things in order to add it as a subview to another view and to set it inside a CGRect.

The first thing to be done was to create a new property ‘viewCGRect’ with which I could set a CGRect for the ImageAnimatorViewController . I also took out the animationOrientation property and associated code since this is now being added as a subVIew to another view.

- (void)loadView { 
// UIView *myView = [[UIView alloc] initWithFrame:[UIScreen mainScreen].applicationFrame]; 
UIView *myView = [[UIView alloc] initWithFrame:viewCGRect]; 
myView autorelease]; 
self.view = myView; 

// FIXME: Additional Supported Orientations 
if (animationOrientation == UIImageOrientationUp) { 
    // No-op 
} else if (animationOrientation == UIImageOrientationLeft) { 
    // 90 deg CCW [self rotateToLandscape]; 
} else if (animationOrientation == UIImageOrientationRight) { 
    // 90 deg CW [self rotateToLandscapeRight]; 
} else { 
    NSAssert(FALSE,@"Unsupported animationOrientation"); 
}

Then inside my superViewController I modified the startAnimator method in order to pass a different file name prefix for every animation. As well as a specific length (each animation had varying lengths) and a CGRect with which to draw the animation.

- (void) startAnimator:(NSString *) pref endingWith: (int) end andFrame:(CGRect) rect { 
//[viewController.view removeFromSuperview]; 

self.animatorViewController = [ImageAnimatorViewController imageAnimatorViewController]; 

NSArray *names = [ImageAnimatorViewController arrayWithNumberedNames:pref 
rangeStart:1 
rangeEnd:end 
suffixFormat:@"%02i.png"]; 

NSArray *URLs = [ImageAnimatorViewController arrayWithResourcePrefixedURLs:names]; 

// setting the public property for our custom CGRect: 

animatorViewController.viewCGRect = rect; 

// we no longer need to provide an orientation //animatorViewController.animationOrientation = UIImageOrientationUp; // Rotate 90 deg CCW 
animatorViewController.animationFrameDuration = ImageAnimator15FPS; 
animatorViewController.animationURLs = URLs; 
animatorViewController.animationRepeatCount = 0; 

// Show animator before starting animation 

// add the animatorViewController.view as a subView: 
[self.view addSubview:animatorViewController.view]; 

[[NSNotificationCenter defaultCenter] addObserver:self 
selector:@selector(animationDidStartNotification:) 
name:ImageAnimatorDidStartNotification 
object:animatorViewController]; 

[[NSNotificationCenter defaultCenter] addObserver:self 
selector:@selector(animationDidStopNotification:) 
name:ImageAnimatorDidStopNotification 
object:animatorViewController]; 

[animatorViewController startAnimating]; }
Then lastly I commented out parts of the stopAnimator method so that the final frame of each animation would remain until I needed to dispose of it by using another method clearAnimation. 

- (void) stopAnimator { 
    [[NSNotificationCenter defaultCenter] removeObserver:self name:ImageAnimatorDidStartNotification object:animatorViewController]; 
    [[NSNotificationCenter defaultCenter] removeObserver:self name:ImageAnimatorDidStopNotification object:animatorViewController]; 
    [animatorViewController stopAnimating]; 
    [animatorViewController.view removeFromSuperview]; 
    self.animatorViewController = nil; 
} 

- (void) clearAnimation { 
    [animatorViewController.view removeFromSuperview]; self.animatorViewController = nil; 
}

 

Flash Builder/Flex 4 and ZendAMF alternative connection example

I was attempting to try out a simple test of ZendAMF and Flash Builder. I had begun by building the test using WAMP on my local machine. I began by using the built in Connect to Data/Service Wizard built into Flash Builder.  The example I was following was from an article over at the Zend Developer Zone called: Data-centric Adobe Flash Builder development with the Zend Framework. Everything worked slick as can be running locally on WAMP but when I tried using the same data connection with my site on my hosting company, I was ending up with errors due to the age of mySQL and PHP that my host is currently using. I am still working on resolving those problems. But in the meantime I was needing to get it to work.  I decided to incorporate the simple example Lee Brimelow used with his Flash and Zend AMF tutorial.

The example here is a simple voting screen to pick from a set of actors for best actor and worst actor. It holds a simple SharedObject variable to determine if you have already voted and keeps you from voting twice.

 

Here is the awards.php file:

class awards {
public function __construct()
{
require("/*path to file outside of public web directory*/configConn.inc.php");
mysql_connect($server,$username,$password);
mysql_select_db("/*my database*/" );
}
public function getPeople()
{
$result = mysql_query("SELECT * FROM awards");
$t = array();

while($row = mysql_fetch_assoc($result))
{
array_push($t, $row);
}

return $t;

}

public function add( $bestActor, $worstActor ) {

$insert = sprintf( "INSERT INTO awards VALUES (NULL, '%s', '%s')",
mysql_real_escape_string($bestActor),
mysql_real_escape_string($worstActor));

mysql_query($insert);

return 'You addded: ' . $bestActor . $worstActor . '. The Query string is: ' . $insert;
}
}

 

 

Here is the configConn.inc.php:

And finally here is the bootstrapper.php file:
[cc lang="php"]
?php

error_reporting(E_ALL | E_STRICT);
ini_set("display_errors", "on");

ini_set("include_path", ini_get("include_path") . ":'/*my path to Zend*/");

require_once Zend/Amf/Server.php';
require_once 'awards.php';

$server = new Zend_Amf_Server();

$server->setClass("awards");
// You can keep adding all the classes you need here

echo($server->handle());

?>

 

P.S. I apologize in advance for any typos due to attempting to make the code more generic.

Paceart System software simulation

Back in May of ’09, I completed the Paceart System Scheduling interactive tutorial for Medtronic it is an interactive software simulation with over one hour of narration. It was built in Flash CS3 using AS3. The entire simulator builds itself with an XML sheet. The callout text, the MP3’s and the seperate SWF’s are all called by the XML file. Here are some screen shots: