A Flash Developer Resource Site

Results 1 to 9 of 9

Thread: moving elements

  1. #1
    13 yr old Flash Whizz :)
    Join Date
    Mar 2003
    Location
    UK
    Posts
    61

    moving elements

    ok,

    Ive got a load of tile on this movie.
    When you click on 1 of the squares. This Green dot goes to the x and y position of the square that you clicked on. but...

    I want to make it so that when you click on one of the tile, the dot moves gradually to the new x and y positions.

    So you can c it moving from 1 place to another.

    Please have a look (Attatchment)

    TAR!
    Attached Files Attached Files
    Luke Coulton, User since V3.0

  2. #2
    Senior Member
    Join Date
    Mar 2003
    Posts
    136
    I changed the logic in your movie to do what you want
    It now calculates the offset and moves it closer by increments

    if(dx==bx)
    {}
    else
    dude.position.x = dx - ((dx-bx)/5)
    dx=dude.position.x
    }

    if(dy==by)
    {}
    else
    {
    dude.position.y = dy - ((dy-by)/5)
    dy=dude.position.y
    }
    Attached Files Attached Files
    Last edited by carnwath; 04-12-2003 at 01:43 PM.

  3. #3
    13 yr old Flash Whizz :)
    Join Date
    Mar 2003
    Location
    UK
    Posts
    61

    thankx.... but

    THANKX,

    Ok, I don't have any knowledge of Javascript, but i intend to learn.

    can you tell me what the script is all about, what all the stuff is that is in the script. If ya know what i mean.

    What is DX? BX? DY? BX?

    thankx again
    Last edited by Jiblob; 04-12-2003 at 03:09 PM.
    Luke Coulton, User since V3.0

  4. #4
    Senior Member
    Join Date
    Mar 2003
    Posts
    136

    javascript

    If you look at the copy of your original, plus my changes in the mymove.zip which I uploaded in the previous posting ---

    Note that each time a button is clicked, instead of making the dude.position.x = button.position.x I do this instead -

    dx = dude,position.x
    bx = button.position.x

    dy = dude,position.y
    by = button.position.y

    and this code is in every one of the twelve buttons, making dx, dy a variable holding the current dude x and y cordinates and bx,by the position coordinates of the button.

    Now I add an action 2 times/second to move the dude a small amount in the x and y direction and save it in dx and dy again

    dude.position.x = dx - ((dx-bx)/5)
    dx=dude.position.x

    dude.position.y = dy - ((dy-by)/5)
    dy=dude.position.y

    This action repeats until dx==bx and dy==by by which time the dude is exactly over the square button.

    I chose the timing of the action ntimes/sec and the change amount ((dy-by)/5) until I got a movement which lasted about a second. If you made it be ((dy-by)/10) it would take about two seconds to complete etc etc.

    I hope you understand what this all means. The future of 3dfa is tightly linked to actionscript/javascripting for a couple of reasons and you should keep visiting this discussion group where I will be posting open-source examples in the next week or so.

    The most important reason is that scripting is the best way to perform anything which is interactive and needs a calculated result.
    In your example you want the dude to glide to the spot.

    In my examples elsewhere I want the dude to navigate a maze under the users control while hunters find their own way around the maze (by programmatically testing where their next step will be)

    3dfa without scripting is no better than Swish, but with scripting it is in my opinion better than Macromedia Flash, for one reason. 3dfa has created a simple interface to allow you to paint objects, add buttons and edit boxes and now since v3.72 the ability to do programming. In Macromedia Flash the integrated designer has grown enormous and so its complexity. True, it is the market leader and you can do very minute detailing, kerning etc etc on a level with Adobe, for truly commercial quality work, but the learning time, cost and personal commitment is huge.

    3dfa can be learned fairly quickly and produces acceptable quality graphics though I wish there was a zoom capability for tiny detail movement. For cartoon style graphics its great.

    I will post a demo shortly showing how to communicate between parent and child movies, something which is useful to allow gamers to make sprite (attacking force) movies within control (main) movies so that the enemy attackers can easily be changed in defferent games.
    Last edited by carnwath; 04-12-2003 at 05:18 PM.

  5. #5
    Senior Member
    Join Date
    Jan 2003
    Posts
    169
    I would agree with the zoom feature thing if there was an easy tool for doing it without using a screen magnifier or anything... and there already is, in v4 beta 2. At the very top just before the play movie button are the buttons that control the zoom. They are, from left to right:

    1. Zoom in,
    2. Zoom out,
    3. Zoom to Window, and
    4. No zoom.

    Just to not be confusing to the location of the buttons, they are under the movie name in the property sheet, NOT on the toolbar.

  6. #6
    Senior Member
    Join Date
    Mar 2003
    Posts
    136
    Is this zoom while in say the Paint Image painter ?

    I want to zoom in on a section to tweak a point position like in Swish.

  7. #7
    Senior Member
    Join Date
    Jan 2003
    Posts
    169
    It's in the Movie properties window. And it affects the entire view - no zoom to location is available. But it should be enough - I suppose you will have to scroll to the position you want in the meantime if the zoom is larger than the window can display without enlarging your resolution.
    Last edited by JSDvs9172; 04-12-2003 at 06:53 PM.

  8. #8
    Senior Member
    Join Date
    Mar 2003
    Posts
    136
    Then if any 3dfa staff are reading, add that to the V5 wishlist

    When moving point during morphing or tweaking a paint object it would be really nice to be able to zoom in like Swish to see a close-up area where you are working...

    I know, if all the ideas were implemented it would become as busy, and monstrous as Macromedia and I dont want that at all.

  9. #9
    Senior Member
    Join Date
    Jan 2003
    Posts
    169
    That's a good idea. Maybe you should mail that to [email protected] as a feature request.

    >>>Adding a little extra I just thought about<<<

    While I'm at it, let me remind you that we're still on beta 2 of v4, so if they do another beta it may be possible to have it in that.
    Last edited by JSDvs9172; 04-12-2003 at 07:12 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center