forked from: forked from: forked from: Emotion Fractal in AS3
// forked from watanabe's forked from: forked from: Emotion Fractal in AS3
// forked from mojowool's forked from: Emotion Fractal in AS3
// forked from 5ivestar's Emotion Fractal in AS3
// Emotion Fractal in AS3
// refer to http://levitated.net/daily/levEmotionFractal.html
package {
import flash.display.Sprite;
import flash.display.BitmapData;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.geom.Rectangle;
import flash.text.TextField;
import flash.text.TextFormat;
import caurina.transitions.Tweener;
import caurina.transitions.properties.TextShortcuts;
[SWF(backgroundColor="#000000", frameRate=30)]
public class EmotionFractal extends Sprite {
private var queue:Array;
private var words:Array;
[Embed(systemFont="serif", fontName="font", unicodeRange="U+0041-U+005A", mimeType="application/x-font")]
private var font:Class;
public function EmotionFractal() {
stage.align = "TL";
stage.scaleMode = "noScale";
words = 'WASHINGTON__—__The__economic__stimulus__plan__that__Congress__has__scheduled__for__a__vote__on__Wednesday__would__shower__the__nations__school__districts,__child__care__centers__and__university__campuses__with__$150__billion__in__new__federal__spending,__a__vast__two-year__investment__that__would__more__than__double__the__Department__of__Educations__current__budget.__Related__Times__Topics:__Economic__Stimulus__Readers__Comments__What__are__the__implications__of__using__stimulus__money__for__education__and__health__care?__Post__a__Comment__»__Read__All__Comments__(21)__»__The__proposed__emergency__expenditures__on__nearly__every__realm__of__education,__including__school__renovation,__special__education,__Head__Start__and__grants__to__needy__college__students,__would__amount__to__the__largest__increase__in__federal__aid__since__Washington__began__to__spend__significantly__on__education__after__World__War__II.__Critics__and__supporters__alike__said__that__by__its__sheer__scope,__the__measure__could__profoundly__change__the__federal__governments__role__in__education,__which__has__traditionally__been__the__responsibility__of__state__and__local__government.__Responding__in__part__to__a__plea__from__Democratic__governors__earlier__this__month,__Congress__allocated__$79__billion__to__help__states__facing__large__fiscal__shortfalls__maintain__government__services,__and__especially__to__avoid__cuts__to__education__programs,__from__pre-kindergarten__through__higher__education.__Obama__administration__officials,__teachers__unions__and__associations__representing__school__boards,__colleges__and__other__institutions__in__American__education__said__the__aid__would__bring__crucial__financial__relief__to__the__nations__15,000__school__districts__and__to__thousands__of__campuses__otherwise__threatened__with__severe__cutbacks.__“This__is__going__to__avert__literally__hundreds__of__thousands__of__teacher__layoffs,”__Education__Secretary__Arne__Duncan__said__Tuesday.__Representative__George__Miller,__Democrat__of__California__and__chairman__of__the__House__education__committee,__said,__“We__cannot__let__education__collapse;__we__have__to__provide__this__level__of__support__to__schools.”__But__Republicans__strongly__criticized__some__of__the__proposals__as__wasteful__spending__and__an__ill-considered__expansion__of__the__federal__governments__role,__traditionally__centered__on__aid__to__needy__students,__into__new__realms__like__local__school__construction.__And__they__were__joined__by__some__education__experts__from__across__the__political__spectrum__in__wondering__how__school__districts__could__spend__so__many__new__billions__so__fast,__whether__such__an__outpouring__of__dollars__would__lead__to__higher__student__achievement,__and__what__might__happen__in__two__years__when__the__stimulus__money__ends.__Analysts__were__also__turning__up__surprises__in__the__fine__print.__One__provision,__which__was__sought__by__the__student__lending__industry__and__went__unmentioned__in__early__Congressional__summaries__of__the__stimulus__package,__would__temporarily__increase__subsidies__to__banks__in__the__guaranteed__student__loan__program__by__tying__them__to__a__new__index,__partly__because__recent__federal__intervention__in__the__credit__markets__has__invalidated__the__previous__index.__A__spokesman__for__Sallie__Mae,__one__of__the__largest__student__lenders,__said__the__change__was__needed__to__keep__student__loan__markets__fluid.__Critics__said__it__represented__a__potential__new__windfall__for__lenders.__“This__just__continues__the__well-established__tradition__of__welfare__for__the__student__loan__industry,”__said__Barmak__Nassirian,__an__expert__in__student__lending.__The__formulas__by__which__the__stimulus__money__for__public__schools__would__be__allocated__to__states__and__local__districts__are__complex,__but__take__into__consideration__numbers__of__school-age__children__in__poor__families.__The__level__received__per__student__would__vary__considerably__by__state,__according__to__an__analysis__by__the__New__America__Foundation,__a__research__group__that__monitors__education__spending.__New__York__would__be__among__the__biggest__beneficiaries,__at__$760__per__student,__while__New__Jersey__and__Connecticut__would__fall__near__the__bottom,__with__$427__and__$409__per__student,__respectively.__The__District__of__Columbia__would__get__the__most__per__student,__$1,289,__according__to__the__foundations__analysis.__The__foundation__contends,__however,__that__the__formula__does__not__effectively__allocate__the__most__money__to__states__with__the__greatest__need.__In__recent__years__the__federal__government__has__contributed__9__percent__of__the__nations__total__spending__on__public__schools,__with__states__and__local__districts__financing__the__rest.__Washington__has__contributed__19__percent__of__spending__on__higher__education.__The__stimulus__package__would__raise__those__federal__proportions__significantly.__The__Department__of__Educations__discretionary__budget__for__the__2008__fiscal__year__was__about__$60__billion.__The__stimulus__bill__would__raise__that__to__about__$135__billion__this__year,__and__to__about__$146__billion__in__2010.__Other__federal__agencies__would__administer__about__$20__billion__in__additional__education-related__spending.__“This__really__marks__a__new__era__in__federal__education__spending,”__said__Edward__Kealy,__executive__director__of__the__Committee__for__Education__Funding,__a__coalition__of__90__education__groups.__The__bill__would__increase__2009__fiscal__year__spending__on__Title__I,__a__program__of__specialized__classroom__efforts__to__help__educate__poor__children,__to__$20__billion__from__about__$14.5__billion,__and__raise__spending__on__education__for__disabled__children__to__$17__billion__from__$11__billion.__Those__increases__respond__to__longtime__demands__by__teachers__unions,__school__boards__and__others__that__Washington__fully__finance__the__mandates__laid__out__for__states__and__districts__in__the__Bush-era__No__Child__Left__Behind__law,__and__in__the__main__federal__law__regulating__special__education.__“Weve__been__arguing__that__the__federal__government__hasnt__been__living__up__to__its__commitments,__but__these__increases__go__a__substantial__way__toward__meeting__them,”__said__Joel__Packer,__a__lobbyist__for__the__National__Education__Association,__the__nations__largest__teachers__union.__Frederick__Hess,__an__education__policy__analyst__at__the__American__Enterprise__Institute,__criticized__the__bill__as__failing__to__include__mechanisms__to__encourage__districts__to__bring__school__budgets__in__line__with__property__tax__revenues,__which__have__plunged__with__the__bursting__of__the__real__estate__bubble.__“Its__like__an__alcoholic__at__the__end__of__the__night__when__the__bars__close,__and__the__solution__is__to__open__the__bar__for__another__hour,”__Mr.__Hess__said.__The__bill__would,__for__the__first__time,__involve__the__federal__government__in__a__significant__fashion__in__the__building__and__renovation__of__schools,__which__has__been__the__responsibility__of__states__and__districts.__It__includes__$20__billion__for__school__renovation__and__modernization,__with__$14__billion__for__elementary__and__secondary__schools__and__$6__billion__for__higher__education.__It__also__includes__tax__provisions__under__which__the__federal__government__would__pay__the__interest__on__construction__bonds__issued__by__school__districts.__Mr.__Duncan__said__the__bills__school__renovation__provisions__would__create__a__“huge__number__of__construction__jobs,”__because__so__many__school__buildings__need__repairs.__But__Representative__Howard__P.__McKeon,__Republican__of__California__and__the__ranking__minority__member__of__the__House__education__committee,__said,__“By__putting__the__federal__government__in__the__business__of__building__schools,__Democrats__may__be__irrevocably__changing__the__federal__governments__role__in__education__in__this__country.”__In__higher__education,__the__bill__would__increase__spending__on__Pell__Grants,__the__most__important__federal__student__aid__program,__to__$27__billion__from__about__$19__billion__this__year.__“Its__a__very__good__idea__to__increase__Pell__Grants__in__the__stimulus,”__said__Terry__Hartle,__a__senior__vice__president__for__public__affairs__at__the__American__Council__on__Education,__which__represents__colleges__and__universities.__But__Mr.__Hartle__said__that__even__he__was__having__difficulty__tracking__all__the__new__spending.__“A__lot__of__things__will__go__through,__and__only__later__will__we__know__exactly__what__happened,”__he__said.'.split('__');
TextShortcuts.init();
init(null);
addEventListener(MouseEvent.MOUSE_DOWN, init);
}
public function init(e:MouseEvent):void {
Tweener.removeAllTweens();
while (numChildren) removeChildAt(0);
queue = [new Rectangle(0, 0, stage.stageWidth, stage.stageHeight)];
addEventListener(Event.ENTER_FRAME, fill);
}
public function fill(e:Event):void {
var i:int = 0;
while (queue.length > 0 && i < 13) {
var rect:Rectangle = queue.pop();
if (rect.width > 2 && rect.height > 2) {
fillRegion(rect);
i++;
}
}
if (!queue.length) removeEventListener(Event.ENTER_FRAME, fill);
}
public function fillRegion(region:Rectangle):void {
var tf:TextField = new TextField();
var fmt:TextFormat = new TextFormat();
fmt.font = 'font';
fmt.size = 24;
fmt.letterSpacing = -0.4;
fmt.rightMargin = 0.4;
tf.defaultTextFormat = fmt;
tf.text = choice(words).toUpperCase();
tf.autoSize = "left";
tf.embedFonts = true;
tf.selectable = false;
var bitmap:BitmapData = new BitmapData(tf.width, tf.height, true);
bitmap.draw(tf);
var bound:Rectangle = bitmap.getColorBoundsRect(0xFFFFFFFF, 0xFFFFFFFF, false);
bitmap.dispose();
var s:Number = region.width / bound.width * (Math.random() * 0.4 + 0.1);
if (bound.height * s > region.height) s = region.height / bound.height;
tf.scaleX = s;
tf.scaleY = s;
bound.x *= s;
bound.y *= s;
bound.width *= s;
bound.height *= s;
switch (choice([1,2,3,4])) {
case 1:
tf.x = region.x - bound.x;
tf.y = region.y - bound.y;
queue.push(
new Rectangle(region.x + bound.width, region.y, region.width - bound.width, bound.height),
new Rectangle(region.x, region.y + bound.height, region.width, region.height - bound.height)
);
break;
case 2:
tf.x = region.x - bound.x;
tf.y = region.bottom - bound.bottom;
queue.push(
new Rectangle(region.x + bound.width, region.bottom - bound.height, region.width - bound.width, bound.height),
new Rectangle(region.x, region.y, region.width, region.height - bound.height)
);
break;
case 3:
tf.x = region.right - bound.right;
tf.y = region.y - bound.y;
queue.push(
new Rectangle(region.x, region.y, region.width - bound.width, bound.height),
new Rectangle(region.x, region.y + bound.height, region.width, region.height - bound.height)
);
break;
case 4:
tf.x = region.right - bound.right;
tf.y = region.bottom - bound.bottom;
queue.push(
new Rectangle(region.x, region.bottom - bound.height, region.width - bound.width, bound.height),
new Rectangle(region.x, region.y, region.width, region.height - bound.height)
);
break;
}
addChild(tf);
//Tweener.addTween(tf, {_text_color: 0xFFFFFF, time: 5, transition: "liner"});
}
private function choice(ary:Array):* {
return ary[Math.floor(ary.length * Math.random())];
}
}
}