Zurück   Flashforum > Flash > Stuff

Antwort
 
LinkBack Themen-Optionen Ansicht
Alt 26-10-2003, 17:07   #1 (permalink)
Revived @ Sunday
 
Benutzerbild von MacEvil
 
Registriert seit: Apr 2003
Ort: Nowhereland
Beiträge: 3.244
[STUFF] Flash MX Prototpyes

Kleine Sammlung :
ActionScript:
  1. /**********        Wulfie's Prototypes          ********** / 
  2. /**********          [email]maunzer@balcab.ch[/email]          ********** /
  3. /*                     
  4. *   Methods :
  5. *  - Math
  6. *    - rad2deg();
  7. *    - deg2rad();
  8. *    - distance();
  9. *    - isDiffrent();
  10. *    - isEven();
  11. *    - isBetween();
  12. *    - isNatural();
  13. *    - isNum();
  14. *    - divisible();
  15. *    - multiplicatable();
  16. *    - subtractable();
  17. *    - additable();
  18. *    - lowerOne();
  19. *    - biggerOne();
  20. *    - randomBetween();
  21. *    - crossfoot();
  22. *    - cubeArea();
  23. *    - triangleAngle();
  24. *    - cosDeg();
  25. *    - sinDeg();
  26. *    - toLowerNumber();
  27. *    - toUpperNumber();
  28. *    - calculateDuty(); 
  29. *    - places();
  30. *    - root();
  31. *    - circumference();
  32. *    - ruleofthree();
  33. *    - makePositive();
  34. *    - makeNegative();
  35. *    - squareArea();
  36. *    - KBstoByters();
  37. *    - BytestoKBs();
  38. *    - diffrenceBetween();
  39. *  - MovieClip
  40. *    - drawCilinder();
  41. *    - drawSquare();   
  42. *    - drawRectangle();
  43. *    - drawCircle();
  44. *    - drawTriangle();
  45. *    - circleMove();
  46. *    - setCursor();
  47. *    - fitTo();
  48. *    - fitToWindow();
  49. *    - resize();
  50. *    - transform();
  51. *    - newpos();
  52. *    - clone();
  53. *  - Loader
  54. *    - getKbsLoaded();
  55. *    - getKbsTotal();
  56. *    - getKbsDiffrence();
  57. *    - getBytesDiffrence(); 
  58. *    - getPrecent();
  59. *    - showPrecent();
  60. *    - getKbLoader();
  61. *    - getByteLoader();
  62. *    - setLoader();
  63. *    - setAction();
  64. *  - Array
  65. *    - nextElement();
  66. *    - prevElement();
  67. *    - getElement();
  68. *    - setElement();
  69. *    - pushArray();
  70. *    - kill(); 
  71. *    - firstElement();
  72. *    - lastElement();
  73. *    - mixArray();
  74. *    - randomElement();
  75. *  - Sound
  76. *    - gotoAndPlay();
  77. *    - gotoAndStop();
  78. *    - play();
  79. *  - String
  80. *    - toArray();
  81. *    - toArray2();
  82. *  - TextField
  83. *    - setDigiClock();
  84. *  - Mouse
  85. *    - getCursor();
  86. */
  87. Math.rad2deg = function(radians) {
  88.         return radians/Math.PI*180;
  89. };
  90. Math.deg2rad = function(radians) {
  91.         return radians*Math.PI/180;
  92. };
  93. Math.distance = function(x1, x2, y1, y2) {
  94.         x = x2-x1;
  95.         y = y2-y1;
  96.         return Math.sqrt((x*x)+(y*y));
  97. };
  98. Math.isDiffrent = function(num1, num2) {
  99.         return num1 != num2;
  100. };
  101. Math.isEven = function(number) {
  102.         return number%2 == 0;
  103. };
  104. Math.isBetween = function(num, num1, num2) {
  105.         return num>num1 && num<um2 ? true : false;
  106. };
  107. Math.isNatural = function(number) {
  108.         return number == Math.round(number);
  109. };
  110. Math.isNum = function(number) {
  111.         return number == parseInt(number);
  112. };
  113. Math.divisible = function(num, div) {
  114.         return num/div == Math.round(num/div);
  115. };
  116. Math.multiplicatable = function(num, multi) {
  117.         return num*multi == Math.round(num*multi);
  118. };
  119. Math.subtractable = function(num, sub) {
  120.         return num-su == Math.round(num-su);
  121. };
  122. Math.additable = function(num, addit) {
  123.         return num+addit == Math.round(num+addit);
  124. };
  125. Math.lowerOne = function(num1, num2) {
  126.         return num1<num2;
  127. };
  128. Math.biggerOne = function(num1, num2) {
  129.         return num1>num2;
  130. };
  131. Math.randomBetween = function(n1, n2) {
  132.         return Math.round(Math.random()*n1)+n2;
  133. };
  134. Math.crossfoot = function(number) {
  135.         var str = new String(number.toString());
  136.         for (i=0; i<str; i++) {
  137.                 return x += parseInt(str.charAt(i));
  138.         }
  139. };
  140. Math.cubeArea = function(width) {
  141.         return (width*width)*6;
  142. };
  143. Math.triangleAngle = function(angle1, angle2) {
  144.         return 180-(angle1+angle2);
  145. };
  146. Math.cosDeg = function(deg) {
  147.         return Math.cos(deg*Math.PI/180);
  148. };
  149. Math.sinDeg = function(deg) {
  150.         return Math.sin(deg*Math.PI/180);
  151. };
  152. Math.toLowerNumber = function(num, div) {
  153.         return !div ? num/10 : num/div;
  154. };
  155. Math.toUpperNumber = function(num, multi) {
  156.         return !multi ? num*10 : num*multi;
  157. };
  158. Math.calculateDuty = function(num, duty) {
  159.         return num+num/100*duty;
  160. };
  161. Math.places = function(number) {
  162.         return number.toString().length-1;
  163. };
  164. Math.root = function(number) {
  165.         while (number/n != n && n<number) {
  166.                 n++;
  167.                 return number/n;
  168.         }
  169. };
  170. Math.circumference = function(radius) {
  171.         return (radius*2)*Math.PI;
  172. };
  173. Math.ruleofthree = function(x, y, a, b) {
  174.         return a ? y/x*a : x/y*b;
  175. };
  176. Math.makePositive = function(num) {
  177.         return Math.abs(num);
  178. };
  179. Math.makeNegative = function(num) {
  180.         return num-num*2;
  181. };
  182. Math.squareArea = function (width,height) {
  183.         return width*height;
  184. }
  185. Math.KBstoBytes = function (num) {
  186.         return num/1024;
  187. }
  188. Math.BytestoKBs = function (num) {
  189.         return num*1024;
  190. }
  191. Math.diffrenceBetween = function(num1, num2) {
  192.         return num2-num1;
  193. };
  194. MovieClip.prototype.drawCilinder = function(x,y,s){
  195.         this.moveTo(x,y);
  196.         z += s;
  197.         x2 += Math.sin(Math.PI/180*z)*5;
  198.         y2 += Math.cos(Math.PI/180*z)*10;
  199.         this.lineTo(x2, y2);
  200. };
  201. MovieClip.prototype.drawSquare = function(x,y,w){
  202.         this.moveTo(x, y);
  203.         this.lineTo(x+w, y);
  204.         this.lineTo(x+w, y+w);
  205.         this.lineTo(x, y+w);
  206.         this.lineTo(x, y);
  207. };
  208. MovieClip.prototype.drawRectangle = function(x,y,w,h){
  209.         this.moveTo(x, y);
  210.         this.lineTo(x+w, y);
  211.         this.lineTo(x+w, y+h);
  212.         this.lineTo(x, y+h);
  213.         this.lineTo(x, y);
  214. };
  215. MovieClip.prototype.drawCircle = function(x,y,s){
  216.         this.lineStyle(s, 0x000000, 100);
  217.         this.moveTo(x, y);
  218.         this.lineTo(x+1, x+0.14);
  219. };
  220. MovieClip.prototype.drawTriangle = function(x,y,w){
  221.         this.moveTo(x, y);
  222.         this.lineTo(x+w/2, y+w/2);
  223.         this.lineTo(x-w/2, y+w/2);
  224.         this.lineTo(x, y);
  225. };
  226. MovieClip.prototype.circleMove = function(si,sp){
  227.   with (this) {
  228.         angle += si;
  229.         _rotation = angle;
  230.         _x += Math.cos(PI/180*_rotation)*sp;
  231.         _y += Math.sin(PI/180*_rotation)*sp;
  232.   }
  233. };
  234. MovieClip.prototype.setCursor = function() {
  235.         Mouse.hide();
  236.         _root.cursor = this._name;
  237.         this._x = _root._xmouse;
  238.         this._y = _root._ymouse;
  239. };
  240. MovieClip.prototype.fitTo = function(target) {
  241.         this._width = target._width;
  242.         this._height = target._height;
  243.         this._x = target._x;
  244.         this._y = target._y;
  245. };
  246. MovieClip.prototype.fitToWindow = function () {
  247.         this._x = 0;
  248.         this._y = 0;
  249.         this._width = Stage.width;
  250.         this._height = Stage.height;
  251. };
  252. MovieClip.prototype.resize = function(w,h) {
  253.         this._width = w;
  254.         this._height = h;
  255. };
  256. MovieClip.prototype.transform = function(x,y,w,h){
  257.         this._width = w;
  258.         this._height = h;
  259.         this._x = x;
  260.         this._y = y;
  261. };
  262. MovieClip.prototype.newpos = function(x, y) {
  263.         this._x = x;
  264.         this._y = y;
  265. };
  266. MovieClip.prototype.clone = function(name,t,d) {
  267.         for (i=1; i<=t; i++) {
  268.                 this.duplicateMovieClip(name+i, d+i);
  269.         }
  270. };
  271. MovieClip.prototype.getKbsLoaded = function () {
  272.     return this.getBytesLoaded()*1024;
  273. }
  274. MovieClip.prototype.getKbsTotal = function () {
  275.     return this.getBytesTotal()*1024;
  276. }
  277. MovieClip.prototype.getKbsDiffrence = function () {
  278.     return this.getKbsLoaded()-this.getKbsTotal();
  279. }
  280. MovieClip.prototype.getBytesDiffrence = function () {
  281.     return this.getBytesLoaded() - this.getBytesTotal();
  282. }
  283. MovieClip.prototype.getPrecent = function () {
  284.     precent = this.getBytesLoaded()/this.getBytesTotal();
  285.     return Math.round((precent)*100);
  286. }
  287. TextField.prototype.showPrecent = function () {
  288.     this.text = this.getPrecent();
  289. }
  290. MovieClip.prototype.getKbLoader = function () {
  291.     total = this.getKbsTotal();
  292.     loaded = this.getKbsLoaded();
  293.     diffrence = this.getKbsDiffrence();
  294.     precent = this.getPrecent();
  295. }
  296. MovieClip.prototype.getByteLoader = function () {
  297.     total = this.getBytesTotal();
  298.     loaded = this.getBytesLoaded();
  299.     diffrence = this.getBytesDiffrence();
  300.     precent = this.getPrecent();
  301. }
  302. MovieClip.prototype.setLoader = function () {
  303.     this._width = precent;
  304. }
  305. MovieClip.prototype.setAction = function (action) {
  306.     if (precent == 100) {
  307.         action;
  308.     }
  309. }
  310. Array.prototype.nextElement = function(old) {
  311.         return this[old+1];
  312. };
  313. Array.prototype.prevElement = function(old) {
  314.         return this[old-1];
  315. };
  316. Array.prototype.getElement = function(Variable) {
  317.         return this[Variable];
  318. };
  319. Array.prototype.setElement = function(ele, con) {
  320.         this[ele]=con;
  321. };
  322. Array.prototype.pushArray = function(array) {
  323.         this.push(array);
  324. };
  325. Array.prototype.kill = function(element) {
  326.         this.splice(element, 1);
  327. };
  328. Array.prototype.firstElement = function() {
  329.         return this[0];
  330. };
  331. Array.prototype.lastElement = function() {
  332.         return this[this.length-1];
  333. };
  334. Array.prototype.mixArray = function() {
  335. var y = this.length;
  336.         for (var i = 0; i<this.length; i++) {
  337.                 var rdm = Math.floor(random(y));
  338.                 var x = this[i];
  339.                 this[i] = this[rdm];
  340.                 this[rdm] = x;
  341.         }
  342. }
  343. Array.prototype.randomElement = function() {
  344.         var y = this.length;
  345.         return this[(Math.floor(random(y)))];
  346. };
MacEvil ist offline   Mit Zitat antworten
Alt 26-10-2003, 17:08   #2 (permalink)
Revived @ Sunday
 
Benutzerbild von MacEvil
 
Registriert seit: Apr 2003
Ort: Nowhereland
Beiträge: 3.244
ActionScript:
  1. Sound.prototype.gotoAndPlay = function(pos) {
  2.         this.start(pos);
  3. };
  4. Sound.prototype.gotoAndStop = function(pos) {
  5.         _root.pos = pos;
  6. };
  7. Sound.prototype.play = function() {
  8.         if (this.position == undefined) {
  9.                 this.start(0);
  10.         } else if (_root.pos) {
  11.                 this.start(_root.pos);
  12.         }
  13. };
  14. String.prototype.toArray = function() {
  15.         arr = new Array();
  16.         for (i=0; i<this.length; i++) {
  17.                 arr[i] = this.charAt(i);
  18.         }
  19. };
  20. String.prototype.toArray2 = function() {
  21.         arr = new Array();
  22.         arr[0] = this;
  23. };
  24. TextField.prototype.setDigiClock = function(s){
  25.         newTime = new Date();
  26.         var hours = newTime.getHours();
  27.         var minutes = newTime.getMinutes();
  28.         var seconds = newTime.getSeconds();
  29.         var time = hours+s+minutes+s+seconds;
  30.         this.text = time;
  31. };
  32. Mouse.getCursor = function () {
  33.         if (_root.cursor == undefined) {
  34.                  return "System Cursor";
  35.         }else {
  36.                 return _root.cursor;
  37.         }
  38. };

Geändert von MacEvil (26-10-2003 um 17:38 Uhr)
MacEvil ist offline   Mit Zitat antworten
Alt 26-10-2003, 17:18   #3 (permalink)
Banned
 
Registriert seit: Jun 2003
Beiträge: 1.276
dinge die niemand braucht.
Magnuss ist offline   Mit Zitat antworten
Alt 26-10-2003, 18:16   #4 (permalink)
filmtip: snatch
 
Registriert seit: Oct 2001
Beiträge: 1.562
und wie schon bei deiner letzten sammlung gilt:

lokale variablen verwenden und kurze Kommentare wären
auch kein Luxus. Abgesehen davon ist vieles einfach falsch
bzw. sinnlos. sorry, mac evil, aber da musst du wohl nochmals
über die bücher

Geändert von Skyla (26-10-2003 um 18:18 Uhr)
Skyla ist offline   Mit Zitat antworten
Alt 27-10-2003, 00:55   #5 (permalink)
mod_rewrite
 
Benutzerbild von sonar
 
Registriert seit: Feb 2003
Ort: München
Beiträge: 15.621
Wenn man sonst gar nix anderes zu tun hat... Besuch doch lieber mal eine Molkerei, dichte die Fenster ab oder streich den Gartenzaun neu.
__________________
RTFM
Wie man Fragen richtig stellt.

Achim Bindannmalweg

Money makes the world go round, fear makes it turn much faster.
(New Model Army)
sonar ist offline   Mit Zitat antworten
Alt 27-10-2003, 01:20   #6 (permalink)
Neuer User
 
Registriert seit: Jun 2001
Ort: Stuttgart
Beiträge: 6.415
und hier die idee fürs nächste projekt,
lokalisier doch das actionscript,und implementiere die dazugehörigen unnützen kommentare die sonst davor stehen würden
aus
ActionScript:
  1. //wechsel zu frame XYZ
  2. this.gotoAndStop(frame)
wird
ActionScript:
  1. //
  2. this.geheDochBitteZuDemFolgendenBildDanke(bildnummer)
übersicht?ach was, dass es deutsch ist und auch noch flash höflich behandelt ist die hauptsache

hier noch ein paar sachen

XML stelle ich mir sehr familiär vor

xml.gibtEsEinKind()
xml.erstesKind()
xml.papa()
xml.mama()
xml.voegeln() //ehm ich meine createElement

das datum sollte dringends lokalisiert werden
year months seconds, da blickt doch keiner mehr durch

es gibt soviel zu tun!
deluxe
Deluxe ist offline   Mit Zitat antworten
Alt 27-10-2003, 01:33   #7 (permalink)
über oder unter dir...
 
Benutzerbild von merlin0815
 
Registriert seit: Dec 2001
Ort: Dulsmountain
Beiträge: 1.657
Zitat:
Geschrieben von Deluxe

XML stelle ich mir sehr familiär vor

xml.gibtEsEinKind()
xml.erstesKind()
xml.papa()
xml.mama()
xml.voegeln() //ehm ich meine createElement
sauber...
(so würde selbst ich das verstehen)
__________________
gruss merlin & peace 4 @ll

eBay -> Erfolgreicher Verkaufen - MotionSell - Die andere Auktionsgalerie für eBay <- VÖLLIG KOSTENLOS
merlin0815 ist offline   Mit Zitat antworten
Alt 27-10-2003, 08:11   #8 (permalink)
Trainman
 
Benutzerbild von Hamster2k
 
Registriert seit: Sep 2001
Ort: Wien, Österreich
Beiträge: 1.324
Och menno
Seid doch nicht so gemein zu ihm!

War sicher eine gewisse Arbeit. Deswegen: Danke für den Versuch, aber es bringt leider wirklich nicht viel. Wenn man etwas aus deiner Sammlung braucht ist es einfacher die Fktn. schnell selbst zu schreiben als sie erst hier zu suchen. Wenn du das nächste mal Zeit und Lust hast(falls überhaupt wieder nach den bisherigen Antworten ) etwas in der Art zu machen, konzentrier dich auf ein Thema und schreib dafür weniger aber umfangreichere Funktionen

Danke, und nimm die vorherigen Posts nicht persönlich, sie meinens doch nicht so

MfG
__________________
So much to learn and so little time.

Ich liebe dieses Forum!!
Hamster2k ist offline   Mit Zitat antworten
Alt 27-10-2003, 09:22   #9 (permalink)
filmtip: snatch
 
Registriert seit: Oct 2001
Beiträge: 1.562
Doch.

Ne, nur Spass. Deinen Tatendrang in Ehren, macEvil.
Das wird schon.
Skyla ist offline   Mit Zitat antworten
Alt 27-10-2003, 09:54   #10 (permalink)
alien
 
Benutzerbild von Smirgel
 
Registriert seit: May 2002
Ort: Colonia
Beiträge: 7.597
jepp. hast dir ja viel mühe gemacht.

aber viele funktionen bringen wirklich nicht den großen nutzen.
ActionScript:
  1. zahl2=makePositive(zahl1);
  2. //-------------------------------------
  3. zahl2=Math.abs(zahl1);
math.abs (hier nur als beispiel) ist ja schon die funktion, die dir eine positive zahl zurück gibt, bringt also nix, das nochmal in eine funktion zu packen. im gegenteil, das macht die swf/fla nur größer.

deine mühe aber in allen ehren
__________________
bei fragen, fragen.
Smirgel ist offline   Mit Zitat antworten
Alt 28-10-2003, 12:03   #11 (permalink)
Revived @ Sunday
 
Benutzerbild von MacEvil
 
Registriert seit: Apr 2003
Ort: Nowhereland
Beiträge: 3.244
@ sonar : *rolleyes*
@ Magnuss : Math.pow(*rolleyes*,2)

@ Smirgel :
Jo... aber gut, da es auch makeNegative gibt.. nur ein Hinweis dass abs eigentlich nix anderes als Positiv machen heisst

@ Deluxe :
Hm.. aber die Funktion geheZu gibbts dann jar gar net..

Btw : Ratet mal wieviel Zeit ich darin investiert habe
MacEvil ist offline   Mit Zitat antworten
Alt 28-10-2003, 20:55   #12 (permalink)
Erstmal n Herri!
 
Benutzerbild von _Hannes_
 
Registriert seit: Aug 2002
Ort: Hamburg
Beiträge: 1.233
also da sich bei dir schon ein gewisses Potential feststellen lässt denke ich mal nich so lange.

mfg

edit: ach ja, MacMoneysack wohnt aber nich im Geldspeicher!
__________________
hannesstruss.de
_Hannes_ ist offline   Mit Zitat antworten
Antwort

Lesezeichen

Themen-Optionen
Ansicht

Forumregeln
Es ist Ihnen nicht erlaubt, neue Themen zu verfassen.
Es ist Ihnen nicht erlaubt, auf Beiträge zu antworten.
Es ist Ihnen nicht erlaubt, Anhänge hochzuladen.
Es ist Ihnen nicht erlaubt, Ihre Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks sind an
Pingbacks sind an
Refbacks sind an



Alle Zeitangaben in WEZ +1. Es ist jetzt 18:28 Uhr.

Domains, Webhosting & Vserver von Host Europe
Unterstützt das Flashforum!
Adobe User Group


Copyright ©1999 – 2012 Marc Thiele