Convert Timeline Code to Document Class

For a few different reasons I decided to write some php code to convert timeline code to a document class. The script is done and it seems to work pretty nicely. I’m sure there are a few bugs, but I’ve tested around 30 snippets from this site and they all worked.

To test it out:

1) just take the below code (or any other timeline code), copy it to your clipboard
(The code doesn’t have to be small, I did a test with 300 lines of timeline code and it worked just fine)

x = stage.stageWidth / 2;
y = stage.stageHeight / 2;
var xp:Number = 0, yp:Number = 0;
var r:Number = 0, t:Number = 0;
var speed:Number = .07;
var scale:Number = 20;
var plot0:Shape = Shape(addChild(new Shape()));
var plot1:Shape = Shape(addChild(new Shape()));
plot0.graphics.lineStyle(0,0x000000);
plot1.graphics.lineStyle(0,0x000000);
addEventListener(Event.ENTER_FRAME, onLoop);
function onLoop(evt:Event):void {
	 r =  scale * Math.sqrt(t);
	 xp =  r * Math.cos(t);
	 yp =  r * Math.sin(t);
	 t += speed;
	plot0.graphics.lineTo(xp, yp);
	plot1.graphics.lineTo(-xp, -yp);
}

2) go to this page and follow the instructions:
http://actionsnippet.com/timeline_to_doc.php

I used this script to convert a few snippets from this site to work on wonderfl.net

Have a look at them here.

In the next few days I may add a button to all code snippets that allows you to convert the code to a doc class…

The script adds import statements automatically, I may however have missed a few packages, so if the generated code is missing an import statement, let me know and I’ll fix it…

This entry was posted in misc and tagged , , . Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

10 Comments

  1. Rafael Dery
    Posted August 6, 2009 at 11:44 am | Permalink

    very nice tool…..very handy to convert his code. But I´m fascinating of all your tutorials. I´m still looking every day on your site and check your newest posts….maybe I learn something for my own blog ;). I just started a own Flash Content Manager.. http://blog.radykal.de/?page_id=44. But it´s a german blog.

    Greetings from Germany

    Rafael

  2. Posted August 6, 2009 at 11:47 am | Permalink

    cool blog, glad you like the site… I wonder if there’s a wordpress plugin that uses google language tools so you could auto-generate an english rss feed…

  3. Rafael Dery
    Posted August 6, 2009 at 12:45 pm | Permalink

    Yeah….I found one and I already installed it to my blog. Check please and tell me if the translation works well or if there are many mistakes. So you can use it too, if you want. Her is the linkage to the wordpress plugin.

    http://www.nothing2hide.net/wp-plugins/wordpress-global-translator-plugin/

  4. Posted August 6, 2009 at 4:11 pm | Permalink

    Cool!
    I didn’t know you were on Wonderl Zevan. Needless to say, I’m now following you.

  5. Posted August 7, 2009 at 4:29 am | Permalink

    This is an excellent tool! I don’t know why it not been done before!!!
    This should definitely come in handy :)

  6. Posted August 7, 2009 at 5:43 am | Permalink

    I bet you could do this far easier using addFrameScript method

  7. Posted August 7, 2009 at 6:17 am | Permalink

    very useful ^^

  8. Posted August 7, 2009 at 7:33 am | Permalink

    @mack3d Well, in some cases addFrameScript would work, but if you were looking to do something the easy way - you could get away with just throwing everything in the constructor and and adding import statements (as the title of this blog suggests) - I wanted the script to do pretty much what I would do if I were actually going to convert something to a doc class manually. Which is pretty much what it does minus some minor spacing issues I need to fix…

    I realized also… that this could potentially be a useful tool for explaining the document class to someone…

  9. Posted August 9, 2009 at 1:25 am | Permalink

    Useful tool for those of us using flex, it makes it easier and more comfortable for us to paste your code and poke with the variables to get a better idea of how it works as I imagine is the idea of this site.

    Looking forward to seeing your experiments on Wonderfl!

  10. Posted August 9, 2009 at 6:59 am | Permalink

    I took a little break from this, but I think I may add a button to the syntax highlighter that converts the snippet using this code… wonderfl is fun

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*