Skip to main content
Participating Frequently
January 17, 2013
Answered

Conflict between Slider and Buttons?

  • January 17, 2013
  • 1 reply
  • 1085 views

Help Please!

I have used the slider successfully to move between frames 43 and 60 in an individual scene:

stop()

function moveAlong_ff(evt:Event):void {

gotoAndStop(sl_ff.value);

}

sl_ff.minimum = 43;

sl_ff.maximum = 60;

sl_ff.liveDragging = true;

sl_ff.addEventListener(Event.CHANGE, moveAlong_ff);

this.addEventListener("enterFrame",onEnterFrame_ff);

function onEnterFrame_ff(e:Event) {

sl_ff.value = this.currentFrame;

}

And I have also managed to set up some buttons that navigate between scenes successfully:

ff_btn2.addEventListener(MouseEvent.CLICK, jump11);

function jump11(event:MouseEvent):void

{

          gotoAndPlay(1,"Scene2");

}

fb_btn2.addEventListener(MouseEvent.CLICK, jump12);

function jump12(event:MouseEvent):void

{

          gotoAndPlay(1,"Scene3");

}

bs_btn2.addEventListener(MouseEvent.CLICK, jump13);

function jump13(event:MouseEvent):void

{

          gotoAndPlay(1,"Scene4");

}

However, when the above scripts are present together there seems to be some kind of conflict and I get the error:

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

          at trailfresh_demo_19_fla::MainTimeline/onEnterFrame_ff()

Can anyone help as I'd really like to be able to navigate between scenes using buttons and also have the slider work in individual scenes?

This topic has been closed for replies.
Correct answer kglad

first, make sure this isn't an obvious error.  click on the object you think is sl_ff and check the properties panel to make sure spelling is correct.  using copy (from your code) and paste (to the properties panel) ensures the spelling is identical in both places.

if that doesn't solve the problem:

if you created sl_ff by placing it on-stage in a certain keyframe check to see if it's timeline tweened.  if it is, that is a subtle cause of this problem.  let me know if this is the case.

otherwise:  the first keyframe that contains sl_ff should contain your code (or, there can be another subtle cause of this problem).  does it?

1 reply

kglad
Community Expert
Community Expert
January 17, 2013

click file>publish settings>swf and tick "permit debugging".  retest.

the problematic line number will be in the error message allowing you to pinpoint the object that doesn't exist.

Ry_55555Author
Participating Frequently
January 18, 2013

Thanks for the help - greatly appreciated.

I retested and I have now isolated the line where the issue is - it is in the slider script:

sl_ff.value = this.currentFrame;

(sl_ff is the slider instance name)

Now I think that I need to use this to find the object that doesn't exist - any ideas how I should go about this?

kglad
Community Expert
kgladCommunity ExpertCorrect answer
Community Expert
January 18, 2013

first, make sure this isn't an obvious error.  click on the object you think is sl_ff and check the properties panel to make sure spelling is correct.  using copy (from your code) and paste (to the properties panel) ensures the spelling is identical in both places.

if that doesn't solve the problem:

if you created sl_ff by placing it on-stage in a certain keyframe check to see if it's timeline tweened.  if it is, that is a subtle cause of this problem.  let me know if this is the case.

otherwise:  the first keyframe that contains sl_ff should contain your code (or, there can be another subtle cause of this problem).  does it?