|
Author |
Topic: Language Comparison: P5/Python/DBN/ActionScript (Read 535 times) |
|
REAS
|
Language Comparison: P5/Python/DBN/ActionScript
« on: Jan 24th, 2003, 4:43pm » |
|
I've posted an abbrieviated language comparison between a few languages at: http://www.proce55ing.net/reference/compare/index.html My understanding was that Python has many different drawing packages and none are included with the standard download so i didn't include Python graphic translations. Can anyone take care of the ActionScript translation?
|
|
|
|
REAS
|
Re: Language Comparison: P5/Python/DBN/ActionScrip
« Reply #2 on: Jan 25th, 2003, 7:39pm » |
|
Thank you Martin. Jim Qode sent us a list as well. It's currently posted at: http://www.proce55ing.net/reference/compare/index.html There are many differences between the two lists. Can the two of you please explain the differences? Best, Casey
|
|
|
|
XemonerdX
|
Re: Language Comparison: P5/Python/DBN/ActionScrip
« Reply #4 on: Jan 26th, 2003, 7:39am » |
|
A few comments on the ActionScript bit... Quote:background of the movie may be set using the setRGB method in flash. |
| This is not true, there is no direct way to access or change the movie's background using ActionScript. The example mentioned doesn't do this either, it uses a movieclip (an object) that is below all other objects and the color of this movieclip is changed, thus making it appear as if the movie's backgroundcolor has been changed. 'MovieClip.beginFill(0xFF9900,a)' is the ActionScript drawingAPI equivalent of fill(...), altho it also requires 'MovieClip.endFill()' after drawing the shape of the fill. http://www.macromedia.com/support/flash/action_scripts/actionscript_dict ionary/actionscript_dictionary509.html 'MovieClip.lineStyle(x,0xFF9900,a)' is another one of the new drawingAPI methods available inside FlashMX to create lines from scratch thru code (which was not possible in previous versions of Flash where the user had to work with pre-defined movieclips etc). So both 'lineStyle' and 'setRGB' can be used as an equivalent of stroke. http://www.macromedia.com/support/flash/action_scripts/actionscript_dict ionary/actionscript_dictionary535.html Drawing a point in ActionScript can be as simple as: this.lineStyle(1); this.lineTo(0.5,0); In ActionScript loop's like do {...} while(...) and while(...) {...} will *not* render each iteration onto the screen, therefore you will not see an 'animation' like you do with P5's void loop() {...}. Flash will run the loop for as long as it can (it gives a warning message after 15 secs tho) and will display the results *after* the loop has finished, halting *everything* visible inside the movie in the mean time. So this is hardly an equivalent. A more appropriate equivalent would be 'MovieClip.onEnterFrame' which runs a funtion every frame (the result of which is displayed on each frame) http://www.macromedia.com/support/flash/action_scripts/actionscript_dict ionary/actionscript_dictionary546.html Quote: Actually 'var' has a very real purpose & need. A variable declared inside a function using 'var' is local to that function and will not be available after the function has completed, a variable declared inside a function without using 'var' will continue to be available after the function has completed... Small example: myFunc = function () { var var1 = "this is var1"; var2 = "this is var2"; } myFunc(); trace(var1); // output: undefined trace(var2); // output: this is var2 http://www.macromedia.com/support/flash/action_scripts/actionscript_dict ionary/actionscript_dictionary816.html Etc...
|
|
|
|
Martin
|
Re: Language Comparison: P5/Python/DBN/ActionScrip
« Reply #5 on: Jan 26th, 2003, 10:23am » |
|
i see i see. thanks for the tips/clarifications.
|
|
|
|
REAS
|
Re: Language Comparison: P5/Python/DBN/ActionScrip
« Reply #6 on: Jan 31st, 2003, 10:24am » |
|
I have posted my attempted synthesis of all comments: http://www.proce55ing.net/reference/compare/index.html Did I miss or mistake something?
|
« Last Edit: Jan 31st, 2003, 10:25am by REAS » |
|
|
|
|
Dara
|
Re: Language Comparison: P5/Python/DBN/ActionScrip
« Reply #7 on: Jan 31st, 2003, 10:58am » |
|
hi, Color>Fill for Action Script beginFill (0x006699, alpha); beginGradientFill(filltype, colors[], alphas, ratios, matrix);
|
|
|
|
Martin
|
Re: Language Comparison: P5/Python/DBN/ActionScrip
« Reply #8 on: Jan 31st, 2003, 3:03pm » |
|
hi casey, er... one thing. misspelled my name. hehe. thnks!
|
|
|
|
XemonerdX
|
Re: Language Comparison: P5/Python/DBN/ActionScrip
« Reply #9 on: Feb 4th, 2003, 1:21am » |
|
The AS-equivalent for the point(30,20) example is wrong, it should be: lineStyle(x); moveTo(x1,y1); lineTo(x1+0.5,y1); The '+0.5' does need to be added (it has to be at least 0.15, doesn't matter if it's added/substracted from the x or y component). And like mentioned before in my previous reply, a loop made in AS ('do{...}' etc) will *not* render the result of each iteration, but only the result *after* the loop has finished completely, whereas 'void loop() {...}' *does* render each iteration in P5, so not sure if the equivalence works there... I would suggest 'onEnterFrame = function () {...}' which *does* render the result every time it is called in AS...
|
|
|
|
Martin
|
Re: Language Comparison: P5/Python/DBN/ActionScrip
« Reply #10 on: Feb 4th, 2003, 8:44am » |
|
logic of while(true){//stuff}; works ... hmm... i have an example up at www.instituteofmedia.com/diwa.html but i stopped it at 500... will make one that's infinite later.
|
|
|
|
JimQode
|
Re: Language Comparison: P5/Python/DBN/ActionScrip
« Reply #11 on: Feb 4th, 2003, 6:10pm » |
|
about the point(30,20) subject: moveTo(x1,y1); lineTo(x1,y1); doesnt draw anything in actionscript. and 0.15 (which is a smaller number than 0.5) draws a very faint dot because of the anti-aliasing algorithm of flash.
|
--- End Of Transmission ---
|
|
|
XemonerdX
|
Re: Language Comparison: P5/Python/DBN/ActionScrip
« Reply #12 on: Feb 5th, 2003, 5:36pm » |
|
Quote: 0.15 (which is a smaller number than 0.5) draws a very faint dot because of the anti-aliasing algorithm of flash. |
| This depends on the thickness set in the lineStyle statement, if you use thickness 2 the point is clearly visible. The only reason I mentioned 0.15 is that AFAIK it is the smallest length possible for a line that will still be drawn on the screen, nothing gets drawn if you use for instance 0.14 (or less), even if you set the thickness to 255 (the maximum value). Quote: logic of while(true){//stuff}; works ... |
| Unless you have *some* sort of frame/time-based loop in your program (frame-loop, onEnterFrame, onClipEvent(enterFrame), setInterval, etc), a while-loop by itself will *not* render the results of each iteration on the screen, only the result of the last iteration of the while-loop before it exits... If you think you've managed to do it somehow, *please* share your code/method, cuz even on the FlashCoders list (which is the most hardcore AS-list) noone's ever done it, nor does anyone dispute the fact that it cannot be done.
|
« Last Edit: Feb 5th, 2003, 5:45pm by XemonerdX » |
|
|
|
|
Martin
|
Re: Language Comparison: P5/Python/DBN/ActionScrip
« Reply #13 on: Feb 6th, 2003, 2:58pm » |
|
precisely. come to think of it, flash has a 200,000 iteration limit... i guess this is a great limiting factor in flash (or is it?) hack your own flash?
|
« Last Edit: Feb 6th, 2003, 2:59pm by Martin » |
|
|
|
|
XemonerdX
|
Re: Language Comparison: P5/Python/DBN/ActionScrip
« Reply #14 on: Feb 7th, 2003, 11:29pm » |
|
There are very easy ways of dealing with the 200,000 iterations problem (not to mention that doing 200,000 iterations in Flash slows most computers down to a grinding halt since Flash isn't a speed-freak unfortunately, so why even attempt, hehee), such as using a setInterval that calls a function that does for instance 1,000 of all the necessary calculations every time it calls the function, which also has the advantage the screen gets updated more frequently... There are more workarounds obviously... The iteration limit is only a minor problem in Flash/ActionScript IMHO (and I *love* ActoinScript), cuz it's easy to deal... If only Flash had the speed of Java/P5 One can only dream I guess, hahaha...
|
|
|
|
|