dcsimg
A Flash Developer Resource Site

Results 1 to 16 of 16

Thread: control movie clip with actionscript

  1. #1
    Senior Member
    Join Date
    Apr 2004
    Posts
    140

    control movie clip with actionscript

    Hi.. i want to control a movie clip through actionscript. I want to be able to make an object move to a certain position from wherever it is. A good example is www.themesshall.com.au

    So say there are 3 buttons that make an object that go to different positions. I want to be able to press either of the other 2 buttons to go to their own position.
    Basically...
    In the action script i would put the position i want the object to go to and thats that.
    Anyone know what i can do??
    Cheers, Mark

  2. #2
    FK's Geezer Mod Ask The Geezer's Avatar
    Join Date
    Jul 2002
    Location
    Out In The Pasture
    Posts
    20,490
    on(release){//button 1
    _root.box._x = 50;
    _root.box._y = 50;
    }

    on(release){//button 2
    _root.box._x = 150;
    _root.box._y = 150;
    }

    on(release){//button 3
    _root.box._x = 250;
    _root.box._y = 250;
    }

  3. #3
    Senior Member
    Join Date
    Apr 2004
    Posts
    140
    Is that where the instance name of object is "box" ?
    Sorry im no good with actionscript

  4. #4
    FK's Geezer Mod Ask The Geezer's Avatar
    Join Date
    Jul 2002
    Location
    Out In The Pasture
    Posts
    20,490
    Yup. It could be anything you want, I just used box. That code will make the object jump from one spot to the other.

  5. #5
    Senior Member
    Join Date
    Apr 2004
    Posts
    140
    What about the instance name for the buttons??

  6. #6
    Senior Member
    Join Date
    Apr 2004
    Posts
    140

    errors

    This is the error with the script ? Do u know whats wrong with it?

    **Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 1: Mouse events are permitted only for button instances
    on(release){//button 1

    **Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 6: Mouse events are permitted only for button instances
    on(release){//button 2

    **Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 11: Mouse events are permitted only for button instances
    on(release){//button 3

    Total ActionScript Errors: 3 Reported Errors: 3

  7. #7
    FK's Geezer Mod Ask The Geezer's Avatar
    Join Date
    Jul 2002
    Location
    Out In The Pasture
    Posts
    20,490
    You don't need button instance names when you add the code to the button. And that's your error, you adding it to a frame, not on the button itself. Click the button to select it and add the code in the actions panel.

  8. #8
    Senior Member
    Join Date
    Apr 2004
    Posts
    140
    Thats great thanks.
    I actually wanted it to move to that position.. like a motion tween not just pop up in the new position. Do you know how to do that?

  9. #9
    FK's Geezer Mod Ask The Geezer's Avatar
    Join Date
    Jul 2002
    Location
    Out In The Pasture
    Posts
    20,490
    As a matter of fact....
    Attached Files Attached Files

  10. #10
    Senior Member
    Join Date
    Apr 2004
    Posts
    140

    Cheers

    Thanks 4 the help mate i appreciate it.

  11. #11
    Senior Member
    Join Date
    Apr 2004
    Posts
    140

    Actually 1 more thing

    Hi again.. how can i scale it with a tween also.
    So it changes location and size?

    box._xscale = 250;

    I got this working but it doesnt tween it.. it just resizes it. Any ideas?

  12. #12
    FK's Geezer Mod Ask The Geezer's Avatar
    Join Date
    Jul 2002
    Location
    Out In The Pasture
    Posts
    20,490
    You have to add the scale and location lines in one button call, 4 lines.

  13. #13
    Senior Member
    Join Date
    Apr 2004
    Posts
    140
    Sorry can you explaine more please.

  14. #14
    FK's Geezer Mod Ask The Geezer's Avatar
    Join Date
    Jul 2002
    Location
    Out In The Pasture
    Posts
    20,490
    Like this.
    Attached Files Attached Files

  15. #15
    Senior Member
    Join Date
    Apr 2004
    Posts
    140

    Thanks again

    Thanks you've been very helpful.
    Now for the ultimate challenge.
    Any chance you could make the clip move along a motion guide and have the size change all through action script???

    Just so i can have it move in a curving direction instead of goind directly straight from one place to the next?

  16. #16
    Senior Member
    Join Date
    Apr 2004
    Posts
    140
    What i mean is.. i would like to have a curved line ~~.~~.~~.~~
    (Pretend thats one curvy line with 3 positions along the way) that has buttons at different positions along the line. The clip will follow the path of the curv until it gets to its position.
    Any ideas?

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