<?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>Soulwire &#187; Interface</title>
	<atom:link href="http://blog.soulwire.co.uk/tag/interface/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.soulwire.co.uk</link>
	<description>Art + Technology</description>
	<lastBuildDate>Mon, 21 Mar 2011 22:27:20 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Simple Flash GUI Tool</title>
		<link>http://blog.soulwire.co.uk/code/actionscript-3/simple-flash-prototype-gui-tool</link>
		<comments>http://blog.soulwire.co.uk/code/actionscript-3/simple-flash-prototype-gui-tool#comments</comments>
		<pubDate>Wed, 19 Jan 2011 17:32:24 +0000</pubDate>
		<dc:creator>Soulwire</dc:creator>
				<category><![CDATA[Actionscript 3.0]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Lab]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[Interface]]></category>

		<guid isPermaLink="false">http://blog.soulwire.co.uk/?p=1242</guid>
		<description><![CDATA[Update: Keith himself has been working on a similar idea and has released MinimalConfigurator. Keith Peter&#8217;s Minimal Components are an excellent tool for any Flash developer when it comes to adding realtime configuration to a SWF. I find myself using them a lot in my demos and prototypes but for sketches with many editable parameters [...]


Related posts:<ol><li><a href='http://blog.soulwire.co.uk/code/open-source/as3-drag-drop-shuffle-grid-menu' rel='bookmark' title='Permanent Link: AS3 Shuffle Grid Class'>AS3 Shuffle Grid Class</a></li>
<li><a href='http://blog.soulwire.co.uk/code/actionscript-3/as3-group94-style-scrolling-menu' rel='bookmark' title='Permanent Link: AS3 Group94 Menu'>AS3 Group94 Menu</a></li>
<li><a href='http://blog.soulwire.co.uk/code/actionscript-3/webcam-motion-detection-tracking' rel='bookmark' title='Permanent Link: AS3 Webcam Motion Tracking'>AS3 Webcam Motion Tracking</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p><a href="http://blog.soulwire.co.uk/wp-content/uploads/2011/01/SimpleGUIDemo.swf" rel="lightbox;width=850;height=550;" ><img src="http://blog.soulwire.co.uk/wp-content/uploads/2011/01/simplegui.jpg" alt="Simple AS3 GUI" title="Simple AS3 GUI"/></a></p>
<blockquote><p>Update: Keith himself has been working on a similar idea and has released <a rel="nofollow" href="http://blog.soulwire.co.uk//goto/http://www.bit-101.com/blog/?p=2961/"  target="_blank">MinimalConfigurator</a>.</p></blockquote>
<p>Keith Peter&#8217;s <a rel="nofollow" href="http://blog.soulwire.co.uk//goto/http://www.minimalcomps.com/"  target="_blank">Minimal Components</a> are an excellent tool for any Flash developer when it comes to adding realtime configuration to a SWF. I find myself using them a lot in my demos and prototypes but for sketches with many editable parameters it&#8217;s still a hassle writing boilerplate code to set up and arrange the components, as well as adding the appropriate event handlers.</p>
<p>Inspired by GUI tools for OpenFrameworks such as <a rel="nofollow" href="http://blog.soulwire.co.uk//goto/https://github.com/memo/msalibs/tree/master/ofxSimpleGuiToo"  target="_blank">ofxSimpleGuiToo</a> and <a rel="nofollow" href="http://blog.soulwire.co.uk//goto/http://www.roxlu.com/of/ofxtweakbar"  target="_blank">ofxTweakbar</a>, and <a rel="nofollow" href="http://blog.soulwire.co.uk//goto/http://www.sojamo.de/libraries/controlP5/"  target="_blank">ControlP5</a> for Processing; I thought it was time to have an equally fast and easy to use GUI tool for Flash AS3 projects.<span id="more-1242"></span></p>
<h3>Introducing SimpleGUI</h3>
<p>SimpleGUI is a single Class utility designed for AS3 projects where a developer needs to quickly add UI controls for variables or functions to a sketch. Properties can be controlled with just one line of code using a variety of components from the fantastic <a rel="nofollow" href="http://blog.soulwire.co.uk//goto/http://www.minimalcomps.com/"  target="_blank">Minimal Comps</a> set, as well as custom components written for SimpleGUI such as the <strong>FileChooser</strong>.</p>
<p>SimpleGUI Currently exposes the following methods, as well as an open <strong>addControl</strong> method where any Class definition can be passed:</p>
<ul>
<li><strong>addColumn</strong>: Starts a new column of components</li>
<li><strong>addGroup</strong>: Starts a new group of components</li>
<li><strong>addLabel</strong>: Adds a TextField for labels or instructions</li>
<li><strong>addToggle</strong>: Adds a CheckBox for Boolean values</li>
<li><strong>addButton</strong>: Adds a PushButton for triggering callbacks</li>
<li><strong>addSlider</strong>: Creates a slider for numerical values</li>
<li><strong>addRange</strong>: Creates a range slider for two numerical values</li>
<li><strong>addStepper</strong>: An alternative component to the slider for numbers</li>
<li><strong>addColour</strong>: Adds a colour picker for integers</li>
<li><strong>addComboBox</strong>: Adds a ComboBox box for any object</li>
<li><strong>addFileChooser</strong>: Allow the user to load in data</li>
<li><strong>addSaveButton</strong>: This triggers the save method for generating code</li>
</ul>
<p>Other features include:</p>
<ul>
<li><strong>HotKey</strong>: Assign a hot key for showing / hiding the GUI</li>
<li><strong>Context Menu</strong>: Toggle the GUI from a context menu item</li>
<li><strong>Message</strong>: Pulse a message to the user in the toolbar</li>
<li><strong>Show Toggle</strong>: Display a toggle when the GUI is hidden</li>
<li><strong>Save Settings</strong>: Generate AS3 code to commit your current values</li>
<ul>
<h3>Using SimpleGUI</h3>
<p>Each method takes an optional parameter called <strong>options</strong>, which is simply a dynamic Object from which you can pass values for any parameter the corresponding component has, as well as <strong>callback</strong> and <strong>callbackParams</strong> properties for triggering methods each time the component changes.</p>
<p>For example, to create a Slider for controlling a Number, set it&#8217;s width, execute a callback and display a custom label, you would write:</p>
<pre>
_gui.addSlider("myNumber", 0, 100, {label:"My Number", width:200, callback:onNumberChanged});
</pre>
<p>Although you can pass custom labels to each component, omitting this parameter will simply cause the variable name to be parsed and used as the label. For example, a variable called <em>&#8216;myNumber&#8217;</em> will generate the label <em>&#8216;My Number&#8217;</em>.</p>
<p>SimpleGUI also supports nested properties, to any depth, using normal dot syntax. So you could control a particle&#8217;s position by writing:</p>
<pre>
_gui.addSlider("myParticle.position.x", 0, 1000);
</pre>
<p>Here is the code for the <a href="http://blog.soulwire.co.uk/wp-content/uploads/2011/01/SimpleGUIDemo.swf" rel="lightbox;width=850;height=550;" >demo</a> above. <em>Only 27 lines of code to control the whole sketch.</em></p>
<pre>
_gui = new SimpleGUI(this, "Example GUI", "C");

_gui.addGroup("General Settings");
_gui.addColour("backgroundColour");
_gui.addButton("Randomise Circle Position", {callback:positionCircle, width:160});
_gui.addSaveButton();

_gui.addColumn("Noise Options");
_gui.addSlider("noiseBase.x", 10, 200);
_gui.addSlider("noiseBase.y", 10, 200);
_gui.addSlider("noiseSeed", 1, 1000);
_gui.addSlider("noiseOctaves", 1, 4);
_gui.addSlider("turbulence.x", -10, 10);
_gui.addSlider("turbulence.y", -10, 10);

_gui.addGroup("Wave Options");
_gui.addStepper("waveCount", 1, 20);
_gui.addStepper("waveSteps", 2, MAX_WAVE_STEPS);
_gui.addSlider("amplitude", 0, 200);
_gui.addColour("waveColour");

_gui.addColumn("Circle Options");
_gui.addRange("minCircleSize", "maxCircleSize", 10, 120, {label:"Circle Size Range"});
_gui.addSlider("rotationSpeed", -10, 10);
_gui.addComboBox("circle.blendMode", [

	{label:"Normal",	data:BlendMode.NORMAL},
	{label:"Darken",	data:BlendMode.DARKEN},
	{label:"Overlay",	data:BlendMode.OVERLAY},
	{label:"Difference",	data:BlendMode.DIFFERENCE},

]);

_gui.addFileChooser("Circle Texture", textureFileRef, textureLoaded, [
	new FileFilter("Image Files", "*.jpg;*.jpeg;*.png")
]);

_gui.addToggle("animateCircle");

_gui.addColumn("Instructions:");
_gui.addLabel("Press 'C' to toggle GUI");
_gui.addLabel("Press 'S' to copy setup code to clipboard");

_gui.show();
</pre>
<p>So, SimpelGUI is really just a timesaver for developers looking to quickly prototype something in Flash, or for releasing demos with controls. The actual hard work has been done by <a rel="nofollow" href="http://blog.soulwire.co.uk//goto/http://www.bit-101.com/"  target="_blank">Keith</a> in building and maintaining his deservedly popular <a rel="nofollow" href="http://blog.soulwire.co.uk//goto/hhttp://www.minimalcomps.com/"  target="_blank">Minimal Comps</a>.</p>
<p>You can browse the <a rel="nofollow" href="http://blog.soulwire.co.uk//goto/http://github.com/soulwire/SoulwireAS3Framework/blob/master/src/uk/co/soulwire/gui/SimpleGUI.as/"  target="_blank">source code</a> or download the <strong>SimpleGUI</strong> class below. SimpleGUI is part of the <a rel="nofollow" href="http://blog.soulwire.co.uk//goto/https://github.com/soulwire/SoulwireAS3Framework"  target="_blank" title="Soulwire AS3 Framework">Soulwire AS3 Framework</a>.</p>
<a href="http://blog.soulwire.co.uk/wp-content/plugins/download-monitor/download.php?id=SimpleGUI.zip" class="download" title="SimpleGUI: AS3 utility class for easily creating GUIs for prototypes and demos"  rel="nofollow"><strong>Download:</strong> SimpleGUI</a>


<p>Related posts:<ol><li><a href='http://blog.soulwire.co.uk/code/open-source/as3-drag-drop-shuffle-grid-menu' rel='bookmark' title='Permanent Link: AS3 Shuffle Grid Class'>AS3 Shuffle Grid Class</a></li>
<li><a href='http://blog.soulwire.co.uk/code/actionscript-3/as3-group94-style-scrolling-menu' rel='bookmark' title='Permanent Link: AS3 Group94 Menu'>AS3 Group94 Menu</a></li>
<li><a href='http://blog.soulwire.co.uk/code/actionscript-3/webcam-motion-detection-tracking' rel='bookmark' title='Permanent Link: AS3 Webcam Motion Tracking'>AS3 Webcam Motion Tracking</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.soulwire.co.uk/code/actionscript-3/simple-flash-prototype-gui-tool/feed</wfw:commentRss>
		<slash:comments>39</slash:comments>
		</item>
		<item>
		<title>AS3 Shuffle Grid Class</title>
		<link>http://blog.soulwire.co.uk/code/open-source/as3-drag-drop-shuffle-grid-menu</link>
		<comments>http://blog.soulwire.co.uk/code/open-source/as3-drag-drop-shuffle-grid-menu#comments</comments>
		<pubDate>Wed, 04 Mar 2009 00:50:47 +0000</pubDate>
		<dc:creator>Soulwire</dc:creator>
				<category><![CDATA[Actionscript 3.0]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Lab]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[Experiments]]></category>
		<category><![CDATA[Interactive]]></category>
		<category><![CDATA[Interface]]></category>

		<guid isPermaLink="false">http://blog.soulwire.co.uk/?p=311</guid>
		<description><![CDATA[Drag &#38; Drop the images to shuffle them around&#8230; A friend of mine, Dale Sattler over at No Ponies recently posted a grid sorting class. He said it was based on my old dynamic stacking menu; but that was pure modesty as his script is based on a 2D grid and much more sophisticated. Anyway [...]


Related posts:<ol><li><a href='http://blog.soulwire.co.uk/laboratory/flash/2d-cellular-automata' rel='bookmark' title='Permanent Link: 2D Cellular Automata'>2D Cellular Automata</a></li>
<li><a href='http://blog.soulwire.co.uk/code/actionscript-3/webcam-motion-detection-tracking' rel='bookmark' title='Permanent Link: AS3 Webcam Motion Tracking'>AS3 Webcam Motion Tracking</a></li>
<li><a href='http://blog.soulwire.co.uk/code/open-source/two-sided-planes-in-flash-player-10' rel='bookmark' title='Permanent Link: Double Sided 3D Plane in FP10'>Double Sided 3D Plane in FP10</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p><a href="http://blog.soulwire.co.uk/wp-content/uploads/2009/03/shuffle-grid.swf" title="Drag the images to shuffle grid" rel="lightbox;width=800;height=500" ><img class="alignnone size-full wp-image-534" title="Shuffle Grid Demo" src="http://blog.soulwire.co.uk/wp-content/uploads/2009/03/shuffle-grid.jpg" alt="Shuffle Grid Demo" width="710" height="325" /></a></p>
<p><strong><em>Drag &amp; Drop</em></strong><em> the images to shuffle them around&#8230;</em><span id="more-311"></span></p>
<p>A friend of mine, <strong>Dale Sattler</strong> over at <a rel="nofollow" href="http://blog.soulwire.co.uk//goto/http://www.blog.noponies.com/"  target="_blank">No Ponies</a> recently posted a <a rel="nofollow" href="http://blog.soulwire.co.uk//goto/http://www.blog.noponies.com/archives/246"  target="_blank">grid sorting class</a>. He said it was based on my old <a href="http://blog.soulwire.co.uk/code/open-source/dynamic-stacking" title="Dynamic Stacking Menu" >dynamic stacking menu</a>; but that was pure modesty as his script is based on a 2D grid and much more sophisticated.</p>
<p>Anyway &#8211; it inspired me to create a <strong>grid sorting / shuffling algorithm</strong> of my own. It behaves differently to Dales but I think it works pretty well.</p>
<p>The basic logic of the algorithm works by determining how far a dragged item travels along the grid (rows and columns) and then shuffling the surrounding items in the opposite direction by these values, therefore creating space for the dragged item to slot into when released.</p>
<p>It currently only works for grids which are fully populated, but adding more flexibility for incomplete grids will only be a matter of adding a few conditions &#8211; functionality which I’ll add when I get a moment.</p>
<p>You can extend the <strong>ShuffleGridItem</strong> class to add the functionality you need. In the demo I’ve made a simple image class which grabs a photo from <a rel="nofollow" href="http://blog.soulwire.co.uk//goto/http://www.flickr.com/"  target="_blank">Flickr</a>.</p>
<p>Creating a <strong>ShuffleGrid</strong> is very simple, and can be done like so:</p>
<pre lang="actionscript">var grid:ShuffleGrid = new ShuffleGrid(4,7,40,40,1);

for (var i : int = 0; i &lt; grid.numCells; i++)
{
	grid.addItem (new ShuffleGridItem());
}

addChild (grid);</pre>
<p>The constructor takes the following arguments:</p>
<pre lang="actionscript">new ShuffleGrid(rows, cols, cellWidth, cellHeight, spacing);</pre>
<p>Feel free to download the class and a simple demo and have a play around. I can imagine many uses for it, so hopefully it will come in handy.</p>
<a href="http://blog.soulwire.co.uk/wp-content/plugins/download-monitor/download.php?id=shuffle-grid-demo.zip" class="download" title="Shuffle Grid Class & Demo: The source code and example implementation of a grid interface with drag & drop functionality and an intelligent shuffling algorithm."  rel="nofollow"><strong>Download:</strong> Shuffle Grid Class & Demo</a>


<p>Related posts:<ol><li><a href='http://blog.soulwire.co.uk/laboratory/flash/2d-cellular-automata' rel='bookmark' title='Permanent Link: 2D Cellular Automata'>2D Cellular Automata</a></li>
<li><a href='http://blog.soulwire.co.uk/code/actionscript-3/webcam-motion-detection-tracking' rel='bookmark' title='Permanent Link: AS3 Webcam Motion Tracking'>AS3 Webcam Motion Tracking</a></li>
<li><a href='http://blog.soulwire.co.uk/code/open-source/two-sided-planes-in-flash-player-10' rel='bookmark' title='Permanent Link: Double Sided 3D Plane in FP10'>Double Sided 3D Plane in FP10</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.soulwire.co.uk/code/open-source/as3-drag-drop-shuffle-grid-menu/feed</wfw:commentRss>
		<slash:comments>63</slash:comments>
		</item>
		<item>
		<title>AS3 G94 Circular Menu</title>
		<link>http://blog.soulwire.co.uk/code/actionscript-3/as3-g94-circular-menu</link>
		<comments>http://blog.soulwire.co.uk/code/actionscript-3/as3-g94-circular-menu#comments</comments>
		<pubDate>Thu, 06 Nov 2008 16:29:40 +0000</pubDate>
		<dc:creator>Soulwire</dc:creator>
				<category><![CDATA[Actionscript 3.0]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Experiments]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Interactive]]></category>
		<category><![CDATA[Interface]]></category>

		<guid isPermaLink="false">http://blog.soulwire.co.uk/?p=214</guid>
		<description><![CDATA[I’ve received quite a few requests to update my circular group94 style menu to AS3 (I’m not really sure why I’m still calling it a &#8220;Group94 menu&#8221;, but it&#8217;s a tribute to them that this style of scrolling navigation is often referred to as a &#8220;group94 menu&#8221; and not an &#8220;offset scrolling menu&#8221; or something [...]


Related posts:<ol><li><a href='http://blog.soulwire.co.uk/code/actionscript-3/as3-group94-style-scrolling-menu' rel='bookmark' title='Permanent Link: AS3 Group94 Menu'>AS3 Group94 Menu</a></li>
<li><a href='http://blog.soulwire.co.uk/code/circular-group94-scrolling-flash-menu' rel='bookmark' title='Permanent Link: G94 Circular Menu'>G94 Circular Menu</a></li>
<li><a href='http://blog.soulwire.co.uk/code/group94-flash-scrolling-menu-list' rel='bookmark' title='Permanent Link: Group94 Style Menu'>Group94 Style Menu</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p><a href="http://blog.soulwire.co.uk/wp-content/uploads/2008/11/circular-menu-as3.swf" title="AS3 Circular Group94 Menu" rel="lightbox;width=700;height=450;" ><img class="alignnone size-full wp-image-574" title="AS3 Circular Group94 Style Flash Menu" src="http://blog.soulwire.co.uk/wp-content/uploads/2008/11/g94-circular-menu.jpg" alt="AS3 Circular Group94 Style Flash Menu" width="710" height="223" /></a></p>
<p>I’ve received quite a few requests to update my <a href="http://blog.soulwire.co.uk/code/circular-group94-scrolling-flash-menu" title="Circular group94 style menu" >circular group94 style menu</a> to AS3 <span id="more-214"></span>(I’m not really sure why I’m still calling it a &#8220;Group94 menu&#8221;, but it&#8217;s a tribute to them that this style of scrolling navigation is often referred to as a &#8220;group94 menu&#8221; and not an &#8220;offset scrolling menu&#8221; or something of that nature).</p>
<p>Anyway, I have been thinking for some time that I should revisit this script and build a more complete version, where horizontal, vertical or circular are simply parameters for the menu, but for now, this is both an update and a massive enhancement of the <a href="http://blog.soulwire.co.uk/code/circular-group94-scrolling-flash-menu" title="Circular group94 style menu" >AS2 G94 circular menu.</a></p>
<p>If you play with the demo, you’ll notice I’ve added some new features, such as the ability to easily change (at runtime of desired) aspects of the menu like the <em>inner radius</em>, <em>item spacing</em>, <em>visible items</em> and much more.</p>
<p>The other big enhancement is that the <em>CircularMenu </em>class actually overrides the <em>addChild</em>, <em>addChildAt</em>, <em>setChildIndex</em>, <em>removeChild </em>(etc) methods, so if you treat it as a regular <em>DisplayObjectContainer </em>and add children to it, these items will be treated as menu items and automatically scroll -cool! This also means that you can easily change an items index, or insert and remove items dynamically, all using the standard <em>DisplayObjectContainer </em>API. The benefit of this is that you can use any <em>DisplayObject </em>as a menu item; <em>Bitmaps</em>, <em>Sprites </em>and <em>Movieclips</em>, so there is no limit to what you can put into the menu – you can even mix it up and add custom classes or library items.</p>
<p>There are also some easy methods for scrolling the menu. For example:</p>
<pre lang="actionscript">// Will scroll the menu to item 4
myCircleMenu.currentIndex = 4;

// Similar to above, scrolls the menu to a given index
myCircleMenu.scrollToIndex(  10  );

// Scrolls the menu to any given child DisplayObject
myCircleMenu.scrollToItem(  someDisplayObject  );

// Scrolls the menu to the next available item
myCircleMenu.next();

// Scrolls the menu to the previous item
myCircleMenu.prev();</pre>
<p>Additionally, there are getters and setters for the properties I mentioned earlier, such as <strong>innerRadius</strong>, <strong>itemSpacing</strong>, <strong>visibleItems </strong>etc, which will dynamically tween the menu to whatever you set one of these properties to.</p>
<a href="http://blog.soulwire.co.uk/wp-content/plugins/download-monitor/download.php?id=as3-g94-circular-menu.zip" class="download" title="Group94 Style Circular Menu: A circular, Group94 inspired interface with AS3 source code and examples of use."  rel="nofollow"><strong>Download:</strong> Group94 Style Circular Menu</a>
<p>Enjoy!</p>


<p>Related posts:<ol><li><a href='http://blog.soulwire.co.uk/code/actionscript-3/as3-group94-style-scrolling-menu' rel='bookmark' title='Permanent Link: AS3 Group94 Menu'>AS3 Group94 Menu</a></li>
<li><a href='http://blog.soulwire.co.uk/code/circular-group94-scrolling-flash-menu' rel='bookmark' title='Permanent Link: G94 Circular Menu'>G94 Circular Menu</a></li>
<li><a href='http://blog.soulwire.co.uk/code/group94-flash-scrolling-menu-list' rel='bookmark' title='Permanent Link: Group94 Style Menu'>Group94 Style Menu</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.soulwire.co.uk/code/actionscript-3/as3-g94-circular-menu/feed</wfw:commentRss>
		<slash:comments>73</slash:comments>
		</item>
		<item>
		<title>AS3 Group94 Menu</title>
		<link>http://blog.soulwire.co.uk/code/actionscript-3/as3-group94-style-scrolling-menu</link>
		<comments>http://blog.soulwire.co.uk/code/actionscript-3/as3-group94-style-scrolling-menu#comments</comments>
		<pubDate>Wed, 24 Oct 2007 13:46:03 +0000</pubDate>
		<dc:creator>Soulwire</dc:creator>
				<category><![CDATA[Actionscript 3.0]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Interactive]]></category>
		<category><![CDATA[Interface]]></category>

		<guid isPermaLink="false">http://blog.soulwire.co.uk/?p=45</guid>
		<description><![CDATA[Welcome to the latest instalment of the Group 94 style scrolling menu tutorial! (With downloadable source files of course) I have been very busy lately, and haven’t had a chance to share much code. I have been learning AS3 and have to say that I love it! It is much easier to adhere to OOP [...]


Related posts:<ol><li><a href='http://blog.soulwire.co.uk/code/actionscript-3/as3-g94-circular-menu' rel='bookmark' title='Permanent Link: AS3 G94 Circular Menu'>AS3 G94 Circular Menu</a></li>
<li><a href='http://blog.soulwire.co.uk/code/open-source/as3-drag-drop-shuffle-grid-menu' rel='bookmark' title='Permanent Link: AS3 Shuffle Grid Class'>AS3 Shuffle Grid Class</a></li>
<li><a href='http://blog.soulwire.co.uk/code/group94-flash-scrolling-menu-list' rel='bookmark' title='Permanent Link: Group94 Style Menu'>Group94 Style Menu</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p><a href="http://blog.soulwire.co.uk/wp-content/uploads/2007/10/g94as3.swf" title="Group94 Style AS3 Menu" rel="lightbox;width=800;height=550;" ><img class="alignnone size-full wp-image-810" title="AS3 Group94 Style Menu" src="http://blog.soulwire.co.uk/wp-content/uploads/2007/10/g94-menu.jpg" alt="AS3 Group94 Style Menu" width="710" height="326" /></a></p>
<p>Welcome to the latest instalment of the Group 94 style scrolling menu tutorial! (With <a href="http://blog.soulwire.co.uk/wp-content/plugins/download-monitor/download.php?id=as3-g94-menu.zip" title="Download AS3 Group 94 style scrolling menu FLA source code" >downloadable source files</a> of course)<span id="more-45"></span></p>
<p>I have been very busy lately, and haven’t had a chance to share much code. I have been learning AS3 and have to say that I love it! It is much easier to adhere to OOP principles and building class based applications has many advantages.</p>
<p>Anyway, I received an email today from Adriaan, who was wondering how to convert the <a href="http://blog.soulwire.co.uk/code/group94-flash-scrolling-menu-list" title="Group 94 scrolling list menu" >Group94 scrolling list</a> into a menu system, with rollovers and click functions. I hacked the old source to do this, but thought it would be a good opportunity to revisit the ‘offset scroll’ idea within the contexts of a fully functional scrolling menu.</p>
<p>So here it is. I have built it into a simple class, which means you need to do very little to get it working  :)</p>
<p>The class is very flexible, and you can assign functions and parameters to each menu item that you add. This can mean calling the same function with different parameters, or entirely different functions for each item.</p>
<p>Adding menu items is as brilliantly simple as <strong>newMenuItem(<em>label</em>, <em>function</em>, <em>parameters</em>)</strong></p>
<p>You can <a href="http://blog.soulwire.co.uk/wp-content/plugins/download-monitor/download.php?id=as3-g94-menu.zip" title="Download AS3 Group 94 style scrolling menu FLA source code" >download the source code</a> and pick it apart all you like. However, here is a quick explanation of how to use the G94Menu class.</p>
<p>Firstly we import the classes:</p>
<pre lang="actionscript">import com.soulwire.g94menu.G94Menu;
import com.soulwire.g94menu.MenuItem;</pre>
<p><em>MenuItem</em><strong> </strong>is linked to a movieClip in you library, so you can use <strong><em>any style of menu item you like</em></strong>.</p>
<p>Now, we create a new instance of the G94Menu class and add it to the stage.</p>
<pre lang="actionscript">exampleMenu = new G94Menu(3, 1, 25);
addChild(exampleMenu);</pre>
<p>The parameters the class constructor requires are:</p>
<ul>
<li><strong>Visible items</strong>: The amount of items visible at one time<strong></strong></li>
<li><strong>Item spacing</strong>: The gap between each item<strong></strong></li>
<li><strong>Item offset</strong>: How far the items scroll up or down as they fly off to the top or bottom</li>
</ul>
<p>Then we simply add as many items as we want using the <em>new MenuItem</em> constructor, for example:</p>
<pre lang="actionscript">myMenu.addItem(new MenuItem('Text', func, { params } ))</pre>
<p>Here is a breakdown of the parameters you pass to the <em>MenuItem </em>constructor inside the<em> addItem </em>method:</p>
<ul>
<li><strong>Item label</strong>: A text string which will be the visible label of the item</li>
<li><strong>Function</strong>: This is optional, but if present will make the item a clickable button, executing this function when clicked.</li>
<li><strong>Parameters</strong>: This is an object containing as many parameters as you need. Again, this parameter is optional, and only needed if you have passed a function and it requires parameters.</li>
</ul>
<p>Now we create a function that will be called when a menu item is clicked:</p>
<pre lang="actionscript">function someFunction (e:MouseEvent)
{
	if(e.currentTarget.params != null)
	{
		var info:Object = e.currentTarget.params;
		trace(info.page);
	}
}</pre>
<p>In this example, we check that the parameters are not null, then access the parameters object using <em>e.currentTarget.params</em>. If your function will open a link (for example), and you pass a URL identified in the parameters object as <em>pageLink</em>, then you can use this by calling <em>e.currentTarget.params.pageLink</em>.</p>
<p>Lastly, to listen for mouse clicks on the scroll arrows, and to enable the <strong>mouse wheel</strong>, both of which will scroll our menu up or down, we add some event listeners:</p>
<pre lang="actionscript">function enableScrolling():void
{
	btnUp.buttonMode = btnDown.buttonMode = true;
	btnUp.addEventListener(MouseEvent.CLICK, exampleMenu.scrollUp);
	btnDown.addEventListener(MouseEvent.CLICK, exampleMenu.scrollDown);
	stage.addEventListener(MouseEvent.MOUSE_WHEEL, onMouseWheel);
}

function onMouseWheel(e:MouseEvent):void
{
	e.delta &lt;0 ? exampleMenu.scrollDown() : exampleMenu.scrollUp();
}</pre>
<p>The <em><strong>scrollUp</strong></em> and <em><strong>scrollDown</strong></em> methods can be called whenever you like (i.e. remotely) on any instance of the G94Menu class.</p>
<p>Once again, I really hope this is useful, even if it is just a simple introduction to Actionscript 3 and writing classes.</p>
<p>Thanks to Adriaan and all of you who have been commenting for inspiring me to update this example.</p>
<p>If anyone wants to use this in older projects, and needs an AS2 version, please let me know and I’ll convert it when I get the time.</p>
<a href="http://blog.soulwire.co.uk/wp-content/plugins/download-monitor/download.php?id=as3-g94-menu.zip" class="download" title="AS3 Group94 Menu: A Group94 inspired menu system written in AS3 with source code and example implementation."  rel="nofollow"><strong>Download:</strong> AS3 Group94 Menu</a>


<p>Related posts:<ol><li><a href='http://blog.soulwire.co.uk/code/actionscript-3/as3-g94-circular-menu' rel='bookmark' title='Permanent Link: AS3 G94 Circular Menu'>AS3 G94 Circular Menu</a></li>
<li><a href='http://blog.soulwire.co.uk/code/open-source/as3-drag-drop-shuffle-grid-menu' rel='bookmark' title='Permanent Link: AS3 Shuffle Grid Class'>AS3 Shuffle Grid Class</a></li>
<li><a href='http://blog.soulwire.co.uk/code/group94-flash-scrolling-menu-list' rel='bookmark' title='Permanent Link: Group94 Style Menu'>Group94 Style Menu</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.soulwire.co.uk/code/actionscript-3/as3-group94-style-scrolling-menu/feed</wfw:commentRss>
		<slash:comments>49</slash:comments>
		</item>
		<item>
		<title>G94 Circular Menu</title>
		<link>http://blog.soulwire.co.uk/code/circular-group94-scrolling-flash-menu</link>
		<comments>http://blog.soulwire.co.uk/code/circular-group94-scrolling-flash-menu#comments</comments>
		<pubDate>Tue, 07 Aug 2007 12:54:16 +0000</pubDate>
		<dc:creator>Soulwire</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Interactive]]></category>
		<category><![CDATA[Interface]]></category>

		<guid isPermaLink="false">http://blog.soulwire.co.uk/?p=42</guid>
		<description><![CDATA[I built this circular version of the group94 style scrolling menu for a flash website awards showcase I was asked to work on. The original design was based around circles, but we ended up redesigning as parts of the interface (not this menu!) were too processor intensive. Ok, so part two of my tribute to [...]


Related posts:<ol><li><a href='http://blog.soulwire.co.uk/code/group94-flash-scrolling-menu-list' rel='bookmark' title='Permanent Link: Group94 Style Menu'>Group94 Style Menu</a></li>
<li><a href='http://blog.soulwire.co.uk/code/actionscript-3/as3-g94-circular-menu' rel='bookmark' title='Permanent Link: AS3 G94 Circular Menu'>AS3 G94 Circular Menu</a></li>
<li><a href='http://blog.soulwire.co.uk/code/actionscript-array-count-values' rel='bookmark' title='Permanent Link: AS2 Array count values'>AS2 Array count values</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p><a href="http://blog.soulwire.co.uk/wp-content/uploads/2007/08/soulwire-circ-nav.swf" title="Group94 Style Circular Menu" rel="lightbox;width=800;height=550;" ><img class="alignnone size-medium wp-image-819" title="Group94 Circular Menu" src="http://blog.soulwire.co.uk/wp-content/uploads/2007/08/g94-circ-nav-710x325.jpg" alt="Group94 Circular Menu" width="710" height="325" /></a><br />
<a href="http://blog.soulwire.co.uk/wp-content/plugins/download-monitor/download.php?id=as2-g94-circular-menu.zip" class="download" title="AS2 Group94 Circular Menu: An AS2 circular menu prototype based on some of the fantastic Group94 interfaces."  rel="nofollow"><strong>Download:</strong> AS2 Group94 Circular Menu</a></p>
<p>I built this circular version of the <a href="http://blog.soulwire.co.uk/code/group94-flash-scrolling-menu-list" title="Group 94 style scrolling menu system in Flash" >group94 style scrolling menu</a> for a flash website awards showcase I was asked to work on. The original design was based around circles, but we ended up redesigning as parts of the interface (not this menu!) were too processor intensive.</p>
<p>Ok, so part two of my tribute to Group 94’s menu system! This is again inspired by the Group 94 (at least they are most famous for it) shuffle menu in Flash, which pushes items off the top and bottom as the menu shuffles into place.<span id="more-42"></span></p>
<p>This version is circular though, and each menu item rotates around a pivot. Initiating the prototype with particular variables will define the spacing between items, the radius of the Group 94 circular menu and the amount of items visible at one time.</p>
<p>Please note, this is in no way a rip of the Group 94 menu. In fact, I haven’t even seen a circular version which is why I made it. I have no idea how Group 94’s actionscript looks, or how they would have approached this style of menu. I do know however, that they have produced many innovative navigation systems, and so this is a simple tribute to their talent and innovation.</p>
<p>As with the regular <a href="http://blog.soulwire.co.uk/code/group94-flash-scrolling-menu-list" title="Group 94 menu actionscript" >group 94 scrolling menu</a>, you will need <a rel="nofollow" href="http://blog.soulwire.co.uk//goto/http://www.mosessupposes.com/Fuse/" title="Fuse Kit"  target="_blank">Fuse</a> installed, though all it does is handle tweening so you could use <a rel="nofollow" href="http://blog.soulwire.co.uk//goto/http://www.osflash.org/tweener" title="Tweener"  target="_blank">tweener</a> or the inbuilt Flash tweening functions. I just prefer Fuse!</p>
<p><strong>How it is done.</strong></p>
<p>First import Fuse for tweening, then setup the array we will use for the menu:</p>
<pre lang="actionscript">import com.mosesSupposes.fuse.*;
ZigoEngine.simpleSetup (Shortcuts,PennerEasing);

var planets:Array = new Array ();
planets.push ("Mercury");
planets.push ("Venus");
planets.push ("Earth");
planets.push ("Mars");
planets.push ("Jupiter");
planets.push ("Saturn");
planets.push ("Uranus");
planets.push ("Neptune");
planets.push ("Pluto");</pre>
<p>Then some very basic functionality for each menu button. I have ommited rollOvers for the demo&#8230;</p>
<pre lang="actionscript">MovieClip.prototype.circNavBtn = function (id:Number, par:MovieClip, name:String)
{
	this.pos = this.id = id;
	this.par = par;
	this.btn.txt.text = name.toUpperCase ();

	this._rotation = 90;
	this._alpha = 0;

	this.onPress = function ()
	{
		this.par.circNavRot (this.pos);
		this.activeBtn ();
	};
};</pre>
<p>Then two small prototypes to handle the activation and de-activation of the buttons when the scroll function is called:</p>
<pre lang="actionscript">MovieClip.prototype.activeBtn = function ()
{
	activeNavBtn.inactiveBtn ();
	activeNavBtn = this;

	this.btn.scaleTo (200,0.5);

	this.enabled = false;
};

MovieClip.prototype.inactiveBtn = function ()
{
	this.btn.scaleTo (100,0.5);
};</pre>
<p>Then the main shuffle or rotation function, which designates tweens to all visible movieClips and hides those outside of the visible items range.</p>
<pre lang="actionscript">MovieClip.prototype.circNavRot = function (num:Number)
{
	var diff:Number = num;

	for (var i:Number = 0; i &lt; this.btns.length; i++)
	{
		var btn:MovieClip = this["navBtn" + i];

		btn.pos -= diff;

		if (Math.abs (btn.pos) &lt; this.visItems)
		{
			var offset:Number;
			btn.pos != 0 ? (offset = btn.pos &gt; 0 ? 15 : -15) : offset = 0;

			var rot:Number = offset + (this.spacing * btn.pos);
			var alph:Number = 100 - ((100 / this.visItems) * Math.abs (btn.pos));
			var scl:Number = 100 - (5 * Math.abs (btn.pos));

			btn.rotateTo (rot,0.5,"easeOutExpo");
			btn.alphaTo (alph,0.5);
			btn.btn.scaleTo (scl,0.5);
		}
		else
		{
			btn.stopTween ("_alpha");
			btn.stopTween ("_rotation");
			btn._rotation = btn.pos &gt; 0 ? 90 : -90;
			btn._alpha = 0;
		}

		btn.enabled = Math.abs (btn.pos) &lt; this.visItems;
	}
	this["navBtn" + num].activeBtn ();
};</pre>
<p>Now we setup the circular scrolling menu on a movieClip:</p>
<pre lang="actionscript">MovieClip.prototype.circNav = function (array:Array, radius:Number, spacing:Number, visItems:Number)
{
	this.btns = new Array ();
	this.spacing = spacing;
	this.visItems = visItems;

	for (var i:Number = 0; i &lt; array.length; i++)
	{
		var navBtn:MovieClip = this.createEmptyMovieClip ("navBtn" + i, i);
		var btnTxt:MovieClip = navBtn.attachMovie ("btn", "btn", 0);
		btnTxt._x = radius;

		navBtn.circNavBtn (i,this,array[i]);
		this.btns.push (navBtn);
	}
	this.circNavRot (0);
};</pre>
<p>Here we dynamically create a movieClip, position it, then call our prototype to create the lovely Group94 style menu&#8230;</p>
<pre lang="actionscript">var testMenu:MovieClip = this.createEmptyMovieClip ("nav", 0);
testMenu._x = 20;
testMenu._y = 112;

testMenu.circNav (planets, 60, 15, 4);</pre>
<p>And finally we add the ability to use the mouse wheel to scroll the menu. otherwise we just click the menu items:</p>
<pre lang="actionscript">var mouseListener:Object = new Object ();
mouseListener.onMouseWheel = function (delta)
{
	var navIndex:Number = activeNavBtn.id;
	if (delta &lt; 0 &amp;&amp; activeNavBtn.id &lt; planets.length - 1)
	{

		testMenu.circNavRot (1);
		testMenu["navBtn" + (navIndex + 1)].activeBtn ();
	}
	else if (delta &gt; 0 &amp;&amp; activeNavBtn.id &gt; 0)
	{
		testMenu.circNavRot (-1);
		testMenu["navBtn" + (navIndex - 1)].activeBtn ();
	}
};
Mouse.addListener (mouseListener);</pre>
<p>I hope this is useful to someone! If you find a home for it, please <a href="http://blog.soulwire.co.uk/contact/" title="Contact soulwire" >let me know</a>.</p>
<a href="http://blog.soulwire.co.uk/wp-content/plugins/download-monitor/download.php?id=as2-g94-circular-menu.zip" class="download" title="AS2 Group94 Circular Menu: An AS2 circular menu prototype based on some of the fantastic Group94 interfaces."  rel="nofollow"><strong>Download:</strong> AS2 Group94 Circular Menu</a>


<p>Related posts:<ol><li><a href='http://blog.soulwire.co.uk/code/group94-flash-scrolling-menu-list' rel='bookmark' title='Permanent Link: Group94 Style Menu'>Group94 Style Menu</a></li>
<li><a href='http://blog.soulwire.co.uk/code/actionscript-3/as3-g94-circular-menu' rel='bookmark' title='Permanent Link: AS3 G94 Circular Menu'>AS3 G94 Circular Menu</a></li>
<li><a href='http://blog.soulwire.co.uk/code/actionscript-array-count-values' rel='bookmark' title='Permanent Link: AS2 Array count values'>AS2 Array count values</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.soulwire.co.uk/code/circular-group94-scrolling-flash-menu/feed</wfw:commentRss>
		<slash:comments>51</slash:comments>
		</item>
		<item>
		<title>Dynamic Stacking</title>
		<link>http://blog.soulwire.co.uk/code/open-source/dynamic-stacking</link>
		<comments>http://blog.soulwire.co.uk/code/open-source/dynamic-stacking#comments</comments>
		<pubDate>Fri, 13 Apr 2007 01:22:09 +0000</pubDate>
		<dc:creator>Soulwire</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[AS2]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Interface]]></category>

		<guid isPermaLink="false">http://blog.soulwire.co.uk/?p=31</guid>
		<description><![CDATA[Update: AS3 Version using TweenLite is available here In this experiment, you can drag the boxes; when you release them the stack will shuffle to accommodate the dropped box. I have recently been working on building an application in which I wanted to use Photoshop style ‘layers’ which the user could create, drag onto different [...]


Related posts:<ol><li><a href='http://blog.soulwire.co.uk/code/dynamic-positioning-part-two' rel='bookmark' title='Permanent Link: Dynamic Positioning Continued'>Dynamic Positioning Continued</a></li>
<li><a href='http://blog.soulwire.co.uk/code/dynamic-positioning-part-one' rel='bookmark' title='Permanent Link: Dynamic Positioning'>Dynamic Positioning</a></li>
<li><a href='http://blog.soulwire.co.uk/code/group94-flash-scrolling-menu-list' rel='bookmark' title='Permanent Link: Group94 Style Menu'>Group94 Style Menu</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p><a href="http://blog.soulwire.co.uk/wp-content/uploads/2007/04/boxes.swf" rel="lightbox;width=800;height=600;" title="Dynamic Stacking Menu" ><img src="http://blog.soulwire.co.uk/wp-content/uploads/2007/04/dynamic-stacking-710x222.jpg" alt="Flash Dynamic Stacking Menu" title="Flash Dynamic Stacking Menu" width="710" height="222" class="alignnone size-medium wp-image-849" /></a></p>
<blockquote><p>
<strong>Update:</strong> AS3 Version using TweenLite is available <a href="http://blog.soulwire.co.uk/wp-content/plugins/download-monitor/download.php?id=dynamic-stack-as3.zip"  title="Download Dynamic Stacking Menu (AS3)">here</a>
</p></blockquote>
<p><em>In this experiment, you can drag the boxes; when you release them the stack will shuffle to accommodate the dropped box.</em></p>
<p>I have recently been working on building an application in which I wanted to use Photoshop style ‘layers’ which the user could create, drag onto different depths and delete.</p>
<p>The basic idea was for the user to <strong>click and drag</strong> ‘layers’, and drop them in between others. This would cause the other layers to reposition to accommodate the new layer and to fill the gap which it had left in it’s old position. Get it?<span id="more-31"></span></p>
<p>Perhaps I’m just a bit dim, but I was surprised at how many difficulties I encountered when trying to sort the boxes or ‘layers’. I began taking the approach of calculating whether the surrounding layers were above or below, and moving them up or down accordingly; but with this approach I found that deleting layers or adding new ones caused the system to go a bit crazy.</p>
<p>As usual, it was the simple and elegant approach which eventually yielded the solution. I basically handled all of the movement from a single, straightforward array. The array was shuffled based on a nifty little prototype I wrote for extracting and reinserting elements (essentially shuffling without randomness), from which all movement calculations (i.e. the eventual positions of the shuffling boxes) could be made.</p>
<pre lang="actionscript">Array.prototype.shuffle = function (x, y)
{
	var i:Number = this.slice (x, x + 1);
	this.splice (x,1);
	this.splice (y,0,i);
};</pre>
<p>The shuffle prototype itself could be very useful, as it pulls items out of the array, and by reinserting them; muscles the other elements outwards around it – no complicated calculations needed for determining where the elements go thanks to some really basic build in Flash Actionscript features. Also, by omitting one line of code, the prototype could be used to simply insert items into an array at a particular position (<em>insertAt(value, index)</em> or something along those lines).</p>
<p>I have attached a bare bones example for you, though I assure you, you can do great things with this script. The menu I was working on will probably make an appearance on Soulwire once the program is finished. One example of its usage would be to associate each box with a layer elsewhere; for example a Stack of photos which are depth ‘shuffled’ through the easy manipulation of their affiliated boxes.</p>
<a href="http://blog.soulwire.co.uk/wp-content/plugins/download-monitor/download.php?id=dynamic-stack-as2.zip" class="download" title="Dynamic Stacking Menu (AS2): A drag & drop menu system which dynamically shuffles as elements are dragged. Source code and example included."  rel="nofollow"><strong>Download:</strong> Dynamic Stacking Menu (AS2)</a> <a href="http://blog.soulwire.co.uk/wp-content/plugins/download-monitor/download.php?id=dynamic-stack-as3.zip" class="download" title="Dynamic Stacking Menu (AS3): A drag & drop menu system which dynamically shuffles as elements are dragged. Source code and example included and update to AS3 with added features."  rel="nofollow"><strong>Download:</strong> Dynamic Stacking Menu (AS3)</a>
<p>You can download the FLA here above, but here is the basic commented code. It is simple but works quite well.</p>
<pre lang="actionscript">// Include the Zigo tweening prototypes to make life easier
#include "lmc_tween.as"

// Create the main holder for the boxes
var menu:MovieClip = this.createEmptyMovieClip ("menu", 0);
menu._x = menu._y = 20;

// Set up our Arrays and counters
var boxes:Array = new Array ();
var boxCount:Number = 0;
var boxGap:Number = 37;

/*
The core 'SHUFFLE' function
This pulls out an array item at a given index and inserts it back into the array
at another index. The other array items are consiquently 'pushed' outwards from
the element, so our new array reflects the visual appearance we want for the
shuffled menu. We can now 'sort' our menu based on this modified array...
*/
Array.prototype.shuffle = function (x, y)
{
	var i:Number = this.slice (x, x + 1);
	this.splice (x,1);
	this.splice (y,0,i);
};

// Our sort function
function sort ()
{
	var count:Number = boxes.length;
	for (var i = 0; i &lt; count; i++)
	{
		// Check which ID is at this point in the array
		var id:Number = boxes[i];
		// Find the corrosponding box
		var box:MovieClip = eval ("menu.box" + id);
		// Calculate the position the box should be at
		var y:Number = i * boxGap;
		// Alter it's id to it's new position
		box.id = i;
		// Tween it there (or just use box._y = y)
		box.tween ("_y",y,0.8,"easeInOut");
	}
}

// Creating new boxes
function addBox ()
{
/*
We use getNextHighestDepth() because of the swapDepths() function used
when the buttons are pressed. This creates new levels and so could
cause problems if we just create boxes at depths based on the length
of the boxes array.
*/
	var d:Number = menu.getNextHighestDepth ();
	var i:Number = boxCount;
	// We could use Push(), but I want the boxes stacked, with newest on top
	boxes.unshift (i);
	// Attach the box
	var box:MovieClip = menu.attachMovie ("box", "box" + i, d);
	// Initiate the box
	box.initBox (i);
	// Increase the counter
	boxCount++;
	// Sort the boxes
	sort ();
}

/*
This is a simple function which can be called to remove boxes. It splices the array and
resorts the stack accordingly.
*/
function deleteLayer (id)
{
	var box:MovieClip = eval ("menu.box" + boxes[id]);
	box.removeMovieClip ();
	boxes.splice (id,1);
	sort ();
}

// The box actions
MovieClip.prototype.initBox = function (num)
{
	this.id = num;
	this.name.text = "Box " + num;

	this.onPress = function ()
	{
		var top:Number = boxCount + 1;

		this.swapDepths (top);
		this.startDrag ();
	};

	this.onRelease = this.onReleaseOutside = function ()
	{
		this.stopDrag ();
		// Slide back to the edge
		this.tween ("_x",0,0.8,"easeInOut");
	/*
	Find the original position, and the new position, based on the
	location of the draged box in relation to the other boxes.
	*/
		var x:Number = this.id;
		var y:Number = Math.round (this._y / boxGap);
		// Call our shuffle function based on these calculations
		boxes.shuffle (x,y);
		// Sort the boxes based on our shuffled array
		sort ();
	};
};

// Add some boxes to test it!
for (var i = 0; i &lt; 5; i++)
{
	addBox ();
}</pre>


<p>Related posts:<ol><li><a href='http://blog.soulwire.co.uk/code/dynamic-positioning-part-two' rel='bookmark' title='Permanent Link: Dynamic Positioning Continued'>Dynamic Positioning Continued</a></li>
<li><a href='http://blog.soulwire.co.uk/code/dynamic-positioning-part-one' rel='bookmark' title='Permanent Link: Dynamic Positioning'>Dynamic Positioning</a></li>
<li><a href='http://blog.soulwire.co.uk/code/group94-flash-scrolling-menu-list' rel='bookmark' title='Permanent Link: Group94 Style Menu'>Group94 Style Menu</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.soulwire.co.uk/code/open-source/dynamic-stacking/feed</wfw:commentRss>
		<slash:comments>48</slash:comments>
		</item>
		<item>
		<title>Group94 Style Menu</title>
		<link>http://blog.soulwire.co.uk/code/group94-flash-scrolling-menu-list</link>
		<comments>http://blog.soulwire.co.uk/code/group94-flash-scrolling-menu-list#comments</comments>
		<pubDate>Wed, 07 Mar 2007 20:42:15 +0000</pubDate>
		<dc:creator>Soulwire</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[AS2]]></category>
		<category><![CDATA[Interface]]></category>
		<category><![CDATA[Open Source]]></category>

		<guid isPermaLink="false">http://blog.soulwire.co.uk/?p=22</guid>
		<description><![CDATA[I have always liked the neat and compact menu system Group94 often use in their projects. It is really useful for lists or menus and is also of course very elegant. I don’t know how Group94 do it, but here is my attempt. I have created two prototypes to make it easy to use multiple [...]


Related posts:<ol><li><a href='http://blog.soulwire.co.uk/code/actionscript-3/as3-group94-style-scrolling-menu' rel='bookmark' title='Permanent Link: AS3 Group94 Menu'>AS3 Group94 Menu</a></li>
<li><a href='http://blog.soulwire.co.uk/code/circular-group94-scrolling-flash-menu' rel='bookmark' title='Permanent Link: G94 Circular Menu'>G94 Circular Menu</a></li>
<li><a href='http://blog.soulwire.co.uk/code/open-source/dynamic-stacking' rel='bookmark' title='Permanent Link: Dynamic Stacking'>Dynamic Stacking</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p><a href="http://blog.soulwire.co.uk/wp-content/uploads/2007/03/group94-scroll-list.swf" rel="lightbox;width=800;height=450;" title="Group94 Style Scrolling Menu List" ><img src="http://blog.soulwire.co.uk/wp-content/uploads/2007/03/as2-group94-menu.jpg" alt="Group94 Style Menu System" title="Group94 Style Menu System" width="710" height="326" class="alignnone size-full wp-image-895" /></a></p>
<p>I have always liked the neat and compact menu system <a rel="nofollow" href="http://blog.soulwire.co.uk//goto/http://www.group94.com/" title="The awesome Group94"  target="_blank">Group94 </a>often use in their projects. It is really useful for lists or menus and is also of course very elegant.</p>
<p>I don’t know how Group94 do it, but here is my attempt. I have created two prototypes to make it easy to use multiple times within a project.</p>
<p><a href="http://blog.soulwire.co.uk/wp-content/plugins/download-monitor/download.php?id=group94-scroll-list.zip" class="download" title="Group94 Style Scrolling List: A Group94 inspired scrolling list or menu system prototype for Flash"  rel="nofollow"><strong>Download:</strong> Group94 Style Scrolling List</a><span id="more-22"></span></p>
<p>This example just uses a simple list, but the actionscript can easily be modified to make the items clickable to use as a menu system, or you could even use images. Your call!</p>
<p>The first prototype is used to create a vertical list from an array. The second is used to scroll the list depending on clicks or mouse wheel scrolling.</p>
<p>This is bare bones, so it is nice and simple and easy to build upon.</p>
<pre lang="actionscript">/*
I have used the old Zigo tweening prorotypes here, it will also work with Fuse.
Links are always good if you use it :)
*/
#include "lmc_tween.as"

MovieClip.prototype.createList = function (array, clip, visibleItems, xPos, yPos, spacing, offset)
{
	this.listItems = new Array ();

	this.total = array.length;
	this.vis = visibleItems;
	this.spacing = spacing;
	this.offset = offset;
	this._x = xPos;
	this._y = yPos;
	this.num = 1;

	for (var i = 1; i &lt;= this.total; i++)
	{
		var listItem:MovieClip = this.attachMovie (clip, "listItem" + i, i);
		listItem.yPos = i * this.spacing;
		if (i &lt;= this.vis)
		{
			listItem._y = listItem.yPos;
		}
		else
		{
			listItem._y = this.offset + (i * this.spacing);
			listItem._alpha = 0;
		}
		listItem.id = i;
		listItem.txt.text = i + ". " + array[i - 1];
		listMc.listItems[i - 1] = listItem;
	}
};

MovieClip.prototype.shuffleList = function (n)
{
	this.num += n;
	if (this.num &gt; 0 &amp;&amp; this.num &lt;= ((this.total + 1) - this.vis))
	{
		var min:Number = this.num;
		var max:Number = this.num + this.vis;
		for (var i = 1; i &lt;= this.total; i++)
		{
			var mc = this.listItems[i - 1];
			if (i &lt; min)
			{
				var Y:Number = mc.yPos - this.offset - (this.num * this.spacing);
				var alpha:Number = 0;
			}
			else if (i &gt;= max)
			{
				var Y:Number = mc.yPos + this.offset - (this.num * this.spacing);
				var alpha:Number = 0;
			}
			else
			{
				var Y:Number = mc.yPos - (this.num * this.spacing);
				var scale:Number = 100;
				var alpha:Number = 100;
			}
			mc.tween ("_y",Y,.7);
			mc.alphaTo (alpha,.7);
		}
	}
	else
	{
		this.num -= n;
	}
};

var fruits:Array = new Array ("Cornelian cherry ", "Date palm", "Fig", "Grape", "Jujube", "Black mulberry", "Olive", "Pomegranate", "Pomelo", "Grapefruit", "Lemon", "Lime", "Mandarin", "Clementine", "Tangerine", "Orange", "Avocado", "Feijoa", "Guava", "Kumquat", "Longan", "Lúcuma", "Lychee", "Passion fruit", "Pond-apple", "Strawberry guava", "Tamarillo", "Yangmei");

var listMc:MovieClip = this.createEmptyMovieClip ("listMc", 0);
listMc.createList (fruits,"listItem",5,150,40,30,20);
listMc.shuffleList (0);

prevBtn.onPress = function ()
{
	listMc.shuffleList (-1);
};
nextBtn.onPress = function ()
{
	listMc.shuffleList (+1);
};

var mouseListener:Object = new Object ();
mouseListener.onMouseWheel = function (delta)
{
	if (delta &lt; 0)
	{
		listMc.shuffleList (+1);
	}
	else
	{
		listMc.shuffleList (-1);
	}
};
Mouse.addListener (mouseListener);</pre>


<p>Related posts:<ol><li><a href='http://blog.soulwire.co.uk/code/actionscript-3/as3-group94-style-scrolling-menu' rel='bookmark' title='Permanent Link: AS3 Group94 Menu'>AS3 Group94 Menu</a></li>
<li><a href='http://blog.soulwire.co.uk/code/circular-group94-scrolling-flash-menu' rel='bookmark' title='Permanent Link: G94 Circular Menu'>G94 Circular Menu</a></li>
<li><a href='http://blog.soulwire.co.uk/code/open-source/dynamic-stacking' rel='bookmark' title='Permanent Link: Dynamic Stacking'>Dynamic Stacking</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.soulwire.co.uk/code/group94-flash-scrolling-menu-list/feed</wfw:commentRss>
		<slash:comments>34</slash:comments>
		</item>
		<item>
		<title>Dynamic Positioning</title>
		<link>http://blog.soulwire.co.uk/code/dynamic-positioning-part-one</link>
		<comments>http://blog.soulwire.co.uk/code/dynamic-positioning-part-one#comments</comments>
		<pubDate>Wed, 27 Sep 2006 15:43:04 +0000</pubDate>
		<dc:creator>Soulwire</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[AS2]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Interface]]></category>

		<guid isPermaLink="false">http://blog.soulwire.co.uk/?p=8</guid>
		<description><![CDATA[Since fullscreen flash websites have become so popular; this little trick (a necessity really) has been used to make sure that no matter what screen resolution a user has, they can experience the site in the way in which the designer intended. I realise that listeners are common knowledge, but I have had a lot [...]


Related posts:<ol><li><a href='http://blog.soulwire.co.uk/code/dynamic-positioning-part-two' rel='bookmark' title='Permanent Link: Dynamic Positioning Continued'>Dynamic Positioning Continued</a></li>
<li><a href='http://blog.soulwire.co.uk/code/open-source/dynamic-stacking' rel='bookmark' title='Permanent Link: Dynamic Stacking'>Dynamic Stacking</a></li>
<li><a href='http://blog.soulwire.co.uk/code/actionscript-3/fit-a-displayobject-into-a-rectangle' rel='bookmark' title='Permanent Link: Fit DisplayObject into Rectangle'>Fit DisplayObject into Rectangle</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p><img src="http://blog.soulwire.co.uk/wp-content/uploads/2006/09/soulwire-v2-interface.jpg" alt="Soulwire V2 Interface" title="Soulwire V2 Interface" width="710" height="223" class="alignnone size-full wp-image-908" /></p>
<p>Since fullscreen flash websites have become so popular; this little trick (a necessity really) has been used to make sure that no matter what screen resolution a user has, they can experience the site in the way in which the designer intended.</p>
<p>I realise that listeners are common knowledge, but I have had a lot of emails asking about <strong>dynamic positioning</strong> so I have written this brief tutorial on how to get all the elements in your Flash movie to position themselves automatically when the user&#8217;s browser window resizes, or if they are using a different screen resolution to you and you hate the idea of letting the movie scale!<span id="more-12"></span></p>
<p>The principal is simple, like in CSS with fluid layouts, you effectivelly position everything relitively, and write some simple formulas for maintaining their relitivity no matter what size stage they are on.</p>
<p>You can also apply this to the height and width of, for example, the background of a banner, so that your pixel font still looks crisp and nicely aligned as the bar behind is stretching to fit the window. The permutations are endless, and evidently, this is a really useful and basic tool to have when putting together a Flash site. I have even used it for CD Business Card presentations, to make sure text areas and graphics sit nicely in harmony with each other, even if it found its way into the grubbly hands of an 800 x 600 user.</p>
<p>Anyway, the code &#8211; Just paste this into the Actionscript panel, render and enjoy. Drag the movie&#8217;s resize handles around for some orgasmic repositioning pleasure:</p>
<pre lang="actionscript" line="1">// Setup the Stage properties
Stage.scaleMode = "noScale";
Stage.align = "TL";

// Create some dummy boxes
// This is only for the demonstration

var margin:Number = 10;
var boxSize:Number = 100;

var boxes = [
		["top", "0x9933cc"],
		["right", "0x00ff00"],
		["bottom", "0xff0000"],
		["left", "0x0099ff"],
		["center", "0xff3399"]];

for (var i = 0; i < boxes.length; i++)
{
	var newBox:MovieClip = createEmptyMovieClip (boxes[i][0], getNextHighestDepth ());

	var nameBadge = newBox.createTextField ("test_txt", 1, 0, (boxSize / 2) - 10, boxSize, 10);
	nameBadge.autoSize = "center";
	nameBadge.text = boxes[i][0];
	nameBadge.textColor = 0xffffff;

	with (newBox)
	{
		beginFill (boxes[i][1],100);
		moveTo (0,0);
		lineTo (boxSize,0);
		lineTo (boxSize,boxSize);
		lineTo (0,boxSize);
		lineTo (0,0);
		endFill ();
	}
}

/*
	The core function...
	I keep this separate from the 'onResize'
	handler so that I can call it at the start
	to position all of my elements if the screen
	size has remained the same
*/

function setStage ()
{
	var sw:Number = Stage.width;
	var sh:Number = Stage.height;
/*
Rule for Top / Center alignment
*/
	top._x = sw / 2 - top._width / 2;
	top._y = margin;
/*
Rule for Right / Middle alignment
*/
	right._x = sw - (right._width + margin);
	right._y = sh / 2 - right._height / 2;
/*
Rule for Bottom / Center alignment
*/
	bottom._x = sw / 2 - bottom._width / 2;
	bottom._y = sh - (bottom._height + margin);
/*
Rule for Left / Middle alignment
*/
	left._x = margin;
	left._y = sh / 2 - left._height / 2;
/*
Rule for Center / Middle alignment
*/
	center._x = sw / 2 - center._width / 2;
	center._y = sh / 2 - center._height / 2;
}

// Add a listener
var stageListener:Object = new Object ();
Stage.addListener (stageListener);

// When the Stage dimensions change...
stageListener.onResize = setStage;

// Call our function to set it all up right!
setStage ();</pre>
<p>Have fun!</p>


<p>Related posts:<ol><li><a href='http://blog.soulwire.co.uk/code/dynamic-positioning-part-two' rel='bookmark' title='Permanent Link: Dynamic Positioning Continued'>Dynamic Positioning Continued</a></li>
<li><a href='http://blog.soulwire.co.uk/code/open-source/dynamic-stacking' rel='bookmark' title='Permanent Link: Dynamic Stacking'>Dynamic Stacking</a></li>
<li><a href='http://blog.soulwire.co.uk/code/actionscript-3/fit-a-displayobject-into-a-rectangle' rel='bookmark' title='Permanent Link: Fit DisplayObject into Rectangle'>Fit DisplayObject into Rectangle</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.soulwire.co.uk/code/dynamic-positioning-part-one/feed</wfw:commentRss>
		<slash:comments>25</slash:comments>
		</item>
	</channel>
</rss>

