How Maple helps
Sometimes it’s good to test some math model before coding it into ActionScript or any other language, draw some cool graphs and play with parameters. Of course you could write a simple flash application to draw graphs for you but why waste time if there are a lot of math software around? In school we used Maple, so from time to time I use it to check stuff before actually coding it. I have to say that I’m not good at it but my knowledge is enough for my own tasks.
Well, right now I need to code a pseudo random movement. I need some kind of a periodic pattern with bursts and decaying.
So, I opened Maple and set several constants I had in mind.
minAmp — minimal value of global amplitude,
maxAmp — maximum value,
minLen — minimal wave length,
deltaLen — minLen + deltaLen = maxLen — maximum wave length,
speed — wave speed (rendered useless).
After that I wrote functions for amplitude.
In the example I used constant wave length, didn’t have time to play more with it. Here everything is simple. We have some x value from which wave length and amplitude is counted. Both are periodical.
Here’s the graph.
Now we can add one more sin which will be limited by this amplitude.
We are getting a periodical movement but it’s too boring. Here goes the magic.
This function generates all the randomness. Simply put, there’s some seed which grows from 0 to 1 (actually a bit more) by dseed and after it reaches 1 it goes back to almost zero and dseed (delta seed — seed change speed) changes to some other value controlled by minRand and ampRand. At the end we get new value in the last line.
That’s how we get such a jerky rhythm, and because of dseed the movement can be be fast and slow. And everything is limited by periodic amplitude.
Let’s check the result.
This is just what I wanted. If you play with parameters a bit ou can get very interesting results.
Here’s the example. You shouldn’t stare it for a long time q: It uses much CPU so I recommend you to close the tab after you finish reading.
Continue Reading | No Comments
Tags: Effect, Maple, Randomness
Why not Unity3d use Flash?
Flash could be great in Unity3d for interfaces, minigames and even animated textures. They should definitely research the possibility of using it. Maybe it’s possible to write a custom Flash Player how the guys from Scaleform did.
Prolog for Mac
Let’s assume that you need to set up Prolog for OS X. If you are still here let’s continue.
After reading some book from 80s about Prolog I found that language to be interesting and I decided to write some simple things in it. But I had to install it somehow on my Mac preferably without any stupid virtual machines. So here’s what I ended with.
- All crossplatform solutions are based on Eclipse, so first of all you need Eclipse. There are a lot of versions, but I chose the one with less stuff I don’t need because I won’t use anything related to Java development.
- The first plugin I tested was PDT which is too old and doesn’t work with Eclipse 3.5, I downloaded 3.1 but haven’t tested it because I got another plugin which works — ProDT. This is just what I need. From Downloads you should choose the smallest file.
- For ProDT to work you need SWI-Prolog — some kind of opensource Prolog.
- I’m not sure if SWI-Prolog requires MacPorts, but anyway I recommend you to install it. It’s useful.
- Extract ProDT to eclipse/dropins/prodt/eclipse/plugins, run eclipse which installs it automatically.
- After that in ProDT preferences ( Eclipse -> Preferences -> Prolog -> Compilers -> Swi Compiler ) set compiler path which is at
/opt/local/bin/swipl. - Switch to Prolog view Window -> Show Perspective -> Other… -> Prolog.
That’s it. Now you can test if it actually works:
yes( one ).
yes( two ).
Run and write in console:
yes(X).
x = one ;
x = two.
Tags: Eclipse, Mac, MacPorts, PDT, ProDT, Prolog, SWI-Prolog
Speed vs. OOP
As I found out, AS3 compiler is too stupid to add even trivial optimizations.
I’ve been trying to optimize one of my heavy libraries I use everywhere for some time. It parses a lot of XML using e4x and creates many objects which it has to check using isSomething() function which is just 3 lines of code. So, this function is executed for every single object created.
Let’s check the test now.
var t: int;
var v: int = 5;
var w: int = 6;
for ( var i: int = 0; i < 5; i++ )
{
t = getTimer();
for ( var j: int = 0; j < 1000000; j++ )
{
var k: Boolean = func( v, w );
//var k: Boolean = v > w;
}
trace( getTimer() - t );
}
private function func( v: int, w: int ): Boolean
{
return v > w;
}
This executes on my Macbook Pro for 400ms.
If you uncomment the second line and comment the first one, execution time drops to 90-100ms. Which is 4 times less. But this is for 100000 calls, you can say. Remember that 30fps = 33ms for every frame, so one millisecond here and one millisecond there give noticeable result. And as I said the same short function is executed for every object. And there can be a lot of them. Though I don’t have to do it every frame but I don’t want my application freeze in the beginning either.
Moreover,
var t: int;
for ( var i: int = 0; i < 5; i++ )
{
t = getTimer();
for ( var j: int = 0; j < 1000000; j++ )
{
var k: int = value;
//var k: int = _value;
}
trace( getTimer() - t );
}
public function get value(): int
{
return _value;
}
it’s the same for getters and setters because they are also functions.
So I just replaced all calls of this function for actual code (6 occurrences). Every programmer who knows OOP will say that it’s bad to copy and paste code, if he doesn’t know why I did that. He might also go post on the forums that I am a noob, make a function of these pasted code snippets and will be proud of himself.
Here’s the question. Speed or OOP? While AS3 compiler is so dumb and can’t inline simple functions like this I’ll have to break readability in favor of execution speed.
Tags: Framework, Inline, OOP, Optimization, XML
mxmlc, ant and metadata
Just not to forget how to make mxmlc and task save my custom metadata.
<target name="compile.test" >
<mxmlc file="${source.dir}/TestsLauncher.mxml" output="${bin.dir}/tests/TestsRunner.swf" keep-generated-actionscript="false">
<load-config filename="${FLEX_HOME}/frameworks/flex-config.xml"/>
<source-path path-element="${FLEX_HOME}/frameworks" />
<source-path path-element="${source.dir}" />
<compiler.library-path dir="${libs.dir}" append="true" >
<include name="fluint.swc" />
<include name="alcon.swc" />
</compiler.library-path>
<keep-as3-metadata name="Meta1"/>
<keep-as3-metadata name="Meta2"/>
</mxmlc>
</target>
What do you think about me?
Of course everyone saw the site. Some of you like it, others don’t. When my internal energy depletes (which doesn’t happen often), looking for inspiration I open valyard.ru. I know it’s strange to steal back energy from your own creation where you put your own creative energy before. But it seems that this half a year I’ve been working on it I put there so much that I am using it even now.
And here are some of feedback messages I got since the launch.
***
what the hell?
***
What a good use of creative juice, It’s really just too bad you never thought of the other 80% of web surfers who can’t see it.
***
congrats on the FWA. loving the whole vibe of the site.
***
im a student from america, im jelous of your skill
***
what the hell is going on with thefwa judges !?
***
Create flash website, really well done design and all. Keep up the good work.
***
powerful slick website.
haven’t seen such a nice website for ages now. keep it up!
***
Overall the graphics included the logo and first of all the typography are really really unaesthetic . Graphics: past time flash intro style / Typo: finally unreadable. So, hopefully your coding skills are much better…
***
unusable, and unreadable.
***
Very great !!
Congratulations !
***
I can’t get the fwa judges desicion and personally don’t like it very much but lots o effort goes around here and site has a good amatour feeling
***
Is this a pathetic joke?
***
i’m sorry but i don’t like your site. the ergonomy is no good at all, the text is unreadable, and i really don’t understan d why you got an FWA SOTD…
***
I’m sure you can program quite well, but I feel as though you’ve turned away a lot of people by making them wait for the site to load. There is also way too much going on, I can barely focus on typing. No contrast, either.
***
It’s really unusable. I realize this is a place for”you” and what you like, but you’re going to scare away potential clients by connecting it with your biz.
***
I like the design but the readability is poor. I went through the portfolio and I see that U do more than just web sites. Overal 9/10 :)
***
this is fucking good!
***
This is the most amazing website made with flash I ever seen. Love the colours, the music… the whole theme is great! I hope to be able to do something like that someday!
***
This is a very diferent site. Great design, colors, interactions, sounds and fun. Good job indeed.
***
G R E A T ! !
RESPECT!
***
Programming skills and audio abilities are very nice. Design application / readability / navigation is pretty lame though and not very practical.
***
This website is extraordinary terrible. Can’t even read a thing and the colors make my eyes bleed. Keep on coding but please don’t put your hands on graphics anymore. Definitely not worth any award.
***
AWESOME! Teach me your ways!? :P
***
THIS IS THE WORST SITE I HAVE EVER SEEN!!!!
***
There is such a thing as too much going on!! This is really terrible. Flash isnt considered high art or anything but no need to drag it thru the gutters! This style hasnt been remotely popular for ten years too btw.
***
Nice work, looks great, Im full of admire.
***
that this site got an FWA has to be a joke.
***
This site is SO Ace Frehley…
***
Great pprogramming / sound / and bravery. Not so great design / practicality / usefulness. But none the less, you are more skilled than I :)
***
Holy Crap dude, my monitor is about to explode! Amazing detail
***
Nice website, good job :)
***
waaaaaaaaay too much faff for pretty standard content. can’t see why it’s got fwa… sorry
***
Dear Valentin, Your are an amazing Flash design programmer. I run a creative firm in Dubai, UAE. I look upon you as an inspiration to create.
***
A nice work, I really feel an inspiration on planet of the drums(older version) from weworkforthem. Never the less a good work
***
amazing skills bro, I must say I hate the colors or maybe just the purplepink
***
Colors, design, animation… everything is brillant! :)
***
Thank you for the inspiration. I have just decided on a web host, and am now keen to look at building a flash based website. Give me pointers !
***
Mad props for the tech side of the site….. but the design is the worst thing i’ve seen in a while….. for real…. what up with all the brushes dude?
anyway….. except for that comment… this shit rocks!!!
***
very artistic. too busy though.
***
i dont enjoy the layout and colors but i must say you have superb scripting skills..keep it up!!
***
So COOL!!
***
Ya your a coder not a designer good code. Your still stuck in 1999 design. Try going to a design class to step up your game.
***
omg, what a creative abstractivity, great work lad
***
I thought this style died forever after its bloom in 1999-2001… Nothing new, but I’m glad to see it again after this huge wave of minimalism…
***
hey man ur site is very very nice yaaar…..
***
took me one hour to get in but after visiting i think its one of the most amazing performance of the year
***
tienes buena programacion, donde aprendiste
***
DAMNNNNNNN!!!!!!! its its damn!!! I need a tutor like you! is it possible?
***
Alien Science!!! love the ripple effect
***
I really like the effects – the ripple effect is cool! – but your color scheme is awful. The white text on the light blue back ground is difficult to read at best. I’m not even going to go into the navigation – RIDICULOUS!!!
***
man……this doesn’t look very new. Also I’m not a fan of the colors you have chosen. I’ve seen all of your background art on istockphoto.com
***
Muy interesante todo lo que realizas, tienes mucho talento!
***
Wow mate you’ve got it going on, never seen anything like your site before, very good well done .
***
its a russian solution to a russian problem i guess…
***
Wow- is this real or what…!
***
mmm feels like 90′s flash revenge!!
***
amazing! it feels like i’m in a futuristic world.
***
Great! the color the style the man you!
***
Great Site, I am a Graphic Student and just being introduced to Flash this is very inspriring!
***
GARBAGE. THIS SITE IS PURE GARBAGE
***
hey… your concept just like my website !!!! but mine still rich sound and kick-ass graphic than yours !!! go to hell !!!my
***
Jesus Christ, your website is the best (and bad for read) that i’ve ever seen! Anyway, your site really kick ass! Congratulations!
***
Making diiferent is something different for the normal people. I like your site buddy! Cool
***
Love the design and feel of the site, very unique and I LIKE that it is not easy to use. Very innovative in every sense of the word.
***
This site is awesome, gave me something interesting to study in my media class.
***
holy crap man. this is the gayest shit i’ve ever seen. this is so 1998 and to add to the insult you outputted it for a minimum of 1280×960
***
Just started studying multimedia designs myself, and you are by far the biggest flash motivation and inspiration sorce i’ve got so far!
***
damn dude, awsome.
Continue Reading | No Comments
Tags: Energy, Feedback, valyard.ru
Importing assets
Separating graphical/sound assets and actual logic is a very good practice. It allows to avoid a lot of problems. For some time I’ve been using compiled SWFs with ActionScript skin classes embeding symbols from that SWF using [Embed] meta tag. But recently I came across much better solution using SWC.
So the algorithm is the following:
- Create a new AS project in Flex Builder.
- Create a new FLA at ‘assets/assets.fla’.
- In Publish Settings of that FLA set ‘Export SWC’ checkbox.
- Create and export assets via ‘linkage properties’ as something like ‘assets.MySymbol’.
- Publish SWC.
- In Flex Builder add this SWC at Project -> Properties-> ActionScript Build Path -> Library Path -> Add SWC.
- Now in Flex Builder we can import and use assets.MySymbol and IDE knows about it and its type.
Flex on Rails is too fast
Ruby on Rails evolves so fast that at version 2.3.2 all the code from a year 2008 book doesn’t work in April 2009.
Well, Flex + Ruby on Rails is great, the speed with which simple applications are made is astonishing. I’m reading right now Flex on Rails: Building Rich Internet Applications with Adobe Flex 3 and Rails 2 and as I said every once and a while I get stuck into compatibility problem.
Right now the problem is the following — in Flex HTTPService class though it says that method = “GET|POST|PUT|DELETE”, but the actual data is sent with GET or POST (for some reason I’m sure that 90% users don’t even know that PUT and DELETE exist). But in case with RoR they are essential, for example GET accounts/1 returns account information, PUT accounts/1 updates account and DELETE accounts/1 deletes an account. The book says just that and as a workaround it suggests to add ?_method=put to URL. But in 2.3.2 it doesn’t work anymore. Trying to do that we get
ActionController::MethodNotAllowed (Only get, put, and delete requests are allowed.)
Google says that I should to send method=put with request itself. Requests are sent in XML but I can’t have 2 roots in AS3 XML, so <_method>put</_method><data /> doesn’t work. Wrapping the whole construct into another root fails.
After googling a bit more I found out that I must set header HTTP_X_HTTP_METHOD_OVERRIDE = PUT. But it didn’t work. I almost gave up but visited this chinese link where our communist friend solved the problem!. It seems that Rails somehow adds to headers another HTTP_ prefix and doesn’t know what to do with things like HTTP_HTTP_X_HTTP_METHOD_OVERRIDE = PUT.
So, here’s the code which works
<mx:HTTPService id=”accountsUpdate”
url=”{CONTEXT_URL}/accounts/{accountsGrid.selectedItem.id}”
method=”POST” resultFormat=”e4x” contentType=”application/xml” headers=”{{X_HTTP_METHOD_OVERRIDE: ‘PUT’}}” >
</mx:HTTPService>
I hope that this text helps people trying to learn Ruby on Rails and how it works with Flex.
Tags: 2.3.2, Flex, Flex on Rails, Headers, HTTP, HTTPService, RoR, Ruby, X_HTTP_METHOD_OVERRIDE







