This content has been marked as final. Show 11 replies
It might be easier with rollover and rollout, let's say your second square has a y of 100 and you want it to go to 200 as an open submenu, you could do something like:
Hi! Thanks for your reply.
What I want:
I have graphical button (gif) imported. I have one square set with alpha and five "menu" items written inside (like "about us", "what we do" etc...). These menu items are aligned horizontally inside this square. The square is not visible when flash is loaded, only gif. When users presses once on the giff, the menu along with items comes down (drops down). It stays down (visible) untill user again clicks on the gif, then the menu goes up (hides).
I would really like this to work, but can't get it. I tried on(press) then making inside if condition but couldn't make it work. If anyone has an idea (or link) i would be very thankfull!
(p.s. I'm a real newbie in flash:)!
im not sure i understand your probem, are you just trying to make a button, so that when it is perssed a gif image moves down? and when itis pressed again it is moved up? thankyou
Ok... I'll try again:)
I have a gif loaded that represents the button. When it is pressed first time square goes down. When it is pressed second time, the square goes up. Square is drawn in flash.
Thanks a lot!
what you are referring to is a 'drop-down menu' and there are many ways to construct one. higreg is on the right track using the Tween class as it is the simplest method to move an item using code - however if the gif is not 'part' or the 'entire' bg of the menu the onRollOver/Out methods will fail to achieve your goal - additionally there are other problems that arise when using a rollover handler on the parent container causing child handlers to not receive events.
But this is moot, since your objective sounds as though you have an 'external' button (gif) that you want to use as a 'toggle' switch - to control the movement of the menu. in this case you need to set up a conditional statement within the onPress handler of the button, and use a variable to determine the next action to take - open or close. The following code belong on the timeline - NOT attached to a button instance (eg -with a on(press) style handler) additionally you need instance names of 'menu_btn' on the button, and 'menu' on the square - it would go something like this:
Thanks a lot for a reply...
I cant get your script working, because i'm a newbie... :)
About a conditional statement, i tried to do it with on(press) and if conditional statement. I even set up variable but the problem is, that I couldn't change variable state since, when script runs, variable alway get loaded first and then the state returns to its primary value.
About your code, could you have some time to explain me little detailed how to get it work? I understand if you don't want to hassle with it..:)
np - lol :)
it may be that you tried to place the code by 'attaching' it to an object - this code is meant to be used from the timeline. It is a 'best practice' to place all of your codes on a frame in the timeline rather than by using object attachment - in fact this had been eliminated in AS3 for that reason. in order to do so - create a new layer - call it 'actions' select a frame (the first one usually) then open the actions panel and enter the code above. placing your code on the timeline makes it easy to find, navigate paths and debug - this also may be the reason your variable had been getting reset.
also you need to have the instance name of 'menu_btn' on the button and 'menu' on the square in order for the above code to work properly.
I must be stupid or something because i can't get it work :)
I have flash 8. This i what i do. I open a new document. Import my gif to stage, convert it to button and name it menu_btn. Then I draw a square, convert it into a graphic and name it menu. When i click on each of them i see in properties window that they are instance of menu and menu_btn. Then i create new layer and paste your code into the first frame...
when i test the movie, nothing happens upon click :)
I'm funny and annoying with this even to myself :)
Thanks for your help!
lol! - you must convert the menu to an MC not a graphic - a graphic symbol cannot have an 'instance name' applied - and you need to have an instance name to control objects with code - it's being pointed at by the code as 'menu' - in fact both items must have 'instance names' - select the button on the stage - now look in the properties panel - on the left there is a input box that will say "<instance name>" type the name in there(ie. menu_btn) - convert the menu to a movieclip - and give it an instance name as well(ie. menu)
Thank you a lot!
Have no doubt that I'll post another one when I get into a problem...!
Have a beer on me :) !
lol. Your site's name really does justice on you man. You are a flash god!