A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: Problems with movieclips

  1. #1
    Junior Member
    Join Date
    Jul 2010
    Posts
    2

    Problems with movieclips

    Created an animation of i.e. a car, that drives across the screen, by clicking on it (as it moves) it then plays a new movieclip of the car losing its tyres and collapsing. PROBLEM - I want the movie clip of the car to load on screen wherever the original movie is clicked, at the moment it only plays where it is set on the original stage i.e. in the middle or whereever I place it. Is there a way of making it track the mouse click on the original movie and play where the mouse click happens in order to make the event appear linked to original???
    kj

  2. #2
    var x:Number = 1; x /= 0;
    Join Date
    Dec 2004
    Posts
    549
    Give the car movieclip an instance name (I'll just use "car") and put this in your main timeline.
    Code:
    _root.onMouseDown=function(){
        car._x=_xmouse;
        car._y=_ymouse;
        delete _root.onMouseDown; //this line makes this only happen the first time you click.
        //if you want it to happen every time you click, then delete that line
    }
    Z¡µµ¥ D££

    Soup In A Box

  3. #3
    Junior Member
    Join Date
    Jul 2010
    Posts
    2
    Thanks for that, but I had:
    on (press)
    {
    _root.van._visible = false;
    _root.nextFrame()
    }

    and this seems to do the same thing! It hides the original car mc which trundles across the screen and plays the next frame which is the wheels falling off but......the second mc still won't track to play where the original stops on the mouse click!

  4. #4
    Senior Member
    Join Date
    Apr 2009
    Posts
    117
    use the script zippy gave and it goes in the main frame, not on the movieclips, also make sure you have different instance names for each movieclip, if you have the same instance name twice it will only work for the first one, that seems to be your problem, dont forget to repeat the code with the different instance name aswel

  5. #5
    var x:Number = 1; x /= 0;
    Join Date
    Dec 2004
    Posts
    549
    Wait, I think I may have misunderstood what you were asking for. I thought you meant that you wanted the car with the wheels falling off to be at the position that you clicked the mouse.

    Alright, you need to use

    On the frame with the car moving
    Code:
    on (press)
    {
    _root.carx=_root.van._x;
    _root.cary=_root.van._y;
    _root.van._visible = false;
    _root.nextFrame();
    }
    on the next frame
    Code:
    carbreak_mc._x=_root.carx;
    carbreak_mc._y=_root.cary;
    Last edited by ZippyDee; 07-23-2010 at 12:47 PM. Reason: Kicks and giggles
    Z¡µµ¥ D££

    Soup In A Box

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