• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

error #1009 with a movie clip button that is within a movie clip

Participant ,
Apr 03, 2013 Apr 03, 2013

Copy link to clipboard

Copied

OK, so I have a mc button within a movie clip that causing a big error problem that keeps repeating.  My code is extremely simple :

stop();

infoGraphicDisparity.addEventListener(MouseEvent.CLICK, disparityGO);

function disparityGO(event:MouseEvent):void

{

    MovieClip(this.root).gotoAndPlay("disparity");

}

I have used these types of buttons a million times, and now CS6 doens't like it.  Any help is much appreciated.  Thanks

TOPICS
ActionScript

Views

2.0K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Apr 04, 2013 Apr 04, 2013

I have no idea what MAIN is, but....

stage.addEventListener(Event.ENTER_FRAME, enterFrameHandler);

That listener is causing the function that is trying to target MAIN at the frame rate of your file, and it continues to do so if you move to frame 2.  If MAIN does not exist in frame 2, then there's your error source.  Try removing that event listener before going to frame 2 and the problem should go away.

Votes

Translate

Translate
Explorer ,
Apr 03, 2013 Apr 03, 2013

Copy link to clipboard

Copied

infoGraphicDisparity is the mc button in the main MC? Which MC is the one with the timeline label "disparity"?

It could be assiging the eventlistenter to the wrong object or trying to play the wrong MC timeline. Trace out MovieClip(this.root) to see if you are getting anything.

intead of using this.root you could also use a more direct approach and get the main movie clip you want by its name(make sure to have a name assigned via mainMC.name = "your main MC name").

getChildByName("name of main MC here")

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Apr 03, 2013 Apr 03, 2013

Copy link to clipboard

Copied

I will explain a little more clearly.

The main Movie Clip is a single frame on the timeline, I will call it frame one.  Within that single frame movie clip, there is another movie clip button.  The function of the movie clip button is to advance the main timeline to frame two.  It is functioning, but the error still shows up.  The movie clip button is called infoGraphicDisparity.  Frame 2 was named "disparity" .  I am not sure if this helps clear things up.  Thank you again for any help.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 03, 2013 Apr 03, 2013

Copy link to clipboard

Copied

I'm sorry im still a little fuzzy on this, so is this movieClip in frame 2 of the main timeline? If not, this may be the issue, when it goes to frame 2 its trying to access a property that is not available, because it is not present in frame 2.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Apr 03, 2013 Apr 03, 2013

Copy link to clipboard

Copied

all the movie clips are in frame 1.  frame 2 is a completely seperate page.  no movie clips from frame 1 are in frame 2

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 03, 2013 Apr 03, 2013

Copy link to clipboard

Copied

Ok you need to access the button mc from the main mc it's stored in so instead of:

infoGraphicDisparity.addEventListener(MouseEvent.CLICK, disparityGO);

you need:

mainMC.infoGraphicDisparity.addEventListener(MouseEvent.CLICK, disparityGO);

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Apr 03, 2013 Apr 03, 2013

Copy link to clipboard

Copied

I just get a bunch of compiler errors, saying it does not recognize the instance names.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 04, 2013 Apr 04, 2013

Copy link to clipboard

Copied

The 1009 error indicates that one of the objects being targeted by your code is out of scope.  This could mean that the object....

 

- is declared but not instantiated

- doesn't have an instance name (or the instance name is mispelled)

- does not exist in the frame where that code is trying to talk to it

- is animated into place but is not assigned instance names in every keyframe for it

- is one of two or more consecutive keyframes of the same objects with no name assigned in the preceding frame(s).

 

If you go into your Publish Settings Flash section and select the option to Permit debugging, your error message should have a line number following the frame number which will help you isolate which object is involved.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Apr 04, 2013 Apr 04, 2013

Copy link to clipboard

Copied

I did debug it.  It says there is an error:

Untitled_fla::MainTimeline/enterFrameHandler()[Untitled_fla.MainTimeline::frame1:21]

So I went to line 21 and there is simply a trace statement there.  The site is functional, but I do not want to have a crap ton of errors popping up. Line 21 is  trace(MAIN.x);     So I deleted the trace statements, and then the error comes up on the if line.  I am completely dumbfounded here.  Here is my code:

import flash.events.Event;

import flash.display.StageAlign;

stop();

stage.addEventListener(Event.ENTER_FRAME, enterFrameHandler);

stage.align = StageAlign.TOP_LEFT;

function enterFrameHandler(e:Event):void

{

          trace(MAIN.x);

          trace(mouseX);

          if((MAIN.x < 911 && (mouseX > 1100)) || (MAIN.x > 369 && (mouseX < 90))) {

                    var newLocation:Number = MAIN.x + ((mouseX - MAIN.x) * -0.04);

                    newLocation = Math.min(910, newLocation);

                    newLocation = Math.max(370, newLocation);

                    MAIN.x = newLocation;

          }

         

         

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 04, 2013 Apr 04, 2013

Copy link to clipboard

Copied

It sounds like MAIN is the object that is not present when that code executes.  Try to reason out why MAIN would be elsewhere, like a different frame or some one of the other reasons I listed.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Apr 04, 2013 Apr 04, 2013

Copy link to clipboard

Copied

I rebuilt just this section of my site in a new fla file.  I made a dummy frame in frame 2 and left MAIN in frame one.  There is nothing in frame 2 at all, other than a rectangle.  The only other code I used was :

test1.addEventListener(MouseEvent.CLICK, frameTwo);

function frameTwo(event:MouseEvent):void

{

    MovieClip(this.root).gotoAndPlay(2);

}

no other action script exists anywhere else.  I even tried to removeEventListener in the next frame, but nothing.  Actionscript is going to make me lose my hair.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 04, 2013 Apr 04, 2013

Copy link to clipboard

Copied

With what you just described, what problem do you encounter?  You say the only other code you used was what you show... so what was the code you don't show, and where is it?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Apr 04, 2013 Apr 04, 2013

Copy link to clipboard

Copied

So, I wanted to see if just navigating away from the frame was causing the problem, and it is.  I put a movie clip button on top of MAIN so I wouldn't have to contend with different timelines.  The same 1009 error is showing.  Here is my full code:

import flash.events.Event;

import flash.display.StageAlign;

stop();

stage.addEventListener(Event.ENTER_FRAME, enterFrameHandler);

stage.align = StageAlign.TOP_LEFT;

function enterFrameHandler(e:Event):void

{

          trace(MAIN.x);

          trace(mouseX);

          if((MAIN.x < 911 && (mouseX > 1100)) || (MAIN.x > 369 && (mouseX < 90))) {

                    var newLocation:Number = MAIN.x + ((mouseX - MAIN.x) * -0.04);

                    newLocation = Math.min(910, newLocation);

                    newLocation = Math.max(370, newLocation);

                    MAIN.x = newLocation;

          }

     

}

next.addEventListener(MouseEvent.CLICK, advanceFrame);

function advanceFrame(event:MouseEvent):void

{

    gotoAndStop(2);

}

There is something about MAIN that it doesn't like, but I can not figure it out

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 04, 2013 Apr 04, 2013

Copy link to clipboard

Copied

I have no idea what MAIN is, but....

stage.addEventListener(Event.ENTER_FRAME, enterFrameHandler);

That listener is causing the function that is trying to target MAIN at the frame rate of your file, and it continues to do so if you move to frame 2.  If MAIN does not exist in frame 2, then there's your error source.  Try removing that event listener before going to frame 2 and the problem should go away.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Apr 04, 2013 Apr 04, 2013

Copy link to clipboard

Copied

I removed the event listener and it worked splendidly.

When I put it inside a movie clip however, and tried to add this little number:

parent.stage.removeEventListener(Event.ENTER_FRAME, parent["enterFrameHandler"]

and now it is error 2007.  Not so good.  I feel like I am one line of code away from getting out of everyone's hair (for now).

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Apr 04, 2013 Apr 04, 2013

Copy link to clipboard

Copied

I removed the event listener and it worked splendidly.

When I put it inside a movie clip however, and tried to add this little number:

parent.stage.removeEventListener(Event.ENTER_FRAME, parent["enterFrameHandler"]

and now it is error 2007.  Not so good.  I feel like I am one line of code away from getting out of everyone's hair (for now).

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 06, 2013 Apr 06, 2013

Copy link to clipboard

Copied

LATEST

Just put it inside the function that changes frames

function advanceFrame(event:MouseEvent):void

{

    stage.removeEventListener(Event.ENTER_FRAME, enterFrameHandler);

    gotoAndStop(2);

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines