flash actionscript:
Hi all, Im completely new to Flash and am struggling to get a simple thing working: I have a "MovieClip" (called "gadget") within my scene which is made up of two "Buttons" (but_burn and but_sandbag) I need to know when the user is holding the left mouse button down within the "but_burn" button. This code lives on MovieClip "gadget" layer in the Scene: var p_mouseDown:Boolean = false; but_burn.onPress = function() { p_mouseDown = true; }; burnButton.onRelease = function() { p_mouseDown = false; }; And then on another layer in the same Scene is the object controlled by those buttons. It has this script: var g_balloonVertSpeed:Number = 0; this.onEnterFrame = function() { moveBalloon(); }; function moveBalloon() { if(but_burn.p_mouseDown==true) { g_balloonVertSpeed --; if(g_balloonVertSpeed < -6) { g_balloonVertSpeed = -6 } } else { g_balloonVertSpeed ++; if(g_balloonVertSpeed > 6) { g_balloonVertSpeed = 6 } } balloon._y += g_balloonVertSpeed; }; P.S. its a hot air balloon game and the "but_burn" button controls the burner to go up. Many many thanks in advance of any and all help given. ** if only all coding was Lingo ** ;)
Is it something to do with: if(but_burn.p_mouseDown==true) { The p_mouseDown property doesnt seem to be changing at all
moving all the code into the "actions" layer, and adding the "gadget" MovieClip object reference here: gadget.but_burn.onPress = function() { p.mouseDown = true };
You have some path issues here... The burn button is inside the MC instance "gadget", so you must add that name (if you have the code on the main timeline): gadget.but_burn.onPress = ... gadget.but_burn.onRelease = ... Then, in the function moveBalloon, you don't need any path: if(p_mouseDown==true) ... because p_mouseDown is a variable on the main timeline. hth, blemmo
Don't see what you're looking for? Try a search.
|