View Full Version : V. Confusing problem with rollover menu. PLEASE HELP!!!
benbenson
04-07-2005, 02:17 PM
I have made (or customised) a rollover menu which works well within flash, aside from two issues i need some help with. When the button is "rolledOver" an animated menu drops down, when the mouse goes outside the hit box, it animates itself away again. Using this code:
on (rollOver) {
gotoAndPlay (2);
}
which i believe initiates the movie clip, then:
onClipEvent (enterFrame)
{
if (this.hitTest(_root.PointerClip)) {
}else{_root.Menu.gotoAndPlay (51)}
}
which i believe begins frame 51, and the menu disappears. all well and good in the test movie thing, but when published, i have to move off the hit area VERY slowly for it to register and disappear again. resulting in lots of menus remaing open on my site. Am i making sense?!
Is there a value i can edit to make it react quicker? and where might it be?
Also, on the targets for the links in the menu, it doesnt seem to like my relative paths. for example, "../contact.php" results in the root of the site, when it should acutally be 2 or 3 branches down.
I'm really quite new to flash, and am getting extremely frustrated!! any help much appreciated!
Ben.
Hi,
This may or may not work, I have not tested it. You could put an onMouseMove function inside the enterframe function to check for the hitTest.The mouseMove code should fire at whatever speed the mouse moves...
onClipEvent (enterFrame) {
_root.onMouseMove=function(){
if (this.hitTest(_root.PointerClip)) {
//do something
}else{
_root.Menu.gotoAndPlay (51)}
}
}
benbenson
04-08-2005, 07:16 AM
THanks for the reply, I have inserted your suggested code, but it still doesnt work. Actually, now its not playing the second animation (menu disappearing) at all !
Not sure what i am supposed to put where you have "//do something". I really am very new to flash, so I've attached the fla file, and would be grateful if you could give it the once over!
I'm keen to learn, so please explain any changes needed! many thanks,
Ben.
N.b. Apparently I'm not allowed to attach .fla files. why's that?! its a flash forum!
Hi,
I have had problems with file attachments in this forum. If I post a demo file, I post it to my website and then provide a link. In the code you posted, you have an if statement that checks for a hitTest, but you dont have any code to do anything if the hitTest is detected.....
onClipEvent (enterFrame) {
if (this.hitTest(_root.PointerClip)) {
}else{
_root.Menu.gotoAndPlay (51)}
}
Usually, when using the hitTest method, when the hitTest is tested as true, something usually happens which is why I posted the pseudo code...
//do something. If you have a website and can upload the file there, provide a link and I will take a quick look.
NTD
benbenson
04-08-2005, 12:16 PM
I thought what that would do is nothing if it hittest was true, but go to frame 51 is it was false. But I do feel very out of my depth, so you tell me what it does and why!!
the site is www.ecom-sys.com/ecstest
that is the intended page aswell, so you'll see what i mean about the menus being difficult to close.
I really appreciate you looking at it for me!
Hi,
If the hitTest code is only there to test that there is not a hit occuring, a more efficient way to code that would be.......
onClipEvent (enterFrame) {
//if this hitTest=false
if (!this.hitTest(_root.PointerClip)) {
_root.Menu.gotoAndPlay(51);
}
The exclamation point operator in flash acts as a boolean trigger for false, so......
!hitTest .... is equal to...... hitTest=false
With this method, the clip is constantly checking for a false hitTest and if that occurs, it will send the menu clip to frame 51.
hope it helps
NTD
benbenson
04-08-2005, 01:09 PM
Sorry for not getting this.....but I've put your suggested code in, and it doesnt go to fram 51 at all now, so the menu never dissapears!
Honestly, I'm just interpreting the code the best i can, I didnt write it so I'm not completely sure what the purpose for each action is. If you could explain it I would be most grateful.
did you look at the site, and see what i mean about having to move off the buttons very slowly?
Hi,
Yes, I see the problem, but without seeing a hands on demo of where and how the code is being implemented, I can only offer suggestions. Post a demo file and I'll take a closer look.
NTD
benbenson
04-08-2005, 02:18 PM
Great thanks. WHat sort of demo file do you need? you have the fla for the first menu on the page, and all the others are identical.
www.ecom-sys.com/ecstest has the fla file link on it. is that all you need?
Hi,
I didn't see the link when I viewed it the first time. I just took a quick look to see the problem. I downloaded the file and I see a couple problems. I noticed on three frames in the menu clip where you had object code on a frame. I will expound a bit more on this later, but first, what version of Flash are you using? The version is very important as some methods will only work with newer versions of Flash.
benbenson
04-08-2005, 02:41 PM
I'm using flash mx. as part of macromedia studio mx. I really appreciaite this, thanks!
Hi,
A quick fix is to paste this code onto the first frame of your movie...
_root.Menu.onRollOver=function(){
this.gotoAndPlay(2);
}
_root.Menu.onRollOut=function() {
this.gotoAndPlay(51);
}
You have a button inside the menu clip that you were using to provide a hit area for opening and closing the menu. Movieclips can serve as buttons, if fact, I rarely use buttons because movieclips can be more dynamic and more customizable.
Object code vs frame code
With Flash 5, object code was more prevelant because buttons could not have instance names, only movieclips could. With the release of MX(or higher) frame code became the standard. The difference rest in how the code is applied. Object code will always use an "on" event handler and is placed on the object itself...
on(press)
on(release)
on(mouseDown)
Frame code uses the same methods, the difference is how the code is applied. Instead of directly on an object, frame code is posted on the first frame of your movie and identifies objects by instance name.Frame code can be applied to any frame, the first frame is standard codeing practice...
myButtonName.onRelease=function(){
trace("I was pressed");
}
//or
myMovieClipName.onEnterFrame=function(){
this._x++;
}
Notice how the on event handler is put right next to the method with frame code. The two codeing styles are not interchangeable. Frame code will not work on an object and object code will not work on a frame.
If you put object code on a frame, you will encounter this error...
"Mouse events are permitted only for button instances"
If you put frame code on an object, you will encounter this error...
"Statement must appear within on/onClipEvent handler"
The advantage of frame code is most noticeable in editing and authoring. It is much easier to edit and customize code that is all in one place as opposed to code that is spread throughout a project on different objects.
hope it helps
NTD
benbenson
04-08-2005, 03:41 PM
***, That actually made a lot of sense!! If only the help files could be just as coherent!
However, your suggested code, still stops the movie from playing frame 51 onwards at all. I also get the
"Statement must appear within on/onClipEvent handler"
error on frame one even tho im sure im pasting it onto a movie clip action. I really am struggling with this, should it be in frame 1 of the very bottom level of the file? or in the menu movie bit?
Hi,
It seems to work for me......
http://ntdesigns.net/quickDemo/company2.swf
I removed the object code you had on the frames inside the menu clip. This gave me the object code on a frame error code. To download the file, just change the .swf extension to .fla
Edit*** One other thing I noticed is that you had the publish setting for Flash player 5.
benbenson
04-08-2005, 04:46 PM
That works great! Thanks very much, was it the fact that i had script inside the movie that was stopping it?
and whats the best place to place the link? on frame 50 im thinking, sort of got it working with an html link but it wouldnt play nicely with a php file. DOes that sound right or complete gibberish?!
Hi,
You had a button inside the menu clip with the code on the button to control the movieclip. Buttons inside movieclips can be tricky. They establish their coordinates based on the parent clip.If you put button actions on the menu movieclip, any button actions inside the movieclip will be overridden.Accessing objects with frame code prevents much of this kind of confusion.
Any HTML page or flash movie can be launched from a button or frame with the getURL method. I'm not sure what you mean about linking to a PHP file. What does the PHP file do? I generally use a loadVars object when dealing with PHP files.
benbenson
04-08-2005, 06:47 PM
well i put the code geturl(blah blah blah) on the object in frame 50, but it doesnt work as it should. when its an html file, its seems to work ok, but when i put in the relative path "../contact.php" it went to the root of the site and obviously doesnt find the page, but opens the 404oage in a _blank windows instead of the target frame. for NO reason!!! most annoying!
so basically, whats the easiest, trouble free way of linking to pages?
the php page is just a simple contact form by the way
Hi,
Try using the absolute file path instead of relative. Can you call your PHP page in a browser window? If so, use the path that is in the location box...
getURL("http://somesite.com/myFile.php","_blank");
• _self specifies the current frame in the current window.
• _blank specifies a new window.
• _parent specifies the parent of the current frame.
• _top specifies the top-level frame in the current window.
benbenson
04-08-2005, 07:20 PM
yeah i thought of that, but it would make it so much more difficlt when updating the site, its likely to move domains soon aswell.
I got the html down, ie. the frame targets, but im specifying the name of the frame, which is "main" and it doesnt seem to work. it jumps up 2 directories, then opens a new window!! when it should look in the directory above, then open it in the "main" window. I was wondering if there is differnt syntax for tagetting frames in flash, and where the target should be put, like in which section of the flash document. I still dont fully understand the whole .root.parent.blah stuff
Hi,
_root is a reference to the main timeline. It is the same as using _level0. Using _root before an object means the main timeline of that object...
_root........ main timeline
_root.mcName........... main timeline of mcName movieclip.
_parent and this are pretty self explanatory. "this" is a reference to the object itself.Parent is the holding movieclip of the child movieclip. To reference the parent clip of a movieclip embeded inside another movieclip would be....
_parent._parent
When it comes to path tracing of objects, you can use the target icon or you can use actionscript....
trace(targetpath(movieClipName));
When it comes to external target paths, I have gotten into the habit of using nothing but absolute paths. You can use variables to represent the path. For example....
myPath="http://someSite.com/";
myButton.onRelease=function(){
getURL(myPath+"myFile.html,"frameName");
}
As long as your frames are named, targeting the name of the frame instead of _blank should work fine. I havn't dealt with frame sets in awhile, but I remember just targeting the frame name.
benbenson
04-12-2005, 02:28 PM
Hi again!
SOrry to keep picking problems with this, but I'm determined to make it work!!
THe adjustments you made have made the drop down disappear again promptly, which is exactly what i wanted. However, now, with it being in Flash 6, the rollover effects on the links dont function. if i publish in flash 5, the rollover links, which change colour, work, but the drop down animation (rolling back up) doesnt. And vice versa if i publish in flash 6. please help because I'm pullingmy hair out and have very little left!!
Thanks in advance
Hi,
Button methods should work correctly with flash player 6. Maybe your trying to use frame code without an instance name on the object or object code should work fine if applied directly to the object. I no longer have the demo on my local machine. Maybe do a couple of quick tests. Make a test movie with buttons and test object and frame rollover code.
Powered by vBulletin™ Version 4.1.1 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.