Skip to main content
Known Participant
September 30, 2009
Question

mouseX position problem in container loaded .swf

  • September 30, 2009
  • 1 reply
  • 902 views

Hi All,

Maybe looking at me in the face but I am having trouble tracing mouseX position.

I have an intro .swf that plays and once finished creates a container and loads main movie in that container.

In the main movie I have an infinite menu where the speed is controlled by mouseX.

Standalone the main movie works perfectly but as soon as I load into container I lose the mouseX.

Below is 'some' of the code that sits in Main movie.

addEventListener(Event.ENTER_FRAME, moveGallery);.........

function moveGallery(e:Event):void {

var speed:Number = -(0.02 * (startpage_nav_mc.mouseX - centerX));..........

I tried adding stage.addEventListener(Event.ENTER_FRAME, moveGallery) to see if that helped follow mouse once loaded into container. Nothing happened!!

Thanks in Advance for any thoughts.

Chris

This topic has been closed for replies.

1 reply

Ned Murphy
Legend
September 30, 2009

Try putting traces in to see what the various x values are.  It is possible your centerX reference value changes due to the movie being a loaded object.

duckdiveAuthor
Known Participant
September 30, 2009

Thanks Ned,

I tried tracing the values. In the stand alone it gives me what I expect. ie:0 at the left of the stage and 900 at right.

When I then load into the intro .swf the trace doesnt show and I get the error:

TypeError: Error #1009: Cannot access a property or method of a null object reference.

at main_de_2009_fla::MainTimeline/main_de_2009_fla::frame1()

referring to mouseX value I guess.

Chris

Ned Murphy
Legend
September 30, 2009

You're not telling/showing enough for me to know what the problem might be beyond suggesting you trace the various position values to see what they are.  If you are getting undefined values for some value (?) then that is likely a good clue that your code isn't seeing what it is meant to see.  That error message you showed indicates that whatever is being monitored is no longer within the same scope.  That brief bit of code you showed before... where is that code and what else follows it?  How is centerX defined?

As far as the error message goes, if you select the option to permit debugging in the Flash Publish Settings, you ar e likely to get just a bit more detail in the error message, possibly pointing to the offending line of code.