Basically you are using the Tween or Y position of three movieclips. On roll over, make sure the remaining two clips are down and the third will animate upwards. You can do this via the timeline or through code.
Give it a try and we can help you through the bumps.
Some people are like Slinkies, not really good for anything, but they bring a smile to your face when pushed down the stairs.
Hi so far I've been able to create a button which when rolled over - plays a movie which houses my other buttons. Roll OVER - brings tab up. Roll OUT tab down.
However I do not seem to be able to target the buttons inside this tab movie.
Also How do I keep the tab menu up whilst user is scrolling through the menu?
Thanks for efforts.
Code:
B1.addEventListener(MouseEvent.ROLL_OVER, menuUp);
B1.addEventListener(MouseEvent.ROLL_OUT, menuDown);
function menuUp(event:MouseEvent):void {
menu_mc.gotoAndPlay("Up");
}
function menuDown(event:MouseEvent):void {
menu_mc.gotoAndPlay("Down");
}
P1.addEventListener(MouseEvent.CLICK, Print1);
function Print1 (evtObj:MouseEvent)
{
SoundMixer.stopAll();
container.source = "PRINT_1.swf";
}
P2.addEventListener(MouseEvent.CLICK, Print2);
function Print2 (evtObj:MouseEvent)
{
SoundMixer.stopAll();
container.source = "PRINT_2.swf";
}
Last edited by Sircharles; 08-24-2010 at 10:34 AM.
I can't view your fla here, I'm only using CS3 at work, so you may have to explain a little. The tab that animates up and down, does it contain the other buttons? If not, then that is the reason. Moving your cursor onto any other stage object will constitute a rollout for the tab. You have to have the sub menu button in the same movieclip as the tab, this way tapping another sub button will not fire the rollout event.
Some people are like Slinkies, not really good for anything, but they bring a smile to your face when pushed down the stairs.
Ya B1 is the main hit area button.
menu_mc is the tab
and P1, P2, P3 etc are the buttons inside the tab.
These are place simply on a layer inside menu_mc.
However my main timeline has code as above and is not recognising P1, P2 etc
Before you could target them, but alas.
Again when I roll out from B1 the tab goes away, so how to rectify this as well?
LOL. I understand your frustrations with AS 3.0. I experienced them also when I moved from 2.0 to 3.0, but the change will improve your skills along with providing you a increased number of capabilities that were not previously available. I'll through a quick menu together so you can see what I'm talking about.
Separating the movieclips is where you are running into problems.
Some people are like Slinkies, not really good for anything, but they bring a smile to your face when pushed down the stairs.
No problem. Okay here is what I put together. Sorry it took so long, I waited until I got home and did it on my computer which is running CS5. Here is the code I used (there are items in my library).
//Global Variables var btnArr:Array = newArray(tab1, tab2, tab3);
//Using a loop to perform the same action multiple times for(var i:int = 0; i < btnArr.length; i++) { MovieClip(btnArr[i]).addEventListener(MouseEvent.ROLL_OVER, tabOverHandler); MovieClip(btnArr[i]).addEventListener(MouseEvent.ROLL_OUT, tabOutHandler);
//Ensure that the movieclip acts like a button MovieClip(btnArr[i]).buttonMode = true;
var mc1:MovieClip = MovieClip(btnArr[i]);
//Make sure to assigned any control the sub menu items for(var j:int=0; j <3; j++) { var mc2:MovieClip = mc1["sub" + (j+1)] as MovieClip;
//Functions for the handler function tabOverHandler(me:MouseEvent):void { var tabTween:Tween = new Tween(me.currentTarget, "y", None.easeNone, me.currentTarget.y, 46, .5, true); }
function tabOutHandler(me:MouseEvent):void { var tabTween:Tween = new Tween(me.currentTarget, "y", None.easeNone, me.currentTarget.y, 176, .5, true); }
function subOverHandler(me:MouseEvent):void { MovieClip(me.currentTarget.parent).gotoAndStop(2); }
function subOutHandler(me:MouseEvent):void { MovieClip(me.currentTarget.parent).gotoAndStop(1); }
function subClickHandler(me:MouseEvent):void { MovieClip(me.currentTarget.parent).gotoAndStop(3); //Place click event code here. }
That represents a bulk of the code. I have a stop command on the submenu buttons since I wanted rollover changes. I've attached the full FLA file also. Hope this helps, let me know if you have any questions.
Last edited by samac1068; 08-26-2010 at 03:57 PM.
Some people are like Slinkies, not really good for anything, but they bring a smile to your face when pushed down the stairs.
Lookin good. To have a different action for each button, you have a couple of options, but depends on what you want it to do. Lets say you want the links to all go to a different web link. Well, the easiest method would be to add a switch statement within the subclick handler and based on the some button identification (I don't think I added that in), have the link selected from there. So one click, determine which button was clicks, then execute the link.
The same holds true if you want a different function to happen. On second thought, even if you have a mixture of functions and link to be called, using a switch statement within the subclick handler will reduce the headache.
To add an identifier for each button, I would try this: (Untested)
Actionscript Code:
for(var j:int=0; j <3; j++) { var mc2:MovieClip = mc1["sub" + (j+1)] as MovieClip;
hmm, comes up with a timeline error. Im tryng to change the source of a UrlLoader(container) on timeline. here is my code with your tailorings..
Fla file attached.
Code:
//Imports
import flash.events.Event;
import flash.events.MouseEvent;
import fl.transitions.Tween;
import fl.transitions.TweenEvent;
import fl.transitions.easing.*;
//Global Variables
var btnArr:Array = new Array(tab1, tab2, tab3);
//Using a loop to perform the same action multiple times
for(var i:int = 0; i < btnArr.length; i++)
{
MovieClip(btnArr[i]).addEventListener(MouseEvent.ROLL_OVER, tabOverHandler);
MovieClip(btnArr[i]).addEventListener(MouseEvent.ROLL_OUT, tabOutHandler);
//Ensure that the movieclip acts like a button
MovieClip(btnArr[i]).buttonMode = true;
var mc1:MovieClip = MovieClip(btnArr[i]);
//Make sure to assigned any control the sub menu items
for(var j:int=0; j < 3; j++)
{
var mc2:MovieClip = mc1["sub" + (j+1)] as MovieClip;
//Identify this button
mc2.name = "Tab" + (i+1) + "Sub" + (j+1);
//Provide the correct label
mc2.btnLabel.text = "Sub button " + (j+1);
//Provide function
mc2.invisBtn.addEventListener(MouseEvent.ROLL_OVER, subOverHandler);
mc2.invisBtn.addEventListener(MouseEvent.ROLL_OUT, subOutHandler);
mc2.invisBtn.addEventListener(MouseEvent.CLICK, subClickHandler);
mc2.invisBtn.buttonMode = true
}
}
//Functions for the handler
function tabOverHandler(me:MouseEvent):void
{
var tabTween:Tween = new Tween(me.currentTarget, "y", None.easeNone, me.currentTarget.y, 312.5, .5, true);
}
function tabOutHandler(me:MouseEvent):void
{var tabTween:Tween = new Tween(me.currentTarget, "y", None.easeNone, me.currentTarget.y, 386.55, .5, true);
}
function subOverHandler(me:MouseEvent):void
{
MovieClip(me.currentTarget.parent).gotoAndStop(2);
}
function subOutHandler(me:MouseEvent):void
{
MovieClip(me.currentTarget.parent).gotoAndStop(1);
}
function subClickHandler(me:MouseEvent):void
{
var subBtn:MovieClip = MovieClip(me.currentTarget.parent);
subBtn.gotoAndStop(3);
switch (subBtn.name)
{
case "Tab1Sub1":
container.source = "PRINT_1.swf";
break;
case "Tab1Sub2":
container.source = "PRINT_2.swf";
break;
case "Tab1Sub3":
container.source = "PRINT_3.swf";
break;
case "Tab2Sub1":
//Some Code here
break;
case "Tab2Sub2":
//Some Code Here
break;
}
}
Last edited by Sircharles; 08-26-2010 at 11:29 AM.
Error: Error #2078: The name property of a Timeline-placed object cannot be modified.
at flash.display::DisplayObject/set name()
at Tab_edit_CS3_fla::MainTimeline/frame1()
Opened your attached, and the first thing I noticed was the introduction of a container variable without it being instantiated previously. What is container and where does it get added to the stage?
Also, I'm looking into the issue with the name property. Not sure why it would give an error.
Last edited by samac1068; 08-27-2010 at 10:39 AM.
Some people are like Slinkies, not really good for anything, but they bring a smile to your face when pushed down the stairs.