Jump to content
Search Community

Help with tint filter and buttons?

TheMightyMac test
Moderator Tag

Recommended Posts

I'm having some trouble with a slideshow I've created. Basically an image tweens in and then when you click "next1_mc" or "previous1_mc" it goes to another frame label and another image tweens in and so on. Everything worked fine with it until I added the "Mouse_Over" and "Mouse_Out" functions to my "next1_mc" that has the button change tint and now I get this error code:

 

Error: Cannot tween a null object.

at com.greensock::TweenLite$iinit()

at com.greensock::TweenLite$/to()

at imagegallerytest_fla::MainTimeline/out1()

TypeError: Error #1006: value is not a function.

at com.greensock::TweenLite/renderTime()

at com.greensock.core::SimpleTimeline/renderTime()

at com.greensock::TweenLite$/com.greensock:TweenLite::updateAll()

TypeError: Error #1006: value is not a function.

 

There is more to this error but I just copied a bit of it since it basically repeats itself. Below is my code I used. Any help to fix this would be greatly appreciated. Thanks!

 

-Mike-

 

 

import com.greensock.*;

import com.greensock.easing.*;

import com.greensock.plugins.*;

TweenPlugin.activate([TintPlugin]);

 

 

TweenLite.from(image1Group_mc, .5, {x:782, ease:Quint.easeInOut, delay:.1});

 

 

 

next1_mc.addEventListener(MouseEvent.CLICK, next1);

 

 

function next1 (event:MouseEvent): void

{

MovieClip(root).gotoAndStop("image 2");

}

 

 

next1_mc.addEventListener(MouseEvent.MOUSE_OVER, over1);

 

 

function over1 (event:MouseEvent): void

{

TweenLite.to(next1_mc, .3, {tint:0x336600});

}

 

 

next1_mc.addEventListener(MouseEvent.MOUSE_OUT, out1);

 

 

function out1 (event:MouseEvent): void

{

TweenLite.to(next1_mc, .3, {tint:0xCC0000});

}

 

 

 

 

 

previous1_mc.addEventListener(MouseEvent.CLICK, previous1);

 

 

function previous1 (event:MouseEvent): void

{

MovieClip(root).gotoAndStop("image 3");

}

 

 

stop();

 

Thanks again :)

Link to comment
Share on other sites

That just means that your next1_mc doesn't refer to anything. It's null. No good. Nada. Invalid. Kaput. Zilch.

 

I bet if you do a trace(next1_mc) right before the tween, you'll see that it's null. So you just need to make sure that points to something valid. Maybe you forgot to name your instance that you have on the stage.

Link to comment
Share on other sites

That's the strange thing, if I remove the "Mouse_Over" and the "Mouse_Out" functions from the script, the "next1_mc" button does exactly what it supposed to when clicked, it jumps to the frame labeled "image 2" and I get no errors with it or the previous1_mc. But when I click "next1_mc" when the "Mouse_Over" and the "Mouse_Out" functions are in the script I get the error code. Also to note, the actual tint tween for "next1_mc" works fine. I'm stumped, I can't figure out why something so simple shouldn't work :cry:

 

-Mike-

Link to comment
Share on other sites

Thank you for taking the time in looking into this for me, it's greatly appreciated. Attached is the FLA, please don't laugh at the simplicity of how it looks. I was just testing out an idea to create a slide show gallery for a my website. The strange thing is it functions properly but the output window pops up with the error code. Also, how can I stop the word "next" from being tinted since it's inside the mc being tinted. Thanks again!

 

-Mike-

Link to comment
Share on other sites

The errors are being caused by the way you set up your FLA. You do indeed have a next1_mc instance on the stage at first. Then when the button is clicked, it moves to a different label on the timeline at which point there IS NO next1_mc instance! Essentially since you created a new keyframe there and deleted that MovieClip, Flash dumps it as soon as it goes to that frame/label. When the mouse isn't over the next1_mc anymore, you have it spawning a tint tween, so TweenLite tries doing that and chokes because the target of that tween no longer exists! Like I said, if you put a trace(next1_mc) right before your tween, you'll see that it returns null in that case.

 

You need to either adjust the way you built your FLA so that the object(s) you're tweening still exist when you're tweening them or remove the corresponding event listeners that are triggering the problematic tweens. For example, in your next1() method, you could add next1_mc.removeEventListener(MouseEvent.MOUSE_OUT, out1);

 

As for not tinting the words in the button(s), you'd need to separate the background of the button from the text and only do the tint tween on the background object. Remember, in Flash, a tint affects EVERY pixel of the DisplayObject.

 

Hope that helps.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...