PDA

View Full Version : button in animation makes it problematic


janislanka
12-30-2005, 10:31 AM
Scenario: I move over a button which calls a movie clip. Then in that movie clip there are another buttons (submenu) and as soon as I move over them (top red field) the movie clip dissapears. That base movie clip should not be dissapearing when I move over some submenu.

file (http://www.aidosstudija.lt/images/index.swf)
source is attached.

This is a newbe question since I'm pretty lame to flash. Any help?

swillicott
12-30-2005, 11:39 AM
Hi,

I am not sure as I am not in a position to view your source file, but could it be that your hit area of the original button is not large enough to cover the area that you sub-menu covers?

Try making the hit area the same size as your submenu.

Sorry I can't view the file but I am at work and supposed to be working!!

Hope this helps

Steve

janislanka
12-30-2005, 11:43 AM
no, that's not it :( You must see the example :)

swillicott
12-30-2005, 11:58 AM
OK - sorry - will take a look this evening

steve

Navarone
01-02-2006, 06:22 PM
The swf file psted suggested that you have somescript that is removing the movieclip on rollover. Did you verify that the moviclips are getting loaded to the correct level? Make sure you don't have duplicate variable names and stuff like that.

janislanka
01-03-2006, 08:12 AM
This is the link for the source file: www.aidosstudija.lt/index.fla

I think there are no duplicate names. Scenario is that button calls movie clip where another button is in. Then when I go over that other button, the "hosting" movie clip of that button restarts again. As almost loosing it's focus.

Navarone
01-03-2006, 10:42 AM
Ok, I took a few moments to look at the code and by removing this code on the button, your problem goes away.

on (press) {
getURL("/LT/priemimas/", "_self");
}


Are you trying to load a movie this or a web page? You should start checking other places in your code, a process of illimination might help narrow down the problem. What version of flash are you using?

I noticed you are still using "tell target"!

janislanka
01-03-2006, 11:21 AM
yes, it goes away. but the problem is following: i need to some buttons for each sublink. How to do it? If I remove that code, it doesn't act as button anymore and visitor can't click. Any better way doign that?

as for what I'm using: Flash MX and probably some old code. Mostly b/c I don't know flash well and don't have money to get the latest falsh version.

Could you suggest some better way to make the submenu as buttons?

Navarone
01-03-2006, 01:07 PM
I have to go to work now, but try commenting out code until you find the issue. For some reason the button and movieclip codes are counteracting each other.

janislanka
01-04-2006, 11:07 AM
Seriously, there is not some advanced coding, i just took the most simple things and put them together. Appearently with old ways of doing. This is the sample code on one of the main fields which calls the field and sublinks to appear:

on (rollOver) {
_root.field1._alpha = 100;
_root.men1._alpha = 100;
tellTarget ("_root.field1") {
gotoAndPlay (1);
}
tellTarget ("_root.men1") {
gotoAndPlay (1);
}
}

on (rollOut) {
tellTarget ("_root.field1") {
gotoAndStop (1);
}
tellTarget ("_root.men1") {
gotoAndStop (1);
}
}

it really seems that when going on the other button, the hosting button things it's a "rollOut" and therefore executes roll out. But what are the other ways to hide all when the user rolls out of the area?

janislanka
01-04-2006, 11:25 AM
I figured that I might put something like this code to every small sublink:

on (rollOver) {
_root.field1._alpha = 100;
_root.men1._alpha = 100;
tellTarget ("_root.field1") {
gotoAndStop (15);
}
tellTarget ("_root.men1") {
gotoAndStop (30);
}
}

That solves the problem when I move over the sublink. However, now there is still a problem of when you move out of the sublink (top one that says "Naujienos") and into the main area. It detects that you are again on there for the first time and plays the restart again.

See sample: http://www.aidosstudija.lt/images/index2.swf

Navarone
01-04-2006, 12:50 PM
Well maybe you need to establish which one has focus. Here is some code I used to build a dynamic menu. It uses a gotFocus function and maybe it will help. I don't know how to explain to you how to use it in the context of what you are doing, but maybe it will help.

// for vertical menu
//////////////////////// LOAD MENU NAMES ///////////////////////////////
// comment out the lables to remove them from the menu
var labels_array = new Array();
labels_array.push("ABOUT US");
labels_array.push("MEET YOUR TEAM");
labels_array.push("REFERENCES");
labels_array.push("TESTIMONIALS");
labels_array.push("PORTFOLIO COMPANIES");
labels_array.push("ACQUISITION PROCESS");
labels_array.push("LIFE WITH RIVERSIDE");
labels_array.push("INVESTORS");
labels_array.push("ADDITIONAL INFORMATION");
labels_array.push("CONCLUSION");
///////////////////////////////////////////////////////////////////////
// create a new empty array "myMenuClips"
myMenuClips = [];
// set the menu starting position from 0 or left edge of stage
startXPos = 0;
// the space between elements along the x direction
mySpaceVar = 2;
// loop each item found in "labels_array", attach "btnMC" from the library,
// populate the dynamic text instance "tf" of "btnMC" with the label values
for (var i = 0; i<labels_array.length; i++) {
var but = _root.attachMovie("btnMC", "btn_"+i, i);
myMenuClips.push(but);
//position the menu from the top of the stage down
but._x = 2;
//set the text to the items in the array
but.tf.text = labels_array[i];
//make the text field the same length as the number of characters
but.tf.autoSize = true;
// position the first menu item
but._y = startXPos;
// so do.....for the next item
startXPos = startXPos+but._height+mySpaceVar;
but.num = i;
trace(but._height)
}
// if certian menu items are commented out
// reposition the menu in the center of the stage
// take the stage width minus total height of the menu and divide by two
// this is now the newXPos
newXPos = (600-(but._y+but._height))/2;

mySpaceVar = 3;
for (var i = 0; i<labels_array.length; i++) {
var but = _root.attachMovie("btnMC", "btn_"+i, i);
myMenuClips.push(but);
but._x = 10;
but.tf.text = labels_array[i];
but.tf.autoSize = true;
but._y = newXPos;
newXPos = newXPos+but._height+mySpaceVar;
but.num = i;

/////////////////////////////////////////////////////////////////////////////////
gotFocus = function (obj) {
// remove the old content
lostFocus(this.prev);
// set the prev object to the current object.
this.prev = obj;
var c = new Color(obj);
c.setRGB(SELECTCOLOR);
};
lostFocus = function (obj) {
var c = new Color(obj);
c.setRGB(DEFAULTCOLOR);
};
//blue
var SELECTCOLOR = 0x0000FF;
//black
var OVERCOLOR = 0x000000;
//gray
var DEFAULTCOLOR = 0x999999;
var prev = null;
but.c = new Color(but);
but.c.setRGB(DEFAULTCOLOR);
////////////////////////////////////////////////////////////////////////////////
but.onRollOver = function() {
if (_root.prev != this) {
this.c.setRGB(OVERCOLOR);
}
};
but.onRollOut = function() {
if (_root.prev != this) {
this.c.setRGB(DEFAULTCOLOR);
}
};
but.onPress = function() {
if (_root.prev != this) {
gotFocus(this);
////////////////////////////////////////////////////////////////
if (this.tf.text == "ABOUT US") {
_root.gotoAndPlay("startAbout");
}
// ///////////////////////////////////////////////////////////////////////////////////////////////
if (this.tf.text == "MEET YOUR TEAM") {
_root.gotoAndPlay("Team Members");
}
// ///////////////////////////////////////////////////////////////////////////////////////////////
if (this.tf.text == "REFERENCES") {
_root.gotoAndPlay("startReferences");
}
// ///////////////////////////////////////////////////////////////////////////////////////////////
if (this.tf.text == "TESTIMONIALS") {
_root.gotoAndPlay("startTestimonials");
}
// ///////////////////////////////////////////////////////////////////////////////////////////////
if (this.tf.text == "PORTFOLIO COMPANIES") {
_root.gotoAndPlay("Portfolios");
}
// ///////////////////////////////////////////////////////////////////////////////////////////////
if (this.tf.text == "ADDITIONAL INFORMATION") {
_root.gotoAndPlay("Documents");
}
// ///////////////////////////////////////////////////////////////////////////////////////////////
if (this.tf.text == "ACQUISITION PROCESS") {
_root.gotoAndPlay("startAcquis");
}
// ///////////////////////////////////////////////////////////////////////////////////////////////
if (this.tf.text == "LIFE WITH RIVERSIDE") {
_root.gotoAndPlay("startLife");
}
// ///////////////////////////////////////////////////////////////////////////////////////////////
if (this.tf.text == "INVESTORS") {
_root.gotoAndPlay("startInvestors");
}
// ///////////////////////////////////////////////////////////////////////////////////////////////
if (this.tf.text == "CONCLUSION") {
_root.gotoAndPlay("startConclusion");
}
}
};
}


edited----

Maybe you could use a variable that gets set when you rollover or rollout and then your script only fires when the variable is "true".

janislanka
01-04-2006, 01:18 PM
wow, i'm sorry, but I went over it and just got confused even more. Here are the latest two files:
flash: http://www.aidosstudija.lt/flash/button.fla
source: http://www.aidosstudija.lt/flash/button.swf

I made the button a bit different and all I woudl request is to tell me how to put something on the sublinks that upon clicking on, would take visitor to specified link.

I know this sounds so lame that I'm not getting, but I need to get this done by friday and I'm just nowhere close to getting it done.

thanks for any help! I appreciate it so much!

Navarone
01-04-2006, 01:24 PM
Sorry, didn't mean to confuse you. I would use the getURL function if you are linking to web address.

Navarone
01-04-2006, 01:45 PM
Ok, where did you put the rollover code? I can't seem to find it on any of the buttons.

janislanka
01-04-2006, 01:47 PM
ok, so, let's do step-by-step :)
I did that and the same problem
source: http://www.aidosstudija.lt/flash/button2.fla
flash: http://www.aidosstudija.lt/flash/button2.swf
It still goes nuts. :(

---> later edits --->
I have following code for the button that is inserted in the main button:
on (release) {
getURL("http://www.lcc.lt/");
}

janislanka
01-04-2006, 01:54 PM
the main button hosts it. If I can correctly explain: it's when you double click that button (b1), it show Up, Over, Down, Hit and it's on the Over on "Button" layer.

Navarone
01-04-2006, 02:02 PM
ok, I see it. Let me get back to you.

Navarone
01-04-2006, 02:29 PM
ok, I hope you can open a zip file. I have to get back to work, but maybe there is enough here to help you.

janislanka
01-04-2006, 03:25 PM
this is an interesting approach. I used your idea and put on all the elements and the same problem. The submenu goes nuts when i roll over.

source: http://www.aidosstudija.lt/flash/button3.fla
flash: http://www.aidosstudija.lt/flash/button3.swf

It's just all back to the same problem! Grrrr!! It's soo simple but the same time soo complicated!

Note: In case it might not seem clear: when you move away from the field, all the field as well as submenu should dissapear.

-------> After note
the problem is more with submenu when you go off the menu.

Navarone
01-04-2006, 03:35 PM
hmm... ok try this, instead of making a movieclip for the field button and one for the menu item, make one movie clip that has all the elements. So this new movie clip would have the menu item fading in as well as the field. Take your individual frames out of the different movieclips and put into one. If I get a chance I'll try and do the same thing here.

janislanka
01-05-2006, 03:09 PM
Well, this is what I kind of did in the very beginning. :( BUT I still tried and overall looked good, except the fact that when I add a

on (release) {
getURL("http://www.msnbc.com", "_blank");
}

it just doesn't work.
source: http://www.aidosstudija.lt/flash/button4.fla
flash: http://www.aidosstudija.lt/flash/button4.swf

Navarone
01-05-2006, 03:13 PM
Can you do a trace. See if you are even getting to the menu item.

trace("test")

janislanka
01-05-2006, 04:38 PM
Some other person gave some good suggestion and it worked pretty well! If you care to look:
source: http://www.aidosstudija.lt/flash/button5.fla
flash: http://www.aidosstudija.lt/flash/button5.swf

Thanks for your help Navarone!

Navarone
01-06-2006, 12:41 AM
Hey, glad you got it working.:)