How to do the Flash animation thing like in the Sketchfu site.

Discussion in 'Graphics & Multimedia' started by misohoni, Dec 13, 2007.

  1. #1
    Sketchfu.com enables a user to make a drawing, but how can it record and replay the animation?

    Could anyone do this for me or explain how it's done?
     
    misohoni, Dec 13, 2007 IP
  2. samedi

    samedi Peon

    Messages:
    75
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Hi
    its not complicated at all.
    in a nutshell (as2):
    declare your variables like linewidth, and color, and stuff
    make the buttons to enable the user to change those variables
    you have to declare an array, you will record the user actions into it
    draw the stageMC
    write the functions for stage mc
    there are need to be an onPress and an onRelease function
    and a drawing/recording function it has to be associated with a variable, like this:
    var draw_n_rec:Function=function(){
      bla bla bla
    }
    Code (markup):
    the onPress function looks like this:
    stageMc.onPress=function(){
      stageMc.onEnterFrame=draw_n_rec
    }
    Code (markup):
    the onrelease:
    stageMc.onRelease=function(){
      delete stageMc.onEnterFrame
    }
    Code (markup):
    basicly the trick is that in the draw_n_rec function you create an object, in wich you "save" the mouse position, the actual linesize, line color, etc, and a time variable. push this object into the array you have declared previously. And draw out to the stage the current step. And because we have this function as an onEnterFrame, this will happens in each frame. If the user releases the mouse button the recording stops. simple, isnt it?
    you can create a function to play back the drawing. it should simple go over the array and repeat the steps.

    you have to work out the details (there is a few:D) but this is the concept of it, and if you know flash it shouldn't be too hard

    feel free to pm me :)
     
    samedi, Dec 28, 2007 IP
  3. samedi

    samedi Peon

    Messages:
    75
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    oh, and if you want your application to be able to save the data you have to use php or similar server side script.
     
    samedi, Dec 28, 2007 IP
  4. wassim

    wassim Well-Known Member

    Messages:
    322
    Likes Received:
    21
    Best Answers:
    0
    Trophy Points:
    110
    #4
    Hi,

    I did a project like that a while ago, I didn't use onEnterFrame (it would kill the CPU if you're running 24 fps), I used onMouseMove :) since drawing will only occur on mouseMove. The saving was done with delta packets and a webServiceConnector.

    The application integrated user registration and login as well.

    Pretty cool.

    I can build you a custom solution.

    If you're interested, drop me a line via pm or through my site:

    http://www.sidani.info

    Here's the portfolio:


    http://www.sidani.info/portfolio/

    Regards.
     
    wassim, Dec 28, 2007 IP
  5. samedi

    samedi Peon

    Messages:
    75
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    yeah, wassim is right, onMouseMove better than onEnterFrame for this
     
    samedi, Dec 28, 2007 IP
  6. misohoni

    misohoni Notable Member

    Messages:
    1,717
    Likes Received:
    32
    Best Answers:
    0
    Trophy Points:
    200
    #6
    Guys, I'm still looking for a flash programmer to help with this? Anyone on DP available for this paid project?
     
    misohoni, Feb 23, 2008 IP