Monica Fonseca + Panning
Monica Fonseca
By Ctrl
March 2010
Inspired By: http://www.soho.com.co/wf_InfoGaleriasMujeres.aspx?IdGal=550
/**
* Copyright Ctrl ( http://wonderfl.net/user/Ctrl )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/pyZm
*/
// Monica Fonseca
// By Ctrl
// March 2010
// Inspired By: http://www.soho.com.co/wf_InfoGaleriasMujeres.aspx?IdGal=550
package
{
import flash.display.Loader;
import flash.display.Sprite;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.net.URLRequest;
import gs.*;
[SWF(frameRate="4")]
public class MonicaFonseca extends Sprite
{
private var url2:String = "http://www.soho.com.co/upload/images/2009/2/10/17577_142752_7.jpg";
private var url4:String = "http://www.soho.com.co/upload/images/2009/2/10/17576_142752_7.jpg";
private var url5:String = "http://www.soho.com.co/upload/images/2009/2/10/17575_142752_7.jpg";
private var loader:Loader;
private var loader2:Loader = new Loader();
public function MonicaFonseca()
{
loader2.contentLoaderInfo.addEventListener(Event.COMPLETE, loadPic2);
loader2.load(new URLRequest(url2));
addChild(loader2);
loader = new Loader();
addChild(loader);
}
private function loadPic2(e:Event):void
{
loader2.contentLoaderInfo.removeEventListener(Event.COMPLETE, loadPic2);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadPic3);
loader.load(new URLRequest(url4));
}
private function loadPic3(e:Event):void
{
loader.contentLoaderInfo.removeEventListener(Event.COMPLETE, loadPic3);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, startLoop);
loader.load(new URLRequest(url5));
}
private function startLoop(e:Event):void
{
loader.contentLoaderInfo.removeEventListener(Event.COMPLETE, startLoop);
loader.addEventListener(MouseEvent.CLICK, switchOnOff);
addEventListener(Event.ENTER_FRAME, loop);
}
private function switchOnOff(e:MouseEvent):void
{
if(hasEventListener(Event.ENTER_FRAME))
{
removeEventListener(Event.ENTER_FRAME, loop);
TweenLite.to(loader, 1, {x:0, y:0});
TweenLite.to(loader2, 1, {x:0, y:0});
}
else
{
addEventListener(Event.ENTER_FRAME, loop);
}
}
private function loop(e:Event):void
{
loader.unloadAndStop();
var num:Number = Math.ceil(Math.random()*3-1);
var arr:Array = [url2, url4, url5];
loader.load(new URLRequest(arr[num]));
TweenLite.to(loader, 1, {x:-mouseX, y:-mouseY});
TweenLite.to(loader2, 1, {x:-mouseX, y:-mouseY});
if(loader.x < -40)
{
loader.x = -40;
loader2.x = -40;
}
if(loader.y <= -200)
{
loader.y = -200;
loader2.y = -200;
}
}
}
}