PDA

View Full Version : button inside a movie clip



widget41
June 7th, 2009, 03:25 AM
Hi i am a newbie but i thought this might be the best place for my question.

I have a flash that i am creating, it is complex and i am not very good.

i have scene 1 with preloader
frame to entire site - which has pages layer, button layer menu layer, background layer, logo and header layer. all have one frame

in the pages frame movie clip opens to pages - layers are content, actions, background

now on the pages frames say frame 40 i have some buttons i am trying to get work. i have tried event listeners but get error - undefined property and have tried this too:

citeMc.contact.addEventListener(MouseEvent.CLICK, clickSection);
function clickSection(evtobj:MouseEvent) {
//tracing the event
trace("The "+evtobj.target.name+ "button has been Clicked");
//go to the selection clicked on.....
gotoAndStop(evtobj.target.name);
}

i get this error now:

TypeError: Error #1009: Cannot access a property or method of a null object reference.
at wax8b_fla::allPages_12/frame1()

maybe i am structuring it wrong and maybe i need to put actions in other places.

can anyone help me.

Navee
June 7th, 2009, 11:50 AM
So you have a mc called allPages_12? and within it there are frame labels or are the frame labels nested within the citeMC clip?

Just trying to figure out where you are placing you actions within your script. By expressing citeMC.contact (root) it is as if you are saying that the frame labels to the different sections/frame labels are within the contact button.

If the frame labels you are trying to reach are on in the same movieclip and layer then you don't need citeMC...just use contact.addEven.... and the trace will return The contact button has been clicked. If your frames labels are outside (parent) or even one more layer to the main timeline (parent.parent) you have to express MovieClip(parent).gotoAndStop(evtobj.target.name) ...I personally like using the AS3 method evtobj.currentTarget.name but it is here or there.

Maybe you could post your project with default shapes like squares and circles in the exact manner that you are currently working if you don't get this...so it can be worked out for you.

Cheers

snickelfritz
June 7th, 2009, 02:13 PM
All actionscript should be on frame1 of the main timeline, or within a document class.

Navee
June 7th, 2009, 03:19 PM
@snickelfritz

True, if the person is a professional like yourself, but the obvious "newbie", scene 1 preloader, frame 40,...in the pages frame movie clip opens to pages - layers are content, actions, background are all very distinctive operative expressions that state impossibilities of having all actionscript on frame 1 of the main timeline.

There has to be a global stop(); somewhere else because the pages are nested and the user is trying to gotoAndStop at the name of the button frame label (and it is approachable from the main timeline if (root) is involved); then there are scope issues that a "newbie" must understand to communicate back to the (parent) main timeline from within the nested movieclips pursuant to how the project appears to be setup.

Clearly this user needs help...asking to perform on a document class level is like asking someone who knows nothing about computer hardware to change your motherboard and set the new processor.

Don't get me wrong: I am on your side and not trying to pick a flaming session. I agree 100%: 1 frame ALL DAY and EVERY DAY for me too AND my own custom classes...but I don't think this user's project is set up for it.

That is why I asked for a basic construction of the project file so that one (or a few) of the many talented brains around here could assist and possibly introduce a better way.

Cheers