<?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"
	>

<channel>
	<title>Visual Flow Designs</title>
	<atom:link href="http://visualflowdesigns.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://visualflowdesigns.com</link>
	<description>Online Portfolio and Blog for Jeremy Wischusen</description>
	<pubDate>Fri, 14 Nov 2008 16:06:05 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.3</generator>
	<language>en</language>
			<item>
		<title>Mind Your P&#8217;s and Q&#8217;s</title>
		<link>http://visualflowdesigns.com/2008/11/14/mind-your-ps-and-qs/</link>
		<comments>http://visualflowdesigns.com/2008/11/14/mind-your-ps-and-qs/#comments</comments>
		<pubDate>Fri, 14 Nov 2008 16:06:05 +0000</pubDate>
		<dc:creator>Jeremy Wischusen</dc:creator>
		
		<category><![CDATA[CSS]]></category>

		<guid isPermaLink="false">http://visualflowdesigns.com/?p=253</guid>
		<description><![CDATA[Ran into a situation today where IE was cutting off the bottom of letters such as p and q. If you run into this, the solution for me was to remove line-height definitions from the CSS file.
]]></description>
			<content:encoded><![CDATA[<p>Ran into a situation today where IE was cutting off the bottom of letters such as p and q. If you run into this, the solution for me was to remove line-height definitions from the CSS file.</p>
]]></content:encoded>
			<wfw:commentRss>http://visualflowdesigns.com/2008/11/14/mind-your-ps-and-qs/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Passing on the POST</title>
		<link>http://visualflowdesigns.com/2008/11/06/passing-on-the-post/</link>
		<comments>http://visualflowdesigns.com/2008/11/06/passing-on-the-post/#comments</comments>
		<pubDate>Thu, 06 Nov 2008 15:59:03 +0000</pubDate>
		<dc:creator>Jeremy Wischusen</dc:creator>
		
		<category><![CDATA[Integration]]></category>

		<category><![CDATA[JSP]]></category>

		<category><![CDATA[form]]></category>

		<category><![CDATA[GET]]></category>

		<category><![CDATA[POST]]></category>

		<guid isPermaLink="false">http://visualflowdesigns.com/?p=239</guid>
		<description><![CDATA[For some of my projects I have been implementing this tracking system that involves taking some values from a form and passing them as URL variables in the source of an image.
Here is the catch. The form is processed by an intermediary page that then forwards you to a confirmation page. This means that the [...]]]></description>
			<content:encoded><![CDATA[<p>For some of my projects I have been implementing this tracking system that involves taking some values from a form and passing them as URL variables in the source of an image.</p>
<p>Here is the catch. The form is processed by an intermediary page that then forwards you to a confirmation page. This means that the form data is not available on the final page where the tracking code needs to access it.</p>
<p>The solution that chosen was to grab the values from the form during the validation process in JavaScript and append them to the URL of the redirect page that the intermediary page forwards you to.</p>
<p>This was fine, but each implementation wanted different variables and form values to be available for tracking. So I was constantly customizing the JavaScript to get the right form data and the request variables in JSP to retrieve the passed variables. This became tiresome really quickly after about the 4th implementation.</p>
<p>So, I created little system to streamline the process. Here is what I came up with (some sensitive data removed, but idea still there).</p>
<p>The JavaScript Class:</p>
<blockquote><p>function TrackingPixel() {<br />
/*Create a reference to the form that contains the data. This could be made more flexible, but for my purposes the form always has the same name. */<br />
this.form = document.emailForm;<br />
/*Iteration variable used to determine if an &amp; needs to be appended between variables*/<br />
this.i = 0<br />
/*String to hold the URL variables that we are going to create*/<br />
this.qs = &#8220;&#8221;;<br />
}</p>
<p>/*Instance variable that holds a reference to a configuration object that specifies the URL variables to create and the form element to use for the value.*/<br />
TrackingPixel.prototype.variableMap;</p>
<p>/*Certain form values are special cases such as birthdates which required the use of multiple form elements to create the final value. This object specified those cases, the processing method and the values required by the method. */<br />
TrackingPixel.prototype.specialCases;</p>
<p>/*This function loops through the configuration objects defined above and handles any special cases to create the final query string. */<br />
TrackingPixel.prototype.createVariables = function() {<br />
/*Loop through the standard cases*/<br />
for (v in this.variableMap) {<br />
/*Find the form element that matches the key in the config object*/<br />
var elem = this.form[this.variableMap[v]];<br />
/*If the form element is a compound type, find the selected value. Right now I only needed to deal with radio buttons*/<br />
if (elem.type == &#8220;radio&#8221;) {<br />
this.buildString(v, this.getArrayValue(elem))<br />
} else {<br />
this.buildString(v, elem.value)<br />
}<br />
}<br />
/*Loop through the special cases and return the value from the specified processing function*/<br />
for (s in this.specialCases) {<br />
this.buildString(s, this[this.specialCases[s].method]<br />
(this.specialCases[s].elems))<br />
}<br />
/*If we found variables append the query string to the URL of the forwarding page*/<br />
if (this.qs.length &gt; 0) {<br />
/*See if there are already variables on the URL of the forwarding page, other wise append the ?*/<br />
if (this.form.targetPage.value.indexOf(&#8221;?&#8221;) &gt; -1) {<br />
this.form.targetPage.value += &#8220;&amp;&#8221;<br />
} else {<br />
this.form.targetPage.value += &#8220;?&#8221;<br />
}<br />
this.form.targetPage.value += this.qs;<br />
}<br />
}<br />
/*This is one of the special cases methods. Create a date string using the specified form values*/<br />
TrackingPixel.prototype.birthDate = function(bDayElems) {<br />
return this.form[bDayElems[0]].value + &#8220;/&#8221; + this.form[bDayElems[1]].value<br />
+ &#8220;/&#8221; + this.form[bDayElems[2]].value<br />
}<br />
/*Create URL value using the passed key and value and append it to the query string*/<br />
TrackingPixel.prototype.buildString = function(key, val) {<br />
if (this.i &gt; 0) {<br />
this.qs += &#8220;&amp;&#8221;;<br />
}<br />
this.qs += key + &#8220;=&#8221; + val;<br />
this.i++;<br />
}<br />
/*Find the selected value of a complex form object such as a radio button*/<br />
TrackingPixel.prototype.getArrayValue = function(arr) {<br />
for (a = 0; a &lt; arr.length; a++) {<br />
if (arr[a].checked == true) {<br />
return arr[a].value<br />
}<br />
}<br />
}</p></blockquote>
<p>Once I had this class set up, all I have to do in the page with the form is the following:</p>
<blockquote><p>&lt;script src=&#8221;/js/TrackingPixel.js&#8221; type=&#8221;text/javascript&#8221;&gt;&lt;/script&gt;</p>
<p>//In form validation code:<br />
function validateForm(){<br />
…other validation code<br />
var tp = new TrackingPixel ();<br />
/*Create the standard configuration object specifying the variables to create and the form field that supply the values*/<br />
tp.variableMap = {e:&#8221;emailAddress&#8221;, src:&#8221;contest&#8221;,f:&#8221;favoritecolor&#8221;}<br />
/*Define any special cases, the method used to handle them, and specify the form values needed by that method*/<br />
tp.specialCases={d:{method:&#8221;birthDate&#8221;, elems:['birthMo',"birthDay","birthYr"]}}<br />
/*Call this function to create and append the variable string*/<br />
tp.createVariables();<br />
}</p></blockquote>
<p>The final piece of this system was to automate the output of the actual tracking image. In the first few implementations I would manually update the URL variables I wanted, which would look something like:</p>
<blockquote><p>&lt;div id=&#8221;trackingPixel&#8221;&gt;&lt;img src=&#8221;https://trackingurl.com?e=&lt;%=request.getParameter(&#8221;e&#8221;)%&gt;&amp; src=&lt;%=request.getParameter(&#8221;src&#8221;)%&gt;&amp; f=&lt;%=request.getParameter(&#8221;f&#8221;)%&gt;’ width=&#8221;1&#8243; height=&#8221;1&#8243;/&gt; &lt;/div&gt;<br />
<!--End pixel tracking--></p></blockquote>
<p>Where I was basically going in each time an updating the var=&lt;%=request.getParameter(&#8221;key&#8221;)%&gt; and adding &amp; in between.</p>
<p>Since the var name always matched the key, I came up with this:</p>
<blockquote><p>&lt;%@ taglib prefix=&#8221;c&#8221; uri=&#8221;http://java.sun.com/jstl/core&#8221; %&gt;<br />
&lt;c:set var=&#8221;eKeys&#8221;&gt;e,src,b&lt;/c:set&gt;<br />
&lt;!&#8211;Being pixel tracking&#8211;&gt;<br />
&lt;div id=&#8221;trackingPixel&#8221;&gt;<br />
&lt;img src=&#8217;https://trackingurl.com?sie=someSite&lt;c:forTokens var = &#8220;k&#8221; items= &#8220;${eKeys}&#8221; delims=&#8221;,&#8221;&gt;&lt;c:if test=&#8221;${! empty param[k]}&#8221;&gt;&amp;&lt;c:out value= &#8220;${k}&#8221;/&gt;=&lt;c:out value= &#8220;${param[k]}&#8221;/&gt;&lt;/c:if&gt;&lt;/c:forTokens&gt;&amp;la=Y&#8217; width=&#8221;1&#8243; height=&#8221;1&#8243;/&gt;<br />
&lt;/div&gt;<br />
&lt;!&#8211;End pixel tracking&#8211;&gt;</p></blockquote>
<p>The only things I have to do to customize this is change the keys in</p>
<blockquote><p>&lt;c:set var=&#8221;eKeys&#8221;&gt;e,src,b&lt;/c:set&gt;</p></blockquote>
<p>to match those passed in the URL and the rest is taken care of for me.</p>
<p>Then I just include the JSP file that contains the code final landing page and I am good to go.</p>
<p>I am sure there are improvements that can be made (there always are), but this has taken the implementation time of this system down from about an hour to about 10 minutes.</p>
]]></content:encoded>
			<wfw:commentRss>http://visualflowdesigns.com/2008/11/06/passing-on-the-post/feed/</wfw:commentRss>
		</item>
		<item>
		<title>arcTo curved animation</title>
		<link>http://visualflowdesigns.com/2008/10/30/arcto-curved-animation/</link>
		<comments>http://visualflowdesigns.com/2008/10/30/arcto-curved-animation/#comments</comments>
		<pubDate>Thu, 30 Oct 2008 17:55:41 +0000</pubDate>
		<dc:creator>Jeremy Wischusen</dc:creator>
		
		<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://visualflowdesigns.com/?p=235</guid>
		<description><![CDATA[While trying to answer another post on Flashkit, ran across an interesting dilemma.
The basic idea here was to create a function that would create a curved animation path to a specified x and y coordinate.
The basic idea here is:

Find the pivot point between the current x and y and the desired x and y.
Calculate the [...]]]></description>
			<content:encoded><![CDATA[<p>While trying to answer another <a href="http://board.flashkit.com/board/showthread.php?t=780334" onclick="javascript:pageTracker._trackPageview('/outbound/article/board.flashkit.com');" target="_blank">post</a> on Flashkit, ran across an interesting dilemma.</p>
<p>The basic idea here was to create a function that would create a curved animation path to a specified x and y coordinate.</p>
<p>The basic idea here is:</p>
<ol>
<li>Find the pivot point between the current x and y and the desired x and y.</li>
<li>Calculate the current angle from this pivot point for the current x and y of the clip.</li>
<li>Calculate the ending angle based on the desired ending coordinates and the pivot point.</li>
<li>Using trig, update the x and y of the clip along an arc at a given radius until it reaches the end angle.</li>
</ol>
<p>After a while of playing with it, came up with this</p>
<p>In AS frame main movie:</p>
<blockquote><p>import CurvedAnimation;<br />
var ca:CurvedAnimation = new CurvedAnimation(ball);<br />
ca.arcTo(500,500);</p></blockquote>
<p>Class File (this is by no means complete and has some code left over from  various previous attempts, but it shows what I finally came up with):</p>
<blockquote><p>class CurvedAnimation {<br />
private var _clip:MovieClip;<br />
private var startAngle:Number;<br />
private var currentAngle:Number;<br />
public var speed:Number = 1;<br />
public var arcWidth:Number;<br />
private var endAngle:Number;<br />
private var pivotX:Number;<br />
private var pivotY:Number;<br />
private var updateInterval:Number;<br />
public function CurvedAnimation(clip:MovieClip) {<br />
trace(&#8221;new curved animation&#8221;);<br />
this._clip = clip;<br />
}<br />
public function arcTo(endX:Number, endY:Number) {<br />
var midWay = Math.sqrt(Math.pow(this._clip._x-endX, 2)+Math.pow(this._clip._y-endY, 2))/2;<br />
this.arcWidth= 100;<br />
_root.endPin._x = endX;<br />
_root.endPin._y = endY;<br />
_root.endPin.lbl_txt.text = &#8220;End point&#8221;;</p>
<p>if (endX&gt;this._clip._x) {<br />
this.pivotX = Math.floor(this._clip._x+midWay);<br />
} else {<br />
this.pivotX = Math.floor(this._clip._x-midWay);<br />
}<br />
if (endY&gt;this._clip._Y) {<br />
this.pivotY = Math.floor(this._clip._y+midWay);<br />
} else {<br />
this.pivotY = Math.floor(this._clip._y-midWay);<br />
}<br />
this.currentAngle = this.startAngle = Math.atan2(this._clip._y - this.pivotY ,this._clip._x - this.pivotX)*180/Math.PI<br />
this.endAngle = Math.atan2(endY - this.pivotY ,endX- this.pivotX)*180/Math.PI<br />
this.updateInterval = setInterval(this, &#8220;updatePosition&#8221;, 100);<br />
debug();<br />
}<br />
private function debug() {<br />
_root.midPin._x = this.pivotX;<br />
_root.midPin._y = this.pivotY;<br />
_root.midPin.lbl_txt.text = &#8220;mid point&#8221;;<br />
trace(&#8221;Current position x: &#8220;+this._clip._x+&#8221; y: &#8220;+this._clip._y);<br />
trace(&#8221;Pivot point x: &#8220;+this.pivotX+&#8221; y: &#8220;+this.pivotY);<br />
trace(&#8221;Start Angle &#8220;+this.startAngle);<br />
trace(&#8221;Current Angle &#8220;+this.currentAngle);<br />
trace(&#8221;End Angle &#8220;+this.endAngle);<br />
_root.debug.mouseAngle.text =this.currentAngle</p>
<p>}<br />
private function updatePosition(){</p>
<p>//this._clip._y = -0.002644 * Math.pow(((this._clip._x += 5) - 200), 2) + 200;<br />
if (Math.floor(this.currentAngle) &lt;= Math.floor(this.endAngle)){<br />
this._clip._y = this.pivotY + Math.sin(this.currentAngle * (Math.PI/180))*this.arcWidth;<br />
this._clip._x = this.pivotX + Math.cos(this.currentAngle * (Math.PI/180))*this.arcWidth;<br />
this.currentAngle += this.speed;<br />
this.currentAngle %= 360;<br />
}else{<br />
clearInterval(this.updateInterval)<br />
}<br />
debug();</p>
<p>}</p>
<p>}</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://visualflowdesigns.com/2008/10/30/arcto-curved-animation/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Joey Lott Presentation</title>
		<link>http://visualflowdesigns.com/2008/10/24/joey-lott-presentation/</link>
		<comments>http://visualflowdesigns.com/2008/10/24/joey-lott-presentation/#comments</comments>
		<pubDate>Fri, 24 Oct 2008 16:03:29 +0000</pubDate>
		<dc:creator>Jeremy Wischusen</dc:creator>
		
		<category><![CDATA[General]]></category>

		<category><![CDATA[Joey]]></category>

		<category><![CDATA[Lott]]></category>

		<guid isPermaLink="false">http://visualflowdesigns.com/?p=217</guid>
		<description><![CDATA[Yesterday I attended a presentation on Adobe Air by Joey Lott. First of all, this guy is a great presenter and if you have the chance to go see him, do so. Secondly, if you have not read any of his books, I highly recommend them. Currently I am reading through Adobe AIR in Action [...]]]></description>
			<content:encoded><![CDATA[<p class="MsoNormal">Yesterday I attended a presentation on Adobe Air by Joey Lott. First of all, this guy is a great presenter and if you have the chance to go see him, do so. Secondly, if you have not read any of his books, I highly recommend them. Currently I am reading through <span><a href="http://www.amazon.com/Adobe-AIR-Action-Joseph-Lott/dp/1933988487" onclick="javascript:pageTracker._trackPageview('/outbound/article/www.amazon.com');">Adobe AIR in Action</a><strong> </strong>and that is definitely worth taking a look at if you are interested in AIR.</p>
<p>However, it is not really the topic of AIR or Joey’s books that I want to cover. </span></p>
<p class="MsoNormal"><span>During the presentation, the topic of what skills one should focus on if one wanted to get a job in the industry came up. Joey made a particular analogy in his response that is worth sharing.<br />
</span></p>
<p class="MsoNormal"><span>He likened knowing ActionScript to knowing English (or any other language). He then went on to say, knowing English, while a prerequisite for being a poet, is not itself alone enough to make you one. </span></p>
<p class="MsoNormal"><span>He was using this analogy in the context of reviewing potential candidate for his company. He was not interested in degrees or certifications, he wanted to see your poetry (what can you do and what have you done). </span></p>
<p class="MsoNormal"><span>This is a great point he was making and it is something that is missed by many interview processes (especially phone screens). Basically many of the interviews I have been through start with a phone screen where they archaic questions about language features. Who cares. If you can’t tell I have the skills you are looking for from the examples I provide on my blog and resume, why bother calling me? </span></p>
<p class="MsoNormal">So perhaps when you are evaluating whether you are interested in working for a company, ask yourself; where the interested in what I had done, or more interested in my ability to answer silly question?</p>
]]></content:encoded>
			<wfw:commentRss>http://visualflowdesigns.com/2008/10/24/joey-lott-presentation/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Gotta Go To Mo&#8217;s</title>
		<link>http://visualflowdesigns.com/2008/10/09/gotta-go-to-mos/</link>
		<comments>http://visualflowdesigns.com/2008/10/09/gotta-go-to-mos/#comments</comments>
		<pubDate>Thu, 09 Oct 2008 15:53:54 +0000</pubDate>
		<dc:creator>Jeremy Wischusen</dc:creator>
		
		<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://visualflowdesigns.com/?p=207</guid>
		<description><![CDATA[Just finished up the site redesign of Modell&#8217;s Sporting goods. I was a team member on this and the rest of the team was a great help, so I in know way want to represent this as if I was the only one involved.
]]></description>
			<content:encoded><![CDATA[<p>Just finished up the site redesign of <a title="Modell's Sporting Goods" href="http://www.modells.com/home/index.jsp" onclick="javascript:pageTracker._trackPageview('/outbound/article/www.modells.com');" target="_blank">Modell&#8217;s Sporting goods</a>. I was a team member on this and the rest of the team was a great help, so I in know way want to represent this as if I was the only one involved.</p>
]]></content:encoded>
			<wfw:commentRss>http://visualflowdesigns.com/2008/10/09/gotta-go-to-mos/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Comparing Flex Frameworks</title>
		<link>http://visualflowdesigns.com/2008/09/12/comparing-flex-frameworks/</link>
		<comments>http://visualflowdesigns.com/2008/09/12/comparing-flex-frameworks/#comments</comments>
		<pubDate>Fri, 12 Sep 2008 18:15:33 +0000</pubDate>
		<dc:creator>Jeremy Wischusen</dc:creator>
		
		<category><![CDATA[Flex]]></category>

		<category><![CDATA[OOP]]></category>

		<guid isPermaLink="false">http://visualflowdesigns.com/?p=189</guid>
		<description><![CDATA[Yesterday I attended a meeting of the local Flex user group.  The subject was comparing Flex frameworks presented by Yakov Fain. You can view the slides from the presentation here.
I myself have never used one of these frameworks, as I simply have never had the need for one. However I have been researching them [...]]]></description>
			<content:encoded><![CDATA[<p>Yesterday I attended a meeting of the local <a href="http://myflex.org/presentations/ComparingFlexFrameworks.pdf" onclick="javascript:pageTracker._trackPageview('/outbound/article/myflex.org');" target="_blank">Flex user group</a>.  The subject was comparing Flex frameworks presented by <a href="http://flexblog.faratasystems.com/" onclick="javascript:pageTracker._trackPageview('/outbound/article/flexblog.faratasystems.com');" target="_blank">Yakov Fain</a>. You can view the slides from the presentation <a href="http://myflex.org/presentations/ComparingFlexFrameworks.pdf" onclick="javascript:pageTracker._trackPageview('/outbound/article/myflex.org');" target="_blank">here</a>.</p>
<p>I myself have never used one of these frameworks, as I simply have never had the need for one. However I have been researching them and after attending this presentation I still feel that my initial inclination towards them stands; they exist mostly for standardization when working in teams.</p>
<p>By this I mean you can accomplish the same thing you can with the framework using standard Flex code and ActionScript, more than likely in a much simpler fashion depending on the project. What they afford you when working in a team is that you know that if everyone is using the same framework, then they are coding in the same fashion, hence the code written by one team member should work with the code by another. And as Yakov pointed out, they allow you to spilt up large projects among a team.</p>
<p>This is a nice benefit, but these benefits often come at a cost. For example one of the major complaints about Cairngorm is that you have to write a lot of classes.  One reason for this is that in Cairngorm each event that the application triggers has to have a corresponding Command class. That&#8217;s a class for every event (its actually worse than that as there are other classes that these need to communicate with that you need to write as well). For a large application with a lot of events, this quickly becomes a lot of code.</p>
<p>Another implication of this is that you can only have one event responder per event. In other words, you lose the benefit of being able to have  multiple responders to a single event that is built into Flex events, which as far as I am concerned was a great improvement over the AS2 model. Cairngorm essentially takes you back to the AS2 model.</p>
<p>Mate has a better event model and it does do a nice job of managing dependencies via dependency injection,  but you have to maintain an event map and Mate is an MXML only framework.</p>
<p>And as far as PureMVC goes (look at the flow diagram slide for it in the presentation I linked to) all I can say is ???????. In its defense, PureMVC was designed to be language agnostic, but it seems to suffer from the &#8220;trying to be everything to everyone&#8221; syndrome.</p>
<p>The slides I linked to do a good job of pointing out the strengths and weaknesses of each framework, so I will refer you to them if you are interested in learning more.</p>
<p>So for now, it seems that these frameworks would get in the way more than they would simplify anything for me.</p>
]]></content:encoded>
			<wfw:commentRss>http://visualflowdesigns.com/2008/09/12/comparing-flex-frameworks/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Tween Sequencer</title>
		<link>http://visualflowdesigns.com/2008/09/04/tween-squencer/</link>
		<comments>http://visualflowdesigns.com/2008/09/04/tween-squencer/#comments</comments>
		<pubDate>Thu, 04 Sep 2008 16:57:56 +0000</pubDate>
		<dc:creator>Jeremy Wischusen</dc:creator>
		
		<category><![CDATA[ActionScript 3]]></category>

		<category><![CDATA[OOP]]></category>

		<category><![CDATA[Open Source Projects]]></category>

		<guid isPermaLink="false">http://visualflowdesigns.com/?p=177</guid>
		<description><![CDATA[Many of the projects I have done have included creating some sort of repeating sequence of tweens. In my early projects I would trigger the next tween using the finished event for each tween. This sucked.
So recently I had some time and decided to take a crack at creating a tween sequencing class. Basic idea [...]]]></description>
			<content:encoded><![CDATA[<p>Many of the projects I have done have included creating some sort of repeating sequence of tweens. In my early projects I would trigger the next tween using the finished event for each tween. This sucked.</p>
<p>So recently I had some time and decided to take a crack at creating a tween sequencing class. Basic idea being that I add a sequence of tweens to a object and then just call a start function to trigger the sequence.</p>
<p>My first idea was to create a collection of tween objects and store references to them in an array. This led me to com up with this:</p>
<blockquote><p>package com.vfd.animation.tweens{<br />
import fl.transitions.TweenEvent;<br />
import fl.transitions.Tween;<br />
public class TweenSequencer {<br />
private var _tweens:Array=new Array  ;</p>
<p>private var index:Number=0;<br />
public var loop:Boolean=false;<br />
public function TweenSequencer() {<br />
trace(&#8221;New Tween Sequencer&#8221;);<br />
}<br />
public function addTween(tween:Tween):void {<br />
tween.stop();<br />
tween.addEventListener(TweenEvent.MOTION_FINISH,nextTween);<br />
this._tweens.push(tween);<br />
}<br />
public function removeTween(tween:Tween):void {<br />
for (var i:Number=0; i &lt; this._tweens.length; i++) {<br />
if (this._tweens[i] == tween) {<br />
this._tweens[i].removeEventListener(TweenEvent.MOTION_FINISH,nextTween);<br />
this._tweens.splice(i,1);<br />
break;<br />
}<br />
}<br />
}<br />
public function start():void {<br />
this.startTween();<br />
}<br />
public function stop():void {<br />
this.pause();<br />
this.reset();<br />
}<br />
public function pause():void {<br />
if (this._tweens[this.index]) {<br />
this._tweens[this.index].stop();<br />
}<br />
}<br />
private function nextTween(event:TweenEvent):void {<br />
trace(&#8221;Index before &#8221; + this.index);<br />
trace(&#8221;Loop : &#8221; + this.loop);<br />
this.index++;<br />
if (this.loop &amp;&amp; this.index &gt;= this._tweens.length) {<br />
this.reset();<br />
}<br />
trace(&#8221;Index after &#8221; + this.index);<br />
this.startTween();</p>
<p>}<br />
private function startTween() {<br />
if (this._tweens[this.index]) {<br />
this._tweens[this.index].play();<br />
} else {<br />
this.reset();<br />
}<br />
}<br />
private function reset():void {<br />
this.index=0;<br />
}<br />
}//end class<br />
}//end package</p></blockquote>
<p>The basic idea worked, but I ran into a couple of problems. I was testing this with a basic ball. I placed the ball in the top right corner of the screen. Every time I ran the thing it would play the tweens in the correct sequence, but the ball always started in the bottom right corner of the screen making the first run through the sequence incorrect. However, after the first run through it played as expected.</p>
<p>This took me a while to figure out, but as it turns out that when I created the tweens, even though I immediately stopped them, it was setting the properties of the ball to the start values of the second set of tweens that were applied to the x and y coordinates.</p>
<p>I tried all sorts of variations including writing my own tween class that overrode the starting behaviors of the standard tween class and I still ended up with the same results (though it is entirely possible that I missed something simple).</p>
<p>I did turn out that if I explicitly set the x and y coordinates of the clip after creating the tweens, it worked as expected. However, I was only testing with many tweens applied to one object. If I was applying tweens to multiple objects I would have to reset all of them and having to explicitly set the coordinates defeated the purposes of placing them on the stage where I wanted them to begin with. Additionally, I ran into this problem with tweens applied to x and y, but if there are other properties that behaved the same way, I would have to reset those as well. This class was intended to make this process sequencing tweens easier, not simply introduce a new set of headaches.</p>
<p>After some time I came up with the idea of using a single tween inside of the sequencer class. Instead of storing multiple tween instances, I would just store sequence of properties and values that I wanted to tween an update the single tween instance. this would keep the tweens property settings from conflicting with one another and throwing the sequence off. This lead to:</p>
<blockquote><p>package com.vfd.animation.tweens{<br />
import fl.transitions.TweenEvent;<br />
import fl.transitions.Tween;<br />
import flash.display.Sprite;<br />
public class TweenSequencer {<br />
private var _tweens:Array=new Array();<br />
private var tween:Tween;<br />
private var index:Number=0;<br />
public var loop:Boolean=false;<br />
private var placeHolderSprite:Sprite   = new Sprite();<br />
public function TweenSequencer() {<br />
trace(&#8221;New Tween Sequencer&#8221;);<br />
this.tween = new fl.transitions.Tween(this.placeHolderSprite,&#8221;alpha&#8221;,null,1,1,1,true);<br />
this.tween.stop();<br />
this.tween.addEventListener(TweenEvent.MOTION_FINISH,nextTween);<br />
}<br />
public function addTween(obj:Object, prop:String, easing:Function, begin:Number, end:Number, duration:Number, useSeconds:Boolean = false):void {<br />
this._tweens.push(arguments);<br />
}<br />
public function start():void {<br />
this.startTween();<br />
}<br />
public function stop():void {<br />
this.tween.rewind();<br />
this.reset();<br />
}<br />
public function pause():void {<br />
this.tween.stop();<br />
}<br />
private function nextTween(event:TweenEvent):void {<br />
this.index++;<br />
if (this.loop &amp;&amp; this.index &gt;= this._tweens.length) {<br />
this.reset();<br />
}<br />
this.startTween();</p>
<p>}<br />
private function startTween() {<br />
this.tween.stop();<br />
if (this._tweens[this.index]) {<br />
this.tween.obj = this._tweens[this.index][0];<br />
this.tween.prop = this._tweens[this.index][1];<br />
if (this._tweens[this.index][2] is Function) {<br />
this.tween.func = this._tweens[this.index][2];<br />
}<br />
this.tween.begin = this._tweens[this.index][3];<br />
this.tween.finish = this._tweens[this.index][4];<br />
this.tween.duration = this._tweens[this.index][5];<br />
this.tween.useSeconds = this._tweens[this.index][6];<br />
this.tween.start();<br />
} else {<br />
this.reset();<br />
}<br />
}<br />
private function reset():void {<br />
this.index=0;<br />
}<br />
public function reverse() {<br />
this._tweens.reverse();<br />
}<br />
}//end class<br />
}//end package</p></blockquote>
<p>So now this:</p>
<blockquote><p>import com.vfd.animation.tweens.TweenSequencer;<br />
var ts:TweenSequencer = new TweenSequencer();<br />
ts.loop = true;<br />
ts.addTween(ball, &#8220;alpha&#8221;, null, 0,1,2,true);<br />
ts.addTween(ball, &#8220;x&#8221;, null, 130,300,2,true);<br />
ts.addTween(ball, &#8220;y&#8221;, null, 130,300,2,true);<br />
ts.addTween(ball, &#8220;x&#8221;, null, 300,130,2,true);<br />
ts.addTween(ball, &#8220;y&#8221;, null, 300,130,2,true);<br />
ts.addTween(ball, &#8220;alpha&#8221;, null, 1,0,2,true);<br />
ts.start();</p></blockquote>
<p>Produces this:</p>

<object	type="application/x-shockwave-flash"
			data="http://www.visualflowdesigns.com/flash/tweenSquencer.swf"
			width="550"
			height="400">
	<param name="movie" value="http://www.visualflowdesigns.com/flash/tweenSquencer.swf" />
</object>
]]></content:encoded>
			<wfw:commentRss>http://visualflowdesigns.com/2008/09/04/tween-squencer/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Tweaking Eclipse</title>
		<link>http://visualflowdesigns.com/2008/08/31/tweaking-eclipse/</link>
		<comments>http://visualflowdesigns.com/2008/08/31/tweaking-eclipse/#comments</comments>
		<pubDate>Sun, 31 Aug 2008 23:17:09 +0000</pubDate>
		<dc:creator>Jeremy Wischusen</dc:creator>
		
		<category><![CDATA[Eclipse]]></category>

		<guid isPermaLink="false">http://visualflowdesigns.com/?p=169</guid>
		<description><![CDATA[Eclipse is a very powerful editor, but let&#8217;s face it. It can be slow. Recently I have been doing some research into some ways I can get the thing to speed up a little and I thought I would share what I have found. As it turns out, the most detailed description I have found [...]]]></description>
			<content:encoded><![CDATA[<p>Eclipse is a very powerful editor, but let&#8217;s face it. It can be slow. Recently I have been doing some research into some ways I can get the thing to speed up a little and I thought I would share what I have found. As it turns out, the most detailed description I have found is in a book I own on Flex -<br />
<a href="http://search.barnesandnoble.com/Flex-Solutions/Marco-Casario/e/9781590598764/?itm=2" onclick="javascript:pageTracker._trackPageview('/outbound/article/search.barnesandnoble.com');">Flex Solutions : Essential Techniques for Flex 2 and 3 Developers</a><em> by                        <a href="http://search.barnesandnoble.com/booksearch/results.asp?ATH=Marco+Casario" onclick="javascript:pageTracker._trackPageview('/outbound/article/search.barnesandnoble.com');">Marco Casario</a></em>. It basically mirrors the resources I found online, but has more details in regards to what settings to try for particular amounts of memory.</p>
<p>In order to apply some of these tweaks, you will be editing the INI file for Eclipse. This file is named eclipse.ini and can be found in the root directory of wherever you installed Elcipse (e.g., C:\Program Files\eclipse).</p>
<p>Lets start with those tweaks first and then move on to some of the other settings you can play with once you have Eclipse open.</p>
<p>Once you have located the eclipse.ini, make a back up copy of it in case you need to reference to your original settings. Once you have done that, open elcipse.ini in you text editor of choice.</p>
<p>The default contents of my ini file looked like this:</p>
<p>-showsplash<br />
org.eclipse.platform<br />
&#8211;launcher.XXMaxPermSize<br />
256M<br />
-vmargs<br />
-Dosgi.requiredJavaVersion=1.5<br />
-Xms40m<br />
-Xmx256m</p>
<p>We are interested in the stuff after the -vmargs. These are the arguments that Eclipse passes to the Java Virtual Machine. By tweaking these settings, we can do things like manage the amount of memory allocated to Eclipse. To apply the tweaks, we are going to modify some of the existing arguments and add a few new ones. For the ones we add, place them at the end of the file after the -vmargs flag. If you are interested in what the specific arguments mean, go <a title="Turbo Charging Eclipse" href="http://http://eclipse.dzone.com/news/turbo-charging-eclipse" onclick="javascript:pageTracker._trackPageview('/outbound/article/eclipse.dzone.com');" target="_blank">here</a> as I am not going to go into that level of detail.</p>
<p>Here are the recommended settings by amount of RAM.</p>
<p>512 MB RAM:</p>
<p>-Xms256m<br />
-Xmx256m<br />
-XX:PermSize=128m<br />
-XX:MaxPermSize=128m</p>
<p>1 GB RAM</p>
<p>-Xms512m<br />
-Xmx512m<br />
-XX:PermSize=256m<br />
-XX:MaxPermSize=256m</p>
<p>2 GB RAM</p>
<p>-Xms1024m<br />
-Xmx1024m<br />
-XX:PermSize=512m<br />
-XX:MaxPermSize=512m</p>
<p>Save the file.</p>
<p>Now we can move onto some of the things you can do once you have eclipse open.</p>
<p>Those of you who use Eclipse know that it has a good error checking system. However, that robustness comes at the cost of speed. Once of the things that Eclipse does is scans through the workspace to check for errors. If you have a large workspace with a lot of projects this can take quite some time. To keep Eclipse from doing this scan each time you save a file, disable the Build Automatically option (Window&gt;&gt;Preferences&gt;&gt;Workspace). If you need error checking, you can turn it back on right before you are going to do a release.</p>
<p>Once of the other things you can do is close any projects that you are not using. That way Eclipse does not have to keep track of them.</p>
<p>Finally, we can apply the same idea to files. For each file that you have open, Eclipse has to track it an allocate memory. Close files that you are not working on and as a further step you can actually limit the number of files that Eclipse will allow you to have open in the preferences dialog (Window &gt;&gt; Preferences &gt;&gt; General &gt;&gt; Editors)</p>
]]></content:encoded>
			<wfw:commentRss>http://visualflowdesigns.com/2008/08/31/tweaking-eclipse/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Flex 4 Available on Adobe Open Source Site</title>
		<link>http://visualflowdesigns.com/2008/08/28/flex-4-avialable-on-adobe-open-source-site/</link>
		<comments>http://visualflowdesigns.com/2008/08/28/flex-4-avialable-on-adobe-open-source-site/#comments</comments>
		<pubDate>Thu, 28 Aug 2008 14:06:25 +0000</pubDate>
		<dc:creator>Jeremy Wischusen</dc:creator>
		
		<category><![CDATA[Flex]]></category>

		<guid isPermaLink="false">http://visualflowdesigns.com/?p=164</guid>
		<description><![CDATA[As the title says: http://opensource.adobe.com/wiki/display/flexsdk/Gumbo
]]></description>
			<content:encoded><![CDATA[<p>As the title says: http://opensource.adobe.com/wiki/display/flexsdk/Gumbo</p>
]]></content:encoded>
			<wfw:commentRss>http://visualflowdesigns.com/2008/08/28/flex-4-avialable-on-adobe-open-source-site/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Hold on a Second</title>
		<link>http://visualflowdesigns.com/2008/08/15/hold-on-a-second/</link>
		<comments>http://visualflowdesigns.com/2008/08/15/hold-on-a-second/#comments</comments>
		<pubDate>Fri, 15 Aug 2008 16:41:21 +0000</pubDate>
		<dc:creator>Jeremy Wischusen</dc:creator>
		
		<category><![CDATA[ActionScript 2]]></category>

		<category><![CDATA[ActionScript 3]]></category>

		<category><![CDATA[OOP]]></category>

		<category><![CDATA[Open Source Projects]]></category>

		<guid isPermaLink="false">http://visualflowdesigns.com/?p=149</guid>
		<description><![CDATA[You can find a lot of tween libraries for AS2 and AS3. Many of these include some sort of mechanism for delaying the start of a tween. A while back I took my own shot at this based off of another class that I found and came up with:
import mx.transitions.Tween;
class com.vfd.animation.tweens.DelayedTween extends Tween{
private var intervalID:Number
private [...]]]></description>
			<content:encoded><![CDATA[<p>You can find a lot of tween libraries for AS2 and AS3. Many of these include some sort of mechanism for delaying the start of a tween. A while back I took my own shot at this based off of another class that I <a title="Original Delayed Tween Class" href="http://timwalling.com/2005/06/22/mxtransitionstween-extended/" onclick="javascript:pageTracker._trackPageview('/outbound/article/timwalling.com');" target="_blank">found</a> and came up with:</p>
<blockquote><p>import mx.transitions.Tween;<br />
class com.vfd.animation.tweens.DelayedTween extends Tween{</p>
<p>private var intervalID:Number<br />
private var delay:Number = 0;</p>
<p>public function DelayedTween(object, property, easingFunction, start, end, duration, useSeconds, delay) {</p>
<p>super(object, property, easingFunction, start, end, duration, useSeconds);<br />
this.delay = Math.abs(delay*1000);<br />
this.setDelay();</p>
<p>}<br />
private function start() {</p>
<p>}</p>
<p>private function setDelay() {<br />
if (this.delay &gt; 0) {<br />
this.intervalID = setInterval(this, &#8220;startAnimation&#8221;, this.delay);<br />
}else {<br />
this.startAnimation();<br />
}<br />
}</p>
<p>private function startAnimation() {<br />
clearInterval(this.intervalID);<br />
super.start();<br />
}</p>
<p>}</p></blockquote>
<p>This was more or less a simple copy of the class I had found. I got a chance to look at this again today and realized I could simplify it a bit. I ended  up with:</p>
<blockquote><p>/**<br />
* @author Jeremy Wischusen<br />
* This class allows for a delay before starting the animation.<br />
*/<br />
import mx.transitions.Tween;<br />
import mx.utils.Delegate;<br />
class com.vfd.animation.tweens.DelayedTween extends Tween {<br />
/*<br />
Holds the number of seconds to wait before starting the animation.<br />
*/<br />
private var _delay:Number = 0;<br />
/*<br />
Instance variable holding a reference to the start function of the Tween class.<br />
This is needed due to scoping issues when using setTimeout.<br />
*/<br />
private var superStart:Function;<br />
public function DelayedTween(object, property, easingFunction, start, end, duration, useSeconds, delay) {<br />
this.delay = delay;<br />
/*Use the Delegate class to create a reference back to the tween start funciton<br />
that can be used with setTimeout. */<br />
this.superStart = Delegate.create(super, super.start);<br />
super(object,property,easingFunction,start,end,duration,useSeconds);<br />
}<br />
/*Override the default start function so that the delay can be applied.*/<br />
public function start() {<br />
if (this._delay&gt;0) {<br />
_global.setTimeout(this.superStart,this._delay);<br />
} else {<br />
super.start();<br />
}<br />
}<br />
/*Setter function for delay attribute*/<br />
public function set delay(seconds:Number){<br />
this._delay = Math.abs(seconds*1000);<br />
}<br />
}</p></blockquote>
<p>As you can see, I reduced the number of functions, used the simpler setTimeOut and rely more on inheritance and overriding than in the previous version. I also decided to make and AS3 version.</p>
<blockquote><p>package com.vfd.animation.tweens{<br />
import fl.transitions.Tween;<br />
import flash.utils.setTimeout;<br />
/**<br />
* @author Jeremy Wischusen<br />
* This class allows for a delay before starting the animation.<br />
*/<br />
public class DelayedTween extends Tween {<br />
/*<br />
Holds the number of seconds to wait before starting the animation.<br />
*/<br />
private var _delay:Number = 0;<br />
public function DelayedTween(object, property, easingFunction, start, end, duration, useSeconds, delay) {<br />
this.delay = delay ;<br />
super(object,property,easingFunction,start,end,duration,useSeconds);<br />
}<br />
/*Override the default start function so that the delay can be applied.*/<br />
public override function start():void {<br />
if (this._delay&gt;0) {<br />
setTimeout(super.start,this._delay);<br />
} else {<br />
super.start();<br />
}<br />
}<br />
/*Setter function for delay attribute*/<br />
public function set delay(seconds:Number):void {<br />
this._delay = Math.abs(seconds*1000);<br />
}<br />
}<br />
}</p></blockquote>
<p>I have noticed that occasionally the compiler spits out:<br />
<em>The superconstructor must be called first in the constructor body.</em></p>
<p>If you place the super constructor before the delay variable is set, the tween just starts immediately since the variable has a default value of 0. This is what caused the need for the additional functions in the first version. While the compiler may occasionally complain (sometimes it shows the message and other times it does not), it still compiles and works.</p>
<p>Will be committing these to the repository on Google code sometime today.</p>
]]></content:encoded>
			<wfw:commentRss>http://visualflowdesigns.com/2008/08/15/hold-on-a-second/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
