<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>absent design &#124; useful simple software &#187; tutorials</title>
	<atom:link href="http://blog.absentdesign.com/category/tutorials/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.absentdesign.com</link>
	<description>useful simple software</description>
	<lastBuildDate>Thu, 02 Feb 2012 02:54:59 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.4</generator>
		<item>
		<title>An ActionScript developer with EXC_BAD_ACCESS? Just check your strings&#8230;</title>
		<link>http://blog.absentdesign.com/2010/10/an-actionscript-developer-with-exec_bad_access-first-just-check-your-strings/</link>
		<comments>http://blog.absentdesign.com/2010/10/an-actionscript-developer-with-exec_bad_access-first-just-check-your-strings/#comments</comments>
		<pubDate>Fri, 01 Oct 2010 05:33:19 +0000</pubDate>
		<dc:creator>Reuben</dc:creator>
				<category><![CDATA[objective-c]]></category>
		<category><![CDATA[tutorials]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[crash]]></category>
		<category><![CDATA[exec_bad_access]]></category>
		<category><![CDATA[memory management]]></category>

		<guid isPermaLink="false">http://blog.absentdesign.com/?p=313</guid>
		<description><![CDATA[Because ActionScript is an ECMA based language, strings are declared a literals using quotes: var string = "This is an ECMA string"; var anotherString = 'So is this'; Objective-C on the other hand, uses the class NSString for string access, and you declare a constant string using a convenience method by putting an @ in [...]]]></description>
			<content:encoded><![CDATA[<p>Because ActionScript is an ECMA based language, strings are declared a literals using quotes:
<pre>var string = "This is an ECMA string";
var anotherString = 'So is this';</pre>
Objective-C on the other hand, uses the class <em>NSString</em> for string access, and you declare a constant string using a convenience method by putting an @ in front of your quotes:
<pre>NSString *string = @"This is an NSString";</pre>
<strong>&#8220;Yeah&#8230;? So?&#8221;</strong></p>

<p>Well, I spent 2 hours yesterday tracking down a dreaded <em>EXC_BAD_ACCESS</em> somewhere in my app &#8211; being new to Objective-C I just assumed that I&#8217;d messed up my memory management somewhere and double-released, or used an <em>autorelease</em> where I shouldn&#8217;t have. But I checked and checked and <em>checked</em> and couldn&#8217;t figure it out. I finally managed to track the crash down to a particular message call to a method that took an <em>NSDictionary</em> as one of it&#8217;s arguments:
<pre>[self.flickrRequest callAPIMethodWithPOST:@"flickr.photos.search" arguments:
    [NSDictionary dictionaryWithObjectsAndKeys:OBJECTIVE_FLICKR_API_KEY, @"api_key",
    @"1",@"has_geo",lat,@"lat",lon,@"lon",@"5",@"radius",@"photos","media",nil]];</pre>
Whenever I sent this message, the program would crash. I checked for a memory leak in every object in my class, I even looked for memory leaks in the <a title="Objective Flickr" href="http://github.com/lukhnos/objectiveflickr">ObjectiveFlickr</a> framework&#8230; But <em>you</em> see the issue right? Look again:
<pre>... ,@"photos",<strong>"media"</strong>,nil]];</pre>
It looked right to me because I&#8217;ve been an ActionScript developer for so long that anything in quotes just looks valid. And in C it <em>is</em> a valid character string constant (so there was no compile-error).
But if you pass a C string (rather than an <em>NSString</em>) as they key in an <em>NSDictionary</em>, you get an <em>EXC_BAD_ACCESS</em>. And a lot of wasted time.
<pre>... ,@"photos",<strong>@"media"</strong>,nil]];</pre>
That&#8217;s better.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.absentdesign.com/2010/10/an-actionscript-developer-with-exec_bad_access-first-just-check-your-strings/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Flash max-height issue</title>
		<link>http://blog.absentdesign.com/2010/03/the-flash-max-height-issue/</link>
		<comments>http://blog.absentdesign.com/2010/03/the-flash-max-height-issue/#comments</comments>
		<pubDate>Sun, 21 Mar 2010 03:23:56 +0000</pubDate>
		<dc:creator>Reuben</dc:creator>
				<category><![CDATA[flash]]></category>
		<category><![CDATA[tutorials]]></category>

		<guid isPermaLink="false">http://blog.absentdesign.com/?p=60</guid>
		<description><![CDATA[While working at Flint on the site for Paper Stone Scissors, I ran in to the little explored area of flash player 9&#8242;s maximum rendering area &#8211; the site uses JQuery to dynamically resize the flash HTML container to use browser scrollbars for long pages and unfortunately FP9 stops rendering graphics beyond 2880&#215;2880 pixels&#8230; a bit [...]]]></description>
			<content:encoded><![CDATA[<p>While working at <a href="http://www.flintinteractive.com.au/">Flint</a> on the site for <a href="http://www.paperstonescissors.com/">Paper Stone Scissors</a>, I ran in to the little explored area of flash player 9&#8242;s maximum rendering area &#8211; the site uses JQuery to dynamically resize the flash HTML container to use browser scrollbars for long pages and unfortunately FP9 stops rendering graphics beyond 2880&#215;2880 pixels&#8230; a bit of a problem where the site often scrolls to 4000px or more&#8230;</p>

<p>Redesign to use flash-based scrollbars wasn&#8217;t an option. After hours of messing around, I found a solution: use Javascript to keep the size of the flash within the renderable area, and fool the user in to <em>thinking they are scrolling HTML content when they are actually scrolling the flash</em>.</p>

<p>Do this by:
- Initially setting the size of the flash element to the desired full size (this sets the correct scrollbar size).
- While scrolling, use external interface to pass the scroll value of the browser in to flash.
Track the value in JS <em>and</em> in flash, and if the scroll value hits the maximum value:</p>

<ol>
    <li>In Javascript - reset the size of the flash html element to the max renderable size</li>
    <li>In flash &#8211; as the browser scrolls, scroll the flash content container in the <em>other</em> direction (this keeps the flash content within the maximum render area)</li>
    <li>In Javascript &#8211; add padding to the top of the flash html element to keep the scroll position correct</li>
</ol>

<p>I had a lot of trouble finding resources about this issue online, I hope this can help someone with the same problem.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.absentdesign.com/2010/03/the-flash-max-height-issue/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Simple mxmlc compiling on a Mac</title>
		<link>http://blog.absentdesign.com/2009/03/simple-mxmlc-compiling-on-a-mac/</link>
		<comments>http://blog.absentdesign.com/2009/03/simple-mxmlc-compiling-on-a-mac/#comments</comments>
		<pubDate>Fri, 27 Mar 2009 21:33:38 +0000</pubDate>
		<dc:creator>Reuben</dc:creator>
				<category><![CDATA[flash]]></category>
		<category><![CDATA[tutorials]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://absentdesign.wordpress.com/?p=7</guid>
		<description><![CDATA[The problem with being a flash developer from a traditional graphic design background is that there are some things that just don&#8217;t come naturally. One of these is working in a command-line environment. I&#8217;ve been using the Flash IDE as my development environment on the Mac since Flash 4. Around the time of Flash 5 [...]]]></description>
			<content:encoded><![CDATA[<p>The problem with being a flash developer from a traditional graphic design background is that there are some things that just don&#8217;t come naturally. One of these is working in a command-line environment.</p>

<p>I&#8217;ve been using the Flash IDE as my development environment on the Mac since Flash 4. Around the time of Flash 5 I started using BBEdit to edit external .as files, around MX I switched to TextMate for AS2 development, and now use TextMate exclusively for AS3 projects. But I&#8217;ve always used the IDE as my compiler, and there was always my designer&#8217;s preference to use the IDE to draw and layout objects rather than generate everything programatically. In developing my WordPress library I&#8217;ve been forced to bite the bullet and move to MXMLC, for the simple reason that the built in RPC libraries and Ak33m&#8217;s XML-RPC are only available for the Flex SDK.</p>

<p>I&#8217;m basically a total unix-command-line newbie, and there is a real dearth of information for people like me on how to command line compile in the mac environment. There is <a href="http://www.senocular.com/flash/tutorials/as3withmxmlc/">this tutorial by Senocular</a> for the PC, and there are plenty of tutorials out there about using MXML, integrating shell commands to use ANT etc etc, but all of these assume you <em>know what you are doing already</em>.</p>

<p>I <em>don&#8217;t know what I&#8217;m doing</em> though. All I want is to be able to integrate the Flex SDK classes without having to purchase and learn Flex and MXML &#8211; I&#8217;ve discovered  that this is of course not only <em>possible</em>, but <em>easy -</em> not that you&#8217;d know it by looking online.</p>

<h3>Here&#8217;s a way to do it</h3>

<h4>1. Download the Flex2 SDK from <a href="http://labs.adobe.com/technologies/flex/sdk/flex2sdk.html">Adobe Labs</a></h4>

<p>The Flex2 SDK is free! It includes the flex libraries and and the mxmlc compiler you will need to use the command line.</p>

<h4>2. Put the Flex2 SDK somewhere sensible</h4>

<blockquote>I put mine in <code>~/Documents/Library/Flex/flex2_sdk_hf1/</code></blockquote>

<h4>3. Open a terminal window</h4>

<blockquote>Usually <code>~/Applications/Utilities/Terminal.app</code></blockquote>

<h4>4. Navigate to your project folder, eg:</h4>

<blockquote><code>cd Documents/Projects/my_flash_project/Development/</code></blockquote>

<h4>5. Run fcsh</h4>

<p>Fcsh is the <em>Flex Compiler SHell</em>, a wrapper for MXMLC that makes compiling fast and easy. The simplest way to run this command is <strong>use the Finder to navigate to where you put the Flex SDK</strong>, find fcsh (in <code><strong>bin/fcsh</strong></code>) and <strong>drag and drop this file into your terminal window</strong>.</p>

<p>You should now see the following:</p>

<blockquote><code>Adobe Flex Compiler SHell (fcsh)
Version 2.0.1 build 159086
Copyright (c) 2004-2006 Adobe Systems, Inc. All rights reserved.</code>

<code> </code>

<code>(fcsh)</code></blockquote>

<h4>6. Compile your flash app using mxmlc</h4>

<p>The syntax to use is:</p>

<blockquote><code>mxmlc <span style="color:#00ccff;">path/to/MainFileForYourApplication.as</span> -sp <span style="color:#00ccff;">path/to/source/folder</span> -o <span style="color:#00ccff;">relative/path/to/output/filename.swf</span></code></blockquote>

<p>eg:</p>

<blockquote><code>mxmlc <span style="color:#00ccff;">src/com/reubenstanton/Main.as</span> -sp <span style="color:#800080;"><span style="color:#00ccff;">src/</span> </span>-o <span style="color:#00ccff;">../Deployment/main.swf</span></code></blockquote>

<p>The output will be something like:</p>

<blockquote><code>fcsh: Assigned 1 as the compile target id
Loading configuration file /Users/absent/Documents/Library/Flex/flex2_sdk_hf1/frameworks/flex-config.xml
../Deployment/main.swf (82769 bytes)</code></blockquote>

<p>You see that last line <code>../Deployment/main.swf</code>? If you navigate to this folder, you should see your swf sitting there! That&#8217;s it.</p>

<p>As you see above, fcsh <em>Assigned 1 as the compile target id</em>. This is just a shortcut to the compile command you just wrote &#8211; it means next time you want to compile you can just enter<span style="color:#993366;"> </span><code><span style="color:#00ccff;">mxmlc 1</span></code> instead of typing the whole command again.</p>

<h4>Now you can use Flex libraries in your flash projects without learning Flex and MXML.</h4>

<p>This took me hours to figure out, so I hope it helps some of you out there.</p>

<h4>Here are a few resources to help along the way:</h4>

<ul>
    <li><a href="http://labs.adobe.com/technologies/flex/sdk/flex2sdk.html">The Flex2 SDK</a> from Adobe Labs</li>
    <li><a href="http://labs.adobe.com/wiki/index.php/Flex_Compiler_Shell">The Flex Compiler Shell</a> from Adobe Labs</li>
    <li><a href="http://www.osxfaq.com/Tutorials/LearningCenter/">Using the terminal</a> from OSX Faq</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.absentdesign.com/2009/03/simple-mxmlc-compiling-on-a-mac/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

