Condor
2007年8月23日にAS2で作ったものをAS3化
/**
* Copyright umhr ( http://wonderfl.net/user/umhr )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/tuEY
*/
package
{
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.events.Event;
import flash.events.MouseEvent;
/**
* ...
* @author umhr
*/
public class Condor extends Sprite
{
private var p_array:Array/*Number*/ = [ -75.12638202673537, -14.69800981633681, -75.12645321538069, -14.69778543443749, -75.12644869979161, -14.69777648143906, -75.12644157779143, -14.69776383951614, -75.12644236397323, -14.69775074498358, -75.12645259317813, -14.6977363423782, -75.12646826916057, -14.69773314233061, -75.12646868100484, -14.69771392827423, -75.12645160127875, -14.6976941800846, -75.12624491293224, -14.69755862666524, -75.12621364064707, -14.69752740885088, -75.12614833538288, -14.69741984168085, -75.12610471895853, -14.69734250551567, -75.12611644087515, -14.69733953180562, -75.12614436739858, -14.69738092021238, -75.12618271491907, -14.69742401504071, -75.12624843202815, -14.69751236814723, -75.12627295664218, -14.69753706357285, -75.12628137952174, -14.6975450253134, -75.12628560972827, -14.69753633940534, -75.12626038325166, -14.69750016987536, -75.12616031488284, -14.6973562113354, -75.12616607993513, -14.69734666996872, -75.12617487252123, -14.69734770199764, -75.12620447424017, -14.69739052973995, -75.12624603642612, -14.69744725768788, -75.12630747187742, -14.69753048246912, -75.12632049928679, -14.69753587782341, -75.12632980193139, -14.69753227493548, -75.12621083367085, -14.69735178484822, -75.12620780613649, -14.69734121145568, -75.12621533998355, -14.69733463933405, -75.12622669218169, -14.69733859534515, -75.12627975156778, -14.69741462337005, -75.12636348416905, -14.69753802339271, -75.12637218779298, -14.69755057477011, -75.12638181797256, -14.69755232646237, -75.12638535093552, -14.69754521569677, -75.12628614850024, -14.69735054493746, -75.12629344838003, -14.69734014811229, -75.12631187112734, -14.6973429318363, -75.12642205605519, -14.69754848828351, -75.12642782573093, -14.69755199615868, -75.12643368434946, -14.69754398467086, -75.12637226322428, -14.69737018019784, -75.12637793467164, -14.69735910895297, -75.12638565566814, -14.69735559658911, -75.12640472884189, -14.69735604022061, -75.12647848479338, -14.69754986440395, -75.12648797459285, -14.69754932127295, -75.126506659499, -14.69750449764857, -75.12647253294, -14.69742661855234, -75.12646439081934, -14.69742324646037, -75.12645322116455, -14.69740930099116, -75.12645010004687, -14.69739719773408, -75.1264514430745, -14.69738023327276, -75.12642509360361, -14.69732570520159, -75.12640801854764, -14.69731900626771, -75.12638661507452, -14.69730641410948, -75.12637246932088, -14.69729570942617, -75.12634431818492, -14.69727659487245, -75.12634356951487, -14.69726435582082, -75.12635226849518, -14.69726385796124, -75.12638237559699, -14.69728900151991, -75.12640973126383, -14.69729511207541, -75.12641484584887, -14.69728791078907, -75.12641047064156, -14.69728125262654, -75.12636509943056, -14.69724009505668, -75.12633457119459, -14.69720806700576, -75.12633638213927, -14.69719875193096, -75.12634601231201, -14.6972005036374, -75.12638444870701, -14.69723207908702, -75.12640538890781, -14.69725007110279, -75.12641920711508, -14.69725542120319, -75.12643470053703, -14.69726221066196, -75.12644060593607, -14.69725496411294, -75.12643548670505, -14.69724911615043, -75.12640165949217, -14.69722802359988, -75.12638057891419, -14.69720773675462, -75.12637997061752, -14.69719779251928, -75.12639104204256, -14.69719715887836, -75.1264077942035, -14.69721155249754, -75.12642989490543, -14.69722256952497, -75.12646525695324, -14.69724280660693, -75.12647461101459, -14.69725301790891, -75.12647308082364, -14.69726692262058, -75.12648108256501, -14.69726799989479, -75.12649257046441, -14.69726120145992, -75.12649958957238, -14.6972462149815, -75.12651069848459, -14.69722024776481, -75.12651958462459, -14.69722280965824, -75.12652038008981, -14.69723581365065, -75.12651010878533, -14.69726250054362, -75.12650201810951, -14.69727294263869, -75.12646951037681, -14.69729936694151, -75.12645751241085, -14.69731080027534, -75.12645468133775, -14.69732938514327, -75.1264611060956, -14.69734360218134, -75.12647381523584, -14.69736974143314, -75.12649010412122, -14.69738953485741, -75.12649690321585, -14.69740987140896, -75.12649639779866, -14.69742755554772, -75.12651143724686, -14.69746584330612, -75.12651902251258, -14.69747308535626, -75.12652171785713, -14.69746525491391, -75.12654834374598, -14.69738159590975, -75.12655984123626, -14.69727116846846, -75.12657327609307, -14.6971145728549, -75.12659848923356, -14.69685213829296, -75.12660509186932, -14.69684331652204, -75.12663733281809, -14.69685145033944, -75.12663836223739, -14.69686827915925, -75.12662481050472, -14.6969580990984, -75.12656475440926, -14.69735148718696, -75.12656857276255, -14.69736201530211, -75.12657703312462, -14.69734464348853, -75.12668706995657, -14.69687316760164, -75.12669241850601, -14.69686979097686, -75.12672289066292, -14.69687495549528, -75.12672573102819, -14.69688246916584, -75.12660191810014, -14.6973363106685, -75.12660308325371, -14.69734238492755, -75.12660926940356, -14.69733972801688, -75.12675755550501, -14.69689676775663, -75.1267627168922, -14.69689033134563, -75.1267829084409, -14.69689608426586, -75.1267848644061, -14.69690211330396, -75.12670234733503, -14.69718778561745, -75.12671048945612, -14.69719115770175, -75.12681524763622, -14.69691879723238, -75.12682199066218, -14.69691227029228, -75.12684362348364, -14.69691563783192, -75.12684646384929, -14.69692315149352, -75.12668252522178, -14.69730483056505, -75.1266899233202, -14.69730901285076, -75.12687303338298, -14.69694235655462, -75.12687977641451, -14.69693582961266, -75.12689824597879, -14.69693937819719, -75.12690434320142, -14.69694824068601, -75.1267101101997, -14.69730171652061, -75.12670011499914, -14.69731994381279, -75.12671597345977, -14.69730675426947, -75.12693989250856, -14.69697153748077, -75.12695021994413, -14.69697171398063, -75.12696608774779, -14.69698462294982, -75.12696720610613, -14.69698993229722, -75.12674327768985, -14.69729905057664, -75.12664977397296, -14.69743105918801, -75.12662067742582, -14.69750027487234, -75.12662546911653, -14.69750076824479, -75.12667509872382, -14.69748180778132, -75.12668007292731, -14.69747231167218, -75.12669202410083, -14.69746011338969, -75.12671156055021, -14.69745515715148, -75.12673370341577, -14.69745388982623, -75.12677533128706, -14.69743385207064, -75.12678403027374, -14.69743335419008, -75.12678779252373, -14.697417018876, -75.12677969252067, -14.69740136249086, -75.12676618786196, -14.69736221927081, -75.12677497577181, -14.69735020202293, -75.12678572431665, -14.69735726301797, -75.12679378218488, -14.6973852037093, -75.12679913539414, -14.69739487635941, -75.12680564910222, -14.69739757402363, -75.12680601878304, -14.69739064429962, -75.12683215788036, -14.69737686634099, -75.12685737045197, -14.69737388806575, -75.12688532983071, -14.6973768935229, -75.12688677575269, -14.69738755742742, -75.12687044933682, -14.69739309758089, -75.12685044493034, -14.69739040443726, -75.12683974783012, -14.69739715763157, -75.12685193764415, -14.69740183328023, -75.12687189525893, -14.69740376148436, -75.12689287299708, -14.69739641987617, -75.12690208672225, -14.69740433633482, -75.12689469326726, -14.69741320330457, -75.12687678521287, -14.69741883398103, -75.12685864319663, -14.69742063995318, -75.12683561590062, -14.69742042267543, -75.12683613062515, -14.69742883701837, -75.12685766987322, -14.69743067470201, -75.12687697705447, -14.69743494299188, -75.12687367807176, -14.69744587846848, -75.12686353781912, -14.6974487616975, -75.12683297202172, -14.69744206731314, -75.12681971529804, -14.69744589652818, -75.12679631833166, -14.69745260896717, -75.12673506040875, -14.69747607308657, -75.12672608532917, -14.69748503056584, -75.12670697001077, -14.69749687126408, -75.12668859405682, -14.69749485251767, -75.12661826749461, -14.69752574419656, -75.12661073366934, -14.69753231632846, -75.12658317194216, -14.69760067656609, -75.12658866552118, -14.69761264404485, -75.12660052777449, -14.69761196512787, -75.12685162401547, -14.69756535399062, -75.1268569304508, -14.6975742617086, -75.12684531617896, -14.69761791310105, -75.12662314788876, -14.69764444572007, -75.12662510386423, -14.69765047472298, -75.1266349680122, -14.69765605111474, -75.12688124462807, -14.69766037870703, -75.12689631698672, -14.69766028368226, -75.1269005565387, -14.69767769629171, -75.12689260623884, -14.69769043323229, -75.12665223493569, -14.69767885905752, -75.12664628273897, -14.69768534067452, -75.1266567084072, -14.69770009636228, -75.12692416890798, -14.69775233928447, -75.12695246066612, -14.69777374869157, -75.12694790762676, -14.69779012932084, -75.12669481736934, -14.69772631717873, -75.12669714769802, -14.69773846572133, -75.12671036230836, -14.69774692084389, -75.12696322341446, -14.69781995762058, -75.12698448671453, -14.69783025499794, -75.12699407488351, -14.69784429106663, -75.12698598419362, -14.69785473320736, -75.12679839585782, -14.69779791869093, -75.12673977698938, -14.69778668883676, -75.12675201829884, -14.69780517874378, -75.12676593016158, -14.69781205873376, -75.12700357890449, -14.69788289588936, -75.12700874501026, -14.6978895088309, -75.12700060752218, -14.69789918603488, -75.12677026797365, -14.69784405055521, -75.12673379202388, -14.69783155337889, -75.12651874111981, -14.6977279507933, -75.12650967243522, -14.69773537839975, -75.12650139456696, -14.69774276074595, -75.12650758537833, -14.69775315310035, -75.12651131015309, -14.69776215135632, -75.12650294334286, -14.69778105309601, -75.12648526923519, -14.69779050846692, -75.12647498859813, -14.69779109686302, -75.1264089897219, -14.69795760998111, -75.12639788069633, -14.69798357736293, -75.12638202673537, -14.69800981633681];
private var _mc:MovieClip = new MovieClip();
private var _xmouse:Number = 0;
private var _ymouse:Number = 0;
private var isDown:Boolean;
public function Condor()
{
init();
}
private function init():void
{
if (stage) onInit();
else addEventListener(Event.ADDED_TO_STAGE, onInit);
}
private function onInit(event:Event = null):void
{
removeEventListener(Event.ADDED_TO_STAGE, onInit);
// entry point
graphics.beginFill(0x326F32);
graphics.drawRect(0, 0, stage.stageWidth, stage.stageHeight);
graphics.endFill();
var heikin_array:Array = new Array();
var heikin_x:Number = new Number(0);
var heikin_y:Number = new Number(0);
for (var i:Number = 0; i<p_array.length/2; i++) {
heikin_x += p_array[i*2];
heikin_y += p_array[i*2+1];
}
heikin_x /= p_array.length/2;
heikin_y /= p_array.length/2;
for (i = 0; i<p_array.length/2; i++) {
p_array[i*2] = (p_array[i*2]-heikin_x)*600000;
p_array[i*2+1] = (p_array[i*2+1]-heikin_y)*600000;
}
var poz_array:Array = new Array();
poz_array = [Math.PI/2, 0, 0];
var n_cx:Number = new Number();
var n_sx:Number = new Number();
var n_cy:Number = new Number();
var n_sy:Number = new Number();
var n_cz:Number = new Number();
var n_sz:Number = new Number();
var af_array:Array = new Array(15);
function fn_sq(event:Event = null):void {
n_cx = Math.cos(poz_array[0]);
n_sx = Math.sin(poz_array[0]);
n_cy = Math.cos(poz_array[1]);
n_sy = Math.sin(poz_array[1]);
n_cz = Math.cos(poz_array[2]);
n_sz = Math.sin(poz_array[2]);
af_array[0] = slide_array[0];
af_array[1] = slide_array[1];
af_array[2] = slide_array[2];
af_array[6] = n_cz*n_cy+n_sx*n_sy*n_sz;
af_array[7] = n_sx*n_sy*n_cz-n_sz*n_cy;
af_array[8] = n_sy*n_cx;
af_array[9] = n_cx*n_sz;
af_array[10] = n_cx*n_cz;
af_array[11] = -n_sx;
af_array[12] = n_cy*n_sx*n_sz-n_sy*n_cz;
af_array[13] = n_sy*n_sz+n_cy*n_sx*n_cz;
af_array[14] = n_cx*n_cy;
///
var aq_array:Array = new Array();
for (var i:Number = 0; i<p_array.length/2; i++) {
aq_array[i] = [p_array[i*2], p_array[i*2+1]];
}
for (i = 0; i<aq_array.length; i++) {
var _array:Array = new Array();
af_array[15] = aq_array[i][0];
af_array[16] = aq_array[i][1];
af_array[17] = 0;
for (var k:Number = 0; k<3; k++) {
_array[k] = af_array[15] * af_array[6 + 3 * k] + af_array[16] * af_array[7 + 3 * k] + af_array[17] * af_array[8 + 3 * k] + af_array[k];
}
aq_array[i] = pertrans(_array[0], _array[1], _array[2]);
aq_array[i][0] += stage.stageWidth * 0.5;
aq_array[i][1] += stage.stageHeight * 0.5;
}
_mc.graphics.clear();
_mc.graphics.beginFill(0x326F32,100)
_mc.graphics.lineStyle(0, 0x33ff33, 100);
_mc.graphics.moveTo(aq_array[0][0], aq_array[0][1]);
for (i = 0; i<aq_array.length; i++) {
_mc.graphics.lineTo(aq_array[i][0], aq_array[i][1]);
}
_mc.graphics.endFill();
isDown = false;
}
function pertrans(arg_x:Number, arg_y:Number, arg_z:Number):Array {
arg_z = 400/(400+arg_z);
return [arg_x*arg_z, arg_y*arg_z];
}
var slide_array:Array = new Array(0, 0, 0);
function fn_r():void {
if (true == isDown) {
slide_array[0] += (_xmouse-400-af_array[0])/20;
slide_array[1] += (_ymouse-60-af_array[1])/20;
} else {
poz_array[1] += (_xmouse-stage.stageWidth * 0.5) / 10000;
poz_array[0] -= (_ymouse-stage.stageHeight * 0.5) / 10000;
}
fn_sq();
}
var to_x:Number = new Number(0);
var to_r:Number = new Number(0);
var to_z:Number = new Number(0);
function fn_ctrl(arg:Boolean):void {
if (arg) {
to_x += 100;
to_r += 1.5;
} else {
to_x -= 100;
to_r -= 1.5;
}
}
addChild(_mc);
addEventListener(MouseEvent.MOUSE_MOVE, mouseMove);
addEventListener(MouseEvent.MOUSE_DOWN, mouseDown);
addEventListener(Event.ENTER_FRAME, fn_r);
function mouseMove(e:MouseEvent):void
{
_xmouse = e.localX;
_ymouse = e.localY;
}
function mouseDown(e:MouseEvent):void
{
isDown = true;
}
}
}
}