-
Nested movie clip button to go to and play a frame in another movie clips frame
I have a flash file that needs 2 menus with buttons linking to frames in one movie clip timeline. This is an exercise to build an app interface and I am using
a left and right menu to allow for left and right handed users so the menu links are the same. I've messed around trying to keep instances and functions
with different names and can get the left menu to work great but the right menu slides out but the buttons don't work.
Below is a link to the fla, please someone help as I am a newbie with actionscript and it has to be as3. I need ot get this working for a college deadline.
https://drive.google.com/file/d/0B7n...ew?usp=sharing
Thanks everyone
-
.
Hi,
I have looked at your file and done something a tad different for you.
I have renamed the button/clips inside menuright_mc to the same names as menu_mc button/clip names.
and used this code instead of your code, basically both set of buttons use the same functions, less code.
PHP Code:
stop();
//file downloaded from www.riacodes.com
import com.greensock.TweenLite;
import com.greensock.easing.*;
import flash.display.MovieClip;
var i:int;
var buttonArray:Array = ["home_mc", "origins_mc", "scrolls_mc" ,"weapons_mc", "quiz_mc"];
menu_mc.addEventListener(MouseEvent.ROLL_OVER,showMenu(menu_mc,0));
menu_mc.addEventListener(MouseEvent.ROLL_OUT,hideMenu(menu_mc,menu_mc.x));
menuright_mc.addEventListener(MouseEvent.ROLL_OVER,showMenu(menuright_mc,885));
menuright_mc.addEventListener(MouseEvent.ROLL_OUT,hideMenu(menuright_mc,1090));
for (i = 0; i < buttonArray.length; i++)
{
menu_mc[buttonArray[i]].buttonMode = true;
menu_mc[buttonArray[i]].addEventListener(MouseEvent.CLICK, showContent(i + 1));
menuright_mc[buttonArray[i]].buttonMode = true;
menuright_mc[buttonArray[i]].addEventListener(MouseEvent.CLICK, showContent(i + 1));
}
function showContent(arg:Number):Function
{
return function showContent(event:MouseEvent):void
{
content_mc.gotoAndStop(arg);
}
}
function showMenu(clipToDo:MovieClip,destinationX:Number):Function
{
return function(event:MouseEvent):void
{
TweenLite.to(clipToDo, .4, {x:destinationX,ease:Linear.easeNone});
}
}
function hideMenu(clipToDo:MovieClip,destinationX:Number):Function
{
return function(event:MouseEvent):void
{
TweenLite.to(clipToDo, .4, {x:destinationX,ease:Linear.easeNone});
}
}
-
.
Hi,
Slight typo in that one, nothing to fuss about though, use this instead.
PHP Code:
stop();
//file downloaded from www.riacodes.com import com.greensock.TweenLite; import com.greensock.easing.*; import flash.display.MovieClip;
var i:int; var buttonArray:Array = ["home_mc", "origins_mc", "scrolls_mc" ,"weapons_mc", "quiz_mc"];
menu_mc.addEventListener(MouseEvent.ROLL_OVER,showMenu(menu_mc,0)); menu_mc.addEventListener(MouseEvent.ROLL_OUT,hideMenu(menu_mc,-200);
menuright_mc.addEventListener(MouseEvent.ROLL_OVER,showMenu(menuright_mc,885)); menuright_mc.addEventListener(MouseEvent.ROLL_OUT,hideMenu(menuright_mc,1090));
for (i = 0; i < buttonArray.length; i++) { menu_mc[buttonArray[i]].buttonMode = true; menu_mc[buttonArray[i]].addEventListener(MouseEvent.CLICK, showContent(i + 1)); menuright_mc[buttonArray[i]].buttonMode = true; menuright_mc[buttonArray[i]].addEventListener(MouseEvent.CLICK, showContent(i + 1)); }
function showContent(arg:Number):Function { return function(event:MouseEvent):void { content_mc.gotoAndStop(arg); } }
function showMenu(clipToDo:MovieClip,destinationX:Number):Function { return function(event:MouseEvent):void { TweenLite.to(clipToDo, .4, {x:destinationX,ease:Linear.easeNone}); } }
function hideMenu(clipToDo:MovieClip,destinationX:Number):Function { return function(event:MouseEvent):void { TweenLite.to(clipToDo, .4, {x:destinationX,ease:Linear.easeNone}); } }
I had "return function showContent(", it should have been "return function("
and menu_mc.x instead 0f -200;
Last edited by fruitbeard; 04-26-2015 at 01:03 PM.
-
.
Hi,
I've been busy as I had some time to kill, you could also do it like so.
Again making sure all button/clips are named the same within each menu.
PHP Code:
stop();
//file downloaded from www.riacodes.com import com.greensock.TweenLite; import com.greensock.easing.*; import flash.display.MovieClip;
var i:int; var j:int;
var menuArray:Array = ["menu_mc","menuright_mc"] var buttonArray:Array = ["home_mc", "origins_mc", "scrolls_mc" ,"weapons_mc", "quiz_mc"];
var m1xa:Number = 0; var m1xb:Number = -200;
var m2xa:Number = 885; var m2xb:Number = 1085;
menu_mc.addEventListener(MouseEvent.ROLL_OVER,showMenu(menu_mc,m1xa)); menu_mc.addEventListener(MouseEvent.ROLL_OUT,hideMenu(menu_mc,m1xb));
menuright_mc.addEventListener(MouseEvent.ROLL_OVER,showMenu(menuright_mc,m2xa)); menuright_mc.addEventListener(MouseEvent.ROLL_OUT,hideMenu(menuright_mc,m2xb));
for (i = 0; i < menuArray.length; i++) { for(j = 0; j < buttonArray.length; j++) { this[menuArray[i]][buttonArray[j]].buttonMode = true; this[menuArray[i]][buttonArray[j]].addEventListener(MouseEvent.CLICK, showContent(j + 1)); } }
function showContent(arg:Number):Function { return function(event:MouseEvent):void { content_mc.gotoAndStop(arg); } }
function showMenu(clipToDo:MovieClip,destinationX:Number):Function { return function(event:MouseEvent):void { TweenLite.to(clipToDo, .4, {x:destinationX,ease:Linear.easeNone}); } }
function hideMenu(clipToDo:MovieClip,destinationX:Number):Function { return function(event:MouseEvent):void { TweenLite.to(clipToDo, .4, {x:destinationX,ease:Linear.easeNone}); } }
-
Cheers dude
Thanks so much for all the effort I really appreciate it, I will go through your code and see if I can get my interface to work.
Best regards
Jason
Originally Posted by fruitbeard
Hi,
I've been busy as I had some time to kill, you could also do it like so.
Again making sure all button/clips are named the same within each menu.
PHP Code:
stop();
//file downloaded from www.riacodes.com
import com.greensock.TweenLite;
import com.greensock.easing.*;
import flash.display.MovieClip;
var i:int;
var j:int;
var menuArray:Array = ["menu_mc","menuright_mc"]
var buttonArray:Array = ["home_mc", "origins_mc", "scrolls_mc" ,"weapons_mc", "quiz_mc"];
var m1xa:Number = 0;
var m1xb:Number = -200;
var m2xa:Number = 885;
var m2xb:Number = 1085;
menu_mc.addEventListener(MouseEvent.ROLL_OVER,showMenu(menu_mc,m1xa));
menu_mc.addEventListener(MouseEvent.ROLL_OUT,hideMenu(menu_mc,m1xb));
menuright_mc.addEventListener(MouseEvent.ROLL_OVER,showMenu(menuright_mc,m2xa));
menuright_mc.addEventListener(MouseEvent.ROLL_OUT,hideMenu(menuright_mc,m2xb));
for (i = 0; i < menuArray.length; i++)
{
for(j = 0; j < buttonArray.length; j++)
{
this[menuArray[i]][buttonArray[j]].buttonMode = true;
this[menuArray[i]][buttonArray[j]].addEventListener(MouseEvent.CLICK, showContent(j + 1));
}
}
function showContent(arg:Number):Function
{
return function(event:MouseEvent):void
{
content_mc.gotoAndStop(arg);
}
}
function showMenu(clipToDo:MovieClip,destinationX:Number):Function
{
return function(event:MouseEvent):void
{
TweenLite.to(clipToDo, .4, {x:destinationX,ease:Linear.easeNone});
}
}
function hideMenu(clipToDo:MovieClip,destinationX:Number):Function
{
return function(event:MouseEvent):void
{
TweenLite.to(clipToDo, .4, {x:destinationX,ease:Linear.easeNone});
}
}
-
It worked
It worked flawlessly and I've learned an awful lot thanks to you.
You have just made my day. I hope I can repay you at someday for this amazing help.
Originally Posted by jasonconway
Thanks so much for all the effort I really appreciate it, I will go through your code and see if I can get my interface to work.
Best regards
Jason
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|