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

Conflict between Slider and Buttons?

New Here ,
Jan 17, 2013 Jan 17, 2013

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?

TOPICS
ActionScript
1.0K
Translate
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

Community Expert , Jan 18, 2013 Jan 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: 

...
Translate
Community Expert ,
Jan 17, 2013 Jan 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.

Translate
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
New Here ,
Jan 18, 2013 Jan 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?

Translate
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
Community Expert ,
Jan 18, 2013 Jan 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?

Translate
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
New Here ,
Jan 18, 2013 Jan 18, 2013

Thanks for this - it has helped a lot.

I now have the movie running smoothly and working fine. However, I still have the error being produced. Is it a big problem to have the error or is it OK to go ahead and publish as the movie looks fine?

I think that maybe the source of (one of) the problems was that I put the slider in the timeline before the first keyframe that it was operational over. I did this so that I could 'fade it in'  (which I acheived by putting a white rectangle over it and reducing the alpha on the rectangle so that I didn't need a tween on the slider). Now I have put the slider in at the first frame where it is used and I'm not going to worry about the fade in.

Still getting the error but I don't think it is a problem - or is it?

Translate
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
Community Expert ,
Jan 18, 2013 Jan 18, 2013

you should eliminate the error.  everyone with a debug flash player will see the error message when running your app.

is your slider in one (or more than one) keyframe?

Translate
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
New Here ,
Jan 21, 2013 Jan 21, 2013

Ok - thanks for the advice... I'll try to sort the errors.

Yes - the slider is in more than 1 keyframe. In this scene the slider moves the action between frames 43 to 60 and each frame has it's own keyframe with a different picture (instance of a movie symbol) in it.

The idea is that the user moves the slider to scroll between different pictures.

Translate
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
Community Expert ,
Jan 21, 2013 Jan 21, 2013
LATEST

the only certain way to prevent that error is to add the slider to its first keyframe, assign its instance name and THEN add the subsequent keyframes that contain your slider AND do not remove/readd the slider thereafter.

Translate
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