PDA

View Full Version : Bubblefest! Is this illegal?



ElectricGrandpa
January 17th, 2006, 03:10 AM
Ok. This is an example of what is technically legal, according to the current rules, but it probably should be illegal, as it enables you to do a LOT more. If I wrote it without using the chain function, it would be at least 25 lines, and possibly more.

This is just an example for now, so ignore how glitchy parts of it are. It took a LONG time to create, and it's incredibly hard to follow, because it was the equivalent of writing a few hundred lines of code.

This technique uses less 'for' loops, and more linking of chain functions, so you've basically gotta write normal code, but it takes way longer to input it. (There's also one line that's well over 3000 characters long, so it's split onto multiple lines... would that count as 1 or 4?)

It's only 12 lines with the current counting rules, and there are now no import statements.


function chain(p_scope:Object, p_methodToCall:String, p_params:Array):Object {
p_scope[p_methodToCall](p_params[0], p_params[1], p_params[2], p_params[3], p_params[4], p_params[5], p_params[6], p_params[7], p_params[8]);
return this;
}
Object.prototype.applyProps = function(p_source:Object):Void {
for (propName in p_source) {
this[propName] = p_source[propName];
}
};
function createInterval(p_scope:Object, p_methodName:String, p_interval:Number) {
setInterval(p_scope, p_methodName, p_interval);
}
chain(this, "createEmptyMovieClip", ["circleHolder_mc", 1]).chain(this, "applyProps", [{dropShadowA:new flash.filters.DropShadowFilter(-3, 45, 0x000000, 100, 10, 10, .5, 1, true, false, false), dropShadowB:new flash.filters.DropShadowFilter(1, 45, 0x000000, 100, 15, 15, .4, 1, false, false, false), dropShadowC:new flash.filters.DropShadowFilter(0, 45, 0xEE4400, 20, 20, 100, .6, 1, true, true, false), dropShadowD:new flash.filters.DropShadowFilter(0, 45, 0xFFFFFF, 100, 150, 150, 1, 1, true, true, false), dropShadowE:new flash.filters.DropShadowFilter(0, 45, 0xFFFFFF, 100, 10, 10, 2, 1, true, true, false)}]).chain(this, "createEmptyMovieClip", ["starburst_mc", -10]).chain(this, "createEmptyMovieClip", ["borderA_mc", 100]).chain(this, "createEmptyMovieClip", ["borderB_mc", 101]);
chain(this.borderA_mc, "lineStyle", [1, 0x000000, 0]).chain(this.borderA_mc, "beginFill", [0x000000, 100]).chain(this.borderA_mc, "lineTo", [0, 0]).chain(this.borderA_mc, "lineTo", [550, 0]).chain(this.borderA_mc, "lineTo", [550, 400]).chain(this.borderA_mc, "lineTo", [0, 400]).chain(this.borderA_mc, "lineTo", [0, 0]).chain(this.borderA_mc, "endFill", []).chain(this.borderB_mc, "lineStyle", [1, 0x000000, 0]).chain(this.borderB_mc, "beginFill", [0x000000, 100]).chain(this.borderB_mc, "lineTo", [0, 0]).chain(this.borderB_mc, "lineTo", [550, 0]).chain(this.borderB_mc, "lineTo", [550, 400]).chain(this.borderB_mc, "lineTo", [0, 400]).chain(this.borderB_mc, "lineTo", [0, 0]).chain(this.borderB_mc, "endFill", []).chain(this.starburst_mc, "lineStyle", [1, 0x000000, 0]).chain(this.starburst_mc, "beginFill", [0xFF5217, 100]).chain(this.starburst_mc, "lineTo", [-33, -364]).chain(this.starburst_mc, "lineTo", [9, -64]).chain(this.starburst_mc, "lineTo", [28, -60]).chain(this.starburst_mc, "lineTo", [98, -361]).chain(this.starburst_mc, "lineTo", [195, -326]).chain(this.starburst_mc, "lineTo", [40, -54]).chain(this.starburst_mc, "lineTo", [50, -44]).chain(this.starburst_mc, "lineTo", [278, -270]).chain(this.starburst_mc, "lineTo", [323, -223]).chain(this.starburst_mc, "lineTo", [63, -33]).chain(this.starburst_mc, "lineTo", [68, -19]).chain(this.starburst_mc, "lineTo", [400, -62]).chain(this.starburst_mc, "lineTo", [407, 33]).chain(this.starburst_mc, "lineTo", [72, 2]).chain(this.starburst_mc, "lineTo", [68, 28]).chain(this.starburst_mc, "lineTo", [394, 129]).chain(this.starburst_mc, "lineTo", [329, 258]).chain(this.starburst_mc, "lineTo", [58, 49]).chain(this.starburst_mc, "lineTo", [47, 60]).chain(this.starburst_mc, "lineTo", [245, 341]).chain(this.starburst_mc, "lineTo", [148, 392]).chain(this.starburst_mc, "lineTo", [30, 71]).chain(this.starburst_mc, "lineTo", [18, 74]).chain(this.starburst_mc, "lineTo", [79, 407]).chain(this.starburst_mc, "lineTo", [3, 411]).chain(this.starburst_mc, "lineTo", [0, 75]).chain(this.starburst_mc, "lineTo", [-7, 77]).chain(this.starburst_mc, "lineTo", [-62, 407]).chain(this.starburst_mc, "lineTo", [-162, 371]).chain(this.starburst_mc, "lineTo", [-23, 73]).chain(this.starburst_mc, "lineTo", [-38, 64]).chain(this.starburst_mc, "lineTo", [-221, 331]).chain(this.starburst_mc, "lineTo", [-281, 275]).chain(this.starburst_mc, "lineTo", [-53, 48]).chain(this.starburst_mc, "lineTo", [-63, 27]).chain(this.starburst_mc, "lineTo", [-350, 158]).chain(this.starburst_mc, "lineTo", [-372, 50]).chain(this.starburst_mc, "lineTo", [-67, 9]).chain(this.starburst_mc, "lineTo", [-67, -9]).chain(this.starburst_mc, "lineTo", [-367, -51]).chain(this.starburst_mc, "lineTo", [-349, -112]).chain(this.starburst_mc, "lineTo", [-62, -24]).chain(this.starburst_mc, "lineTo", [-49, -42]).chain(this.starburst_mc, "lineTo", [-259, -253]).chain(this.starburst_mc, "lineTo", [-190, -309]).chain(this.starburst_mc, "lineTo", [-33, -54]).chain(this.starburst_mc, "lineTo", [-8, -63]).chain(this.starburst_mc, "lineTo", [-102, -351]).chain(this.starburst_mc, "lineTo", [-33, -365]).chain(this.starburst_mc, "endFill", []).chain(this.starburst_mc, "applyProps", [{_x:260, _y:190, filters:[dropShadowC]}]).chain(this.borderA_mc, "applyProps", [{filters:[dropShadowD]}]).chain(this.borderB_mc, "applyProps", [{filters:[dropShadowE]}]);
for (var c:Number = 0; c<20; c++) {
chain(circleHolder_mc, "createEmptyMovieClip", ["circle"+c+"_mc", c]).chain(this, "applyProps", [{radius:5+random(25)}]);
this.circleHolder_mc["circle"+c+"_mc"].move = function():Void {
this._parent._parent.chain(this, "applyProps", [{_visible:(this._y<(0-this.radius)) ? false : true, ys:(this._y>400-this.radius*2) ? (Math.max((20+random(5))*-1, this.ys*-1)) : this.ys+1, _y:(this._y>400-(this.radius*2)) ? (this._y-this.ys-this.radius*2)-(this._y-(400)) : this._y+this.ys, xs:(this._x<0+this.radius || this._x>550-this.radius) ? this.xs*-1 : this.xs, _x:(this._x<0+this.radius) ? (this._x-(this._x-(0+this.radius)))-this.xs : (this._x>550-this.radius) ? (this._x-(this._x-(550-this.radius)))-this.xs : this._x+this.xs}]);
};
chain(this.circleHolder_mc["circle"+c+"_mc"], "applyProps", [{_x:100+random(300), _y:random(100), ys:(random(11)*-1), xs:(random(11)-5), radius:this.radius}]).chain(this.circleHolder_mc["circle"+c+"_mc"], "lineStyle", [this.radius*2, 0xFF66FF, 100]).chain(this.circleHolder_mc["circle"+c+"_mc"], "moveTo", [0, 0]).chain(this.circleHolder_mc["circle"+c+"_mc"], "lineTo", [0.2, 0]).chain(circleHolder_mc, "applyProps", [{filters:[dropShadowA, dropShadowB]}]).chain(this, "createInterval", [this.circleHolder_mc["circle"+c+"_mc"], "move", 30]);
}
Stage.scaleMode = "noScale";


Bubblefest in Action (http://www.matt-rix.com/kirupa/25Lines/Bubblefest.html)

TheCanadian
January 17th, 2006, 03:25 AM
I haven't actually counted the code but you aren't allowed non-core classes (such as DropShadowFilter). It looks really good though :afro:

ElectricGrandpa
January 17th, 2006, 04:22 AM
Hmm... Rats, I checked the rules and now no importas has been added to them. Last time I checked the rules that hadn't actually been decided yet.

Well if it counts for anything, I really think it's silly not to allow imports of built-in classes... maybe I'll post something about it in the rules section.

-Matt

Sinister Shadow
January 17th, 2006, 04:35 AM
You stole my idea! The chain function at least ;)
Funky effect!

ElectricGrandpa
January 17th, 2006, 04:40 AM
Posted a little argument :)

http://www.kirupa.com/forum/showthread.php?p=1755289#post1755289

hybrid101
January 17th, 2006, 07:52 AM
that is one, sick code. great job, EG!

kookaburra
January 17th, 2006, 08:45 AM
looks cute. not sure if the i the importing allowed.........

ElectricGrandpa
January 17th, 2006, 10:49 AM
You stole my idea! The chain function at least

Yep! :D Well, I used yours as a starting point at least, I made mine a bunch simpler and made it work for any function.

lostinbeta
January 17th, 2006, 11:02 AM
Very nice code, a bit of a birch to read because of how it is condensed, but I'm not going to get into all of that, I honestly haven't read the rules for this contest as I doubt I will be participating... I do have one question about your code though... function createInterval(p_scope:Object, p_methodName:String, p_interval:Number) {
setInterval(p_scope, p_methodName, p_interval);
}

I'm not understanding the point of that function. If setInterval() already exists, why are you calling it within another function and passing all the same parameters it takes anyway?

Seb Hughes
January 17th, 2006, 01:12 PM
Yea your not allowed to import filters, caus enot everybody has 8 and it is nifty :D

ElectricGrandpa
January 17th, 2006, 02:38 PM
I'm not understanding the point of that function. If setInterval() already exists, why are you calling it within another function and passing all the same parameters it takes anyway?

Yeah I figured someone would ask about that. For some reason (perhaps because setInterval is a global function) it's not possible to call it using my chain function, so I have to make a function that calls the function.

ElectricGrandpa
January 17th, 2006, 02:43 PM
Tada! Now there's no import statement, so it's technically legal, but it still works! :D I think it's fully legit now.

TheCanadian
January 17th, 2006, 03:07 PM
you aren't allowed non-core classes (such as DropShadowFilter).

I tried to say somewhere in the rules that fully qualified class paths aren't legal either but no one ever really picked up - I'm pretty sure though that what I said above is the rules though. Perhaps some clarification please :nerd:

Edit: I just read Kirupa's post in the rules so apparently using Flash 8's classes are allowed. I don't see why anyone would use an import statement in this contest when they could just use the qualified path.

ElectricGrandpa
January 18th, 2006, 12:11 AM
Yeah I don't know why I ever used an import statement... I for some reason completely forgot about doing the full path... And it even saved me a line. No imports basically means I can't use custom classes or anything, so I think that's absolutely fair. Anything that's included with Flash should be fair game.

ElectricGrandpa
January 18th, 2006, 01:59 AM
So can I get the official word: Is this style of coding, with function chaining and Flash 8 Filters allowed? I don't wanna waste my time if it's not :)

-Matt