
Monday, August 8, 2011
Step 12

Step 11

Step 10
Once the code is all typed in and you have changed the values and colours of the butterflies to ones you like, test it out by hitting “shift + enter”. This is called exporting and it also creates a swf file. You can play around with the butterfly image, colours, alpha channels, and values to change it up and make it your own, just trial and error.
When playing with values you can always comment out certain text. Just copy and paste the line you want to change and use two forward slashes // to comment out one of the lines, that way you can keep the original text and if it doesn’t work you can always go back and try again

The grey shows the code is not commented out
Step 9
To change the alpha (opacity) of the butterflies: This will make some of the butterflies transparent depending on the value and rotation randomly selected by the variables you chose:
clip.alpha=(Math.random()*3);;

Step 8
To change the scale (size) of the butterflies as well as the rotation: This code will randomly select values between whatever values you select and will change the scale and rotation of them creating an interesting pattern:
clip.scaleX = clip.scaleY = (Math.random() * 0.75) + 0.25;
clip.rotation=(Math.random()*200)+5;
Step 7
To change the colour: Use the HTML colour names to change the colours to which ones you would like:
var color:ColorPool = new ColorPool(
0x33CCCC, 0x339999, 0x336666, 0x333399, 0x33FFCC, 0xFFCCFF, 0x33CC66, 0x99FFFF, 0x33FFFF

Step 6
Code:
import hype.extended.color.ColorPool;
import hype.extended.layout.ShapeLayout;
import hype.framework.core.ObjectPool;
import hype.framework.interactive.Adjuster;
MyShape.visible = false;
var pool:ObjectPool = new ObjectPool(MyCircle,500);
var layout:ShapeLayout = new ShapeLayout(MyShape);
var color:ColorPool = new ColorPool(
0x33CCCC, 0x339999, 0x336666, 0x333399, 0x33FFCC, 0xFFCCFF, 0x33CC66, 0x99FFFF, 0x33FFFF
pool.onRequestObject = function(clip) {
clip.scaleX = clip.scaleY = (Math.random() * 0.75) + 0.25;
clip.rotation=(Math.random()*200)+5;
clip.alpha=(Math.random()*3);;
layout.applyLayout(clip);
color.colorChildren(clip);
addChild(clip);
}
pool.requestAll();
var adjuster:Adjuster = new Adjuster();
addChild(adjuster);
pool.activeSet.forEach(adjuster.add);
Step 4
Step 3
Step 2
1) Open Adobe Flash CS5
2) Choose Action Script 3.0
I am providing the butterfly image to you, just drag it to your desktop, it is a png file so there is no background. If you’re going to use a different butterfly image make sure it has an outline and is a solid colour.
HERE you can find the link to the butterfly image to use.
Butterfly Tutorial: Step 1
This is what we will be creating:






