flash on 2011-4-11
/**
* Copyright Thy ( http://wonderfl.net/user/Thy )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/poq3
*/
package {
import flash.geom.ColorTransform;
import flash.geom.Point;
import flash.filters.BlurFilter;
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.display.Graphics;
import flash.events.Event;
import flash.display.Sprite;
public class FlashTest extends Sprite {
private var buts:Array = new Array(5, true);
private var imgs:Array = new Array(5, true);
private var atual:int;
private var velho:int;
private var sprite:Sprite = new Sprite();
public function FlashTest() {
sprite.cacheAsBitmap = true;
var mask:Sprite = new Sprite();
mask.cacheAsBitmap = true;
this.addChild(sprite);
this.addChild(mask);
var g:Graphics;
g = mask.graphics;
g.lineStyle(1, 0xFFFFFF, .5);
g.beginFill(0xFFFFFF);
g.drawRoundRect(2, 2, 310, 250, 15, 15);
g.endFill();
sprite.mask = mask;
var nomes:Array = ["Oportunidades", "Infraestrutura","a","b","c"];
var links:Array = ["http://i1.squidoocdn.com/resize/squidoo_images/-1/draft_lens11905561module108663091photo_1278093909demotivational_posters_-_",
"http://crujonessociety.com/wordpress/wp-content/uploads/2008/07/waterballoon-demotivational-poster.jpg",
"http://prankcall.us/wp-content/uploads/2010/03/ninjas-demotivational-poster.jpg",
"http://1.bp.blogspot.com/_Zhnhq_exYt0/SHA7nKW-8jI/AAAAAAAAAUc/krGCbcy4_Nw/s400/camel-toe-seriously-demotivational-poster.jpg",
"http://www.atalhobacs.com.br/galeria/slideshow/galleries/3%20Calourada%20UNIFEI%20-%20Itabira/"+String((Math.random()*29)>>0)+".jpg"];
var b:B;
var i:int = -1;
while(++i < 5)
{
buts[i] = b = new B(nomes[i]);
imgs[i] = new Img(links[i]);
this.addChild(b);
sprite.addChild(imgs[i]);
b.x = 465;
b.y = i*56 + 1;
}
stage.addEventListener(Event.ENTER_FRAME, ef);
}
private function ef(e:Event):void
{
var b:B;
atual = buts[4].t.text = ((mouseY - 1) / 56) >> 0;
atual = atual < 0 ? 0 : atual > 4 ? 4 : atual;
if(velho != atual)
{
buts[velho].x2 = 360;
buts[atual].x2 = 340;
imgs[velho].alpha = 1;
imgs[atual].alpha = 0;
imgs[atual].a2 = 1;
sprite.addChild(imgs[atual])
velho = atual;
}
var i:int = -1;
var img:Img;
while(++i < 5)
{
b = buts[i];
b.x += (b.x2 - b.x) * .4;
img = imgs[i];
img.alpha += (img.a2 - img.alpha) * .4;
}
}
}
}
import flash.events.Event;
import flash.net.URLRequest;
import flash.display.Loader;
import flash.text.TextFieldAutoSize;
import flash.text.TextFormat;
import flash.text.TextField;
import flash.display.Graphics;
import flash.display.Sprite;
class Img extends Sprite
{
private var g:Graphics;
private var l:Loader = new Loader();
public var a2:Number = 1;
public function Img(url:String = "")
{
l.load(new URLRequest(url));
l.contentLoaderInfo.addEventListener(Event.COMPLETE, c);
}
private function c(e:Event):void
{
addChild(l);
l.scaleX = l.scaleY = (stage.stageWidth - 130) / l.width;
}
}
class B extends Sprite
{
private var
g:Graphics,
f:TextFormat;
public var t:TextField = new TextField(),
x2:Number = 360;
public function B(ti:String = "")
{
g = this.graphics;
g.beginFill(0x87AA2E);
g.drawRoundRect(0,0,100,55, 15,15);
f = new TextFormat("Arial", 14);
t.defaultTextFormat = f;
t.y = 18;
t.selectable = false;
this.addChild(t);
t.autoSize = TextFieldAutoSize.LEFT;
t.text = ti;
}
}