Skip to main content
Known Participant
February 15, 2008
Answered

a movie clip button cant detect its AS code

  • February 15, 2008
  • 10 replies
  • 1742 views
On my root timeline the code below referencing a movie clip button, which cannot be detected when I place my mouse over it. It has been given an instance name. I dont know why it work. I have done other buttons the same way and they work.It only works when I place my code in the binary_mc timeline, which I dont want to do as I like to keep all of my code centralized.

Any ideas?
This topic has been closed for replies.
Correct answer
It appears to me that your replay button is doing eaxctly what you are telling it to. You should try to logically follow what you are asking it to.

For your next button, you have a "_root." stuck in all by itself that is a typo and should be removed. Your next button is also doing exactly what you are asking it to. It does, in fact, go to the frame label _binaryToDenaryPage Two where it executes the script on frame # 469 which is what is then sending you back to the main menu.

It would be helpful to you if you could debug your FLA a little better and try to tract its actions. For example, try to comment out all the AS on frame 469 except for the stop();

You are assuming your button script is not working because they don't appear to be doing what you are asking them to but that is only appearance. So you are looking for the needle in the wrong haystack.

I also noticed that in frame 469, you reference several frame labels that don't exist such as _B2D3 and _B2D2. I tried changing those to the labels I think you mean and now my Flash crashes every time I try to test your movie so I give up.

10 replies

kglad
Community Expert
Community Expert
February 24, 2008
learn to use the trace() function. it's essential to debugging flash.
kglad
Community Expert
Community Expert
February 22, 2008
no. i don't want the full picture. it would take too much time to find the essence of the problem. i just want to see the essence of the problem.

create a new fla and duplicate just the essentials to recreate the problem.
badhamsAuthor
Known Participant
February 22, 2008
Please find attached the problem file. The trouble code is n frame 428 of the whatIsBinary_mc movie clip. The frame has the label _binaryToDenaryPageOne

Both the replay and next buttons take me back to the main menu but the previous and home buttons work fine

http://download.yousendit.com/AB2F5D5B7DB1C606
Correct answer
February 23, 2008
It appears to me that your replay button is doing eaxctly what you are telling it to. You should try to logically follow what you are asking it to.

For your next button, you have a "_root." stuck in all by itself that is a typo and should be removed. Your next button is also doing exactly what you are asking it to. It does, in fact, go to the frame label _binaryToDenaryPage Two where it executes the script on frame # 469 which is what is then sending you back to the main menu.

It would be helpful to you if you could debug your FLA a little better and try to tract its actions. For example, try to comment out all the AS on frame 469 except for the stop();

You are assuming your button script is not working because they don't appear to be doing what you are asking them to but that is only appearance. So you are looking for the needle in the wrong haystack.

I also noticed that in frame 469, you reference several frame labels that don't exist such as _B2D3 and _B2D2. I tried changing those to the labels I think you mean and now my Flash crashes every time I try to test your movie so I give up.
kglad
Community Expert
Community Expert
February 22, 2008
if you can create a fla that contains just the essence of your problem, i can show you how to correct it.
badhamsAuthor
Known Participant
February 22, 2008
Shall I just upload the latest version of what I have so that it gives you the full picture??
badhamsAuthor
Known Participant
February 21, 2008
The aannoying thing is I have used the above in other buttons within the whatIsBinary_mc movieclip and it works. I have copied and changed the instance name as appropriate but it dont work. I cant see why.

I have tried to check for duplicate instance name and also duplicate frame names. The thing I dont understand is why i movie explorer the name of the frames are shown in brackets for the _root timeline but not for any frames in movieclips, which are located inside the root time line. For example the whatIsBinary_mc movie clip.
It just shows the frame number and no brackets.

kglad
Community Expert
Community Expert
February 18, 2008
you're welcome. and you shouldn't feel badly: i don't think anyone's made as many dumb mistakes as i've made. and your issue wasn't because of a dumb mistake.
badhamsAuthor
Known Participant
February 20, 2008
This gets better. I am trying to code a button at the same point when it exist but the code is not functioning correctly.

Its a binary test button located in the binary test movieclip. It has a instance name but the code does not work correctly unless I do this.onRelease = function()
{
//do this
}

Using the _root.whatIsBinary_mc.button1.onRelease etc it does not work. It takes me to the main menu but I want it to take me to the next scene in the whatIsBinary_mc movie clip. I dont know why. I cant find any duplicate code using the movie explorer.

Thanks
Phil

ps I used the find target option so I am sure its not a typo
kglad
Community Expert
Community Expert
February 21, 2008
if you want to control the whatIsBinary_mc timeline use:

kglad
Community Expert
Community Expert
February 17, 2008
i gave two ways to solve the issue.
badhamsAuthor
Known Participant
February 17, 2008
Sorry kglad. Please accept my apologies. I have used your idea of placing the code when the button(s) are initiated

Thanks again.
Sorry to be a pain and post silly questions
kglad
Community Expert
Community Expert
February 16, 2008
i have no idea what you mean by the first set of binary buttons, but if you write code for an object before that object exists, the code will be meaningless because it applies to undefined objects.

so, if code for "the first set of binary test buttons work", those objects must exist when the code is executed.
February 17, 2008
Well I did download that file and it is somewhat of a mess. But I did look inside the whatIsBinary_mc and I cannot find a single instance of anything called "homeButton_mc". What I did see was a (mc) button with the word "Home" written on it so I'm guessing that is the button you are trying to target. The LIBRARY name of that mc button is "homeBtn_mc" which is not the same as homeButton_mc. Regardless, the LIBRARY name is immaterial. The only thing that matters is the INSTANCE name and the INSTANCE name of that mc button is "whatIsBinaryHomeButton_mc" (not "homeButton_mc") so I suspect that if you had scripted the following, it would likely work if and only if the mc instance exists at the time you try to apply the code just as kglad said. But you clearly have the instance name of the movie clip wrong at the very least. I also see you are publishing for Flash 8 so remember that instance names are case sensitive. For example, homeButton and HomeButton would be two different instances.
February 17, 2008
I looked at your FLA a little more and kglad is right. There is no possible way to target your whatIsBinaryHomeButton_mc clip from the _root timeline. When your _root timeline hits frame 4 where the whatIsBinary_mc itself becomes instantiated, that movie clip is also on its frame 1. So your AS to target a clip within that clip executes when the frame is entered but the clip you are targeting with that clip is not instantiated until frame 170 of the clip. Since you are running at 12 FPS, the clip you are trying to target with your _root AS will not exist until about 14 seconds after the AS is executed. So your script is wasted and does nothing.

So if you truly need to target that button mc from the _root, what I suggest you do is place the whatIsBinaryHomeButton_mc on frame 1 of the whatIsBinary_mc rather than on frame 170 and make it invisible on frame 1 and until you reach frame 170 where you then make it visible. Of course making it invisible will effectively disable the button until you make it visible so your "Hellow" test wouldn't actually work.

Frame 1:
whatIsBinaryHomeButton_mc._visible = 0;

Frame 170:
whatIsBinaryHomeButton_mc._visible = 1;
whatIsBinaryHomeButton_mc.onRollOver = function()
{
_root.onMouseRollOver(whatIsBinaryHomeButton_mc);
}
whatIsBinaryHomeButton_mc.onRollOut = function()
{
_root.onMouseRollOut(whatIsBinaryHomeButton_mc);
}
whatIsBinaryHomeButton_mc.onRelease = function()
{
_root.gotoAndStop("_mainMenu");
}
kglad
Community Expert
Community Expert
February 16, 2008
you can't code for your buttons until they exist. you can put your handler code in a function that you call from frame 170 of binary_mc, so all your important code is on the main timeline.

otherwise, to put all of it on the main timeline, you'll need to create a loop on your main timeline that repeatedly checks the _currentframe property of binary_mc and when it reaches 170, then terminate the loop and define your handlers.
badhamsAuthor
Known Participant
February 16, 2008
I kind of see what you. I dont get why if thats the case the first set of binary test buttons work
kglad
Community Expert
Community Expert
February 15, 2008
on the timeline that contains homeButton_mc, place:

trace(this);

// and copy and paste the output panel result
badhamsAuthor
Known Participant
February 16, 2008
This code has been placed in the whatIsBinary_mc timeline as that is where the home button is located. I have attached the code below.
February 16, 2008
Can you replace the trace(this) with the attached in exactly the same place on the same timeline?

(And then attached what you get in the output window?)
kglad
Community Expert
Community Expert
February 15, 2008
you have a typo or path problem. or you have mouse handlers defined for whatIsBinary_mc.
badhamsAuthor
Known Participant
February 15, 2008
I am certain its not a typo as I used the find target option in AS. I cant see any code which directly relates to the Binary_mc in the movie explorer