A Flash Developer Resource Site

Results 1 to 9 of 9

Thread: please help me with this code

  1. #1
    Senior Member
    Join Date
    Dec 2002
    Posts
    156

    please help me with this code

    I need to declare something at the top of my code which says that whenever i write: car = "moving" it executes the following code

    _root.car_mc.wheels_mc.attachMovie("movingWheels", "newWheels", 1);

    so.. as i have many instances in my movie where the car moves, i shall write "car = "moving" " and the wheels will change to moving, then for car = "still" they will change back to still wheels.

    it should be something like IF car = moving then... but im not sure how to make it check all my clicks etc. I just want to not have to clutter my code with the attachMovie statement every other line.
    is it an OnclipEvent?
    Any ideas please?

  2. #2
    curmudgeon swampy's Avatar
    Join Date
    Jan 2001
    Location
    [wakey]
    Posts
    2,775
    Code:
    if (car=="moving")
    {
    // do something
    }
    "They're very much like scruffy pigs to look at, and they've got big, knobbly warts and lumps all over their long, hairy faces. They are very, very ugly indeed..."

  3. #3
    Senior Member
    Join Date
    Dec 2002
    Posts
    156
    on my actions layer on timeline i have:

    if (car=="moving"){
    _root.car_mc.wheel1_mc.attachMovie("wheelMoving", "newWheel",0)

    then further down on my button click i have:

    car=="moving"

    but when i click the button it doesnt work, i know the symbols are fine because i put root.car_mc.wheel1_mc.attachMovie "wheelMoving", "newWheel",0) in place of car="moving" and it worked, so it must be the IF..

  4. #4
    Senior Member
    Join Date
    Dec 2002
    Posts
    156
    should i not have an ON handler for the if statement? as it just sits above all my code, it needs to be checked every click

  5. #5
    curmudgeon swampy's Avatar
    Join Date
    Jan 2001
    Location
    [wakey]
    Posts
    2,775
    attach the file and I'll take a look
    "They're very much like scruffy pigs to look at, and they've got big, knobbly warts and lumps all over their long, hairy faces. They are very, very ugly indeed..."

  6. #6
    Senior Member
    Join Date
    Dec 2002
    Posts
    156
    I have made a mock up cos mine is far too big

    see attachment
    Attached Files Attached Files

  7. #7
    curmudgeon swampy's Avatar
    Join Date
    Jan 2001
    Location
    [wakey]
    Posts
    2,775
    Code:
    button_btn.onPress = function()
    {
    	_root.car_mc._x = 400;
    	// this is a motion tween in mine
    	car = "moving";
    };
    car_mc.onEnterFrame = function()
    {
    	if (car == "moving")
    	{
    		_root.car_mc.wheel1_mc.attachMovie("wheelMoving", "newWheel", 0);
    		_root.car_mc.wheel2_mc.attachMovie("wheelMoving", "newWheel", 0);
    	}
    };
    "They're very much like scruffy pigs to look at, and they've got big, knobbly warts and lumps all over their long, hairy faces. They are very, very ugly indeed..."

  8. #8
    Senior Member
    Join Date
    Dec 2002
    Posts
    156
    thankyou

  9. #9
    Senior Member
    Join Date
    Dec 2002
    Posts
    156
    ok well it was working, then all i did was re-draw my wheelMoving symbol, re-exported it, and now there is no change on button click owh!

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