Jump to content
Search Community

New ShaderFilter Class and TweenLite Problem

Guest RebuiltJorge
Moderator Tag

Recommended Posts

Guest RebuiltJorge

I create my own Static Tween Utiltiy class that uses TweenLite as its core.

In this class I'm going to be applying the new ShaderFilter to a DisplayObject

you can call the class like this:

 

 

ShaderUtils.tweenTo([mc1,mc2,mc3], "pixelate", .1, { dimension:[0, 100], radius:[0,39] } );

 

 

-the first parameter will be an array of display objects that will have the ShaderFilter applied to

-the second is the type of filter that will be applied

-the third is the time it takes to complete the tween

-the fourth will be an object that has the parameters that get applied to the ShaderProxy class which contains a Shader instance I created

 

inside the tweenTo method I have a loop that goes through the custom paramter object and applies each property individually to the ShaderProxy class

I use TweenLite to tween these properties, I find that if I hardcode the property names, it works find like so

 

          //this works but I don't want this
				for (var param in $params) { 

					param will trace out to "dimension" and "radius" respectively
					params[param][1] will trace out to 100 and 39 respectively

					TweenLite.to(currentShader, $time, { dimension:$params[param][1], onUpdate:function() { 
						var filter:ShaderFilter = new ShaderFilter(currentShader.shader);
						$target.filters = [filter];
					}});
				}

				//i want this, but it doesn't work
				for (var param in $params) { 

					param will trace out to "dimension" and "radius" respectively
					params[param][1] will trace out to 100 and 39 respectively

					TweenLite.to(currentShader, $time, { param:$params[param][1], onUpdate:function() { 
						var filter:ShaderFilter = new ShaderFilter(currentShader.shader);
						$target.filters = [filter];
					}});
				}

I figure you're the man and would easily fix this problem, thanks! Come to think of it, maybe you can find a way to integrate the new ShaderFilter class with TweenMax or TweenLite, this would make you God of course.

Link to comment
Share on other sites

To accomplish that, you need to go the slightly longer route:

 

var vars:Object = {};
vars[param] = $params[param][1];
vars.onUpdate = function() {
                    var filter:ShaderFilter = new ShaderFilter(currentShader.shader);
                    $target.filters = [filter];
                 }
TweenLite.to(currentShader, $time, vars);

 

Feel free to whip together a plugin for v11 (which should be out by the end of the month) if it's more convenient for you than a custom class. Or not. http://blog.greensock.com/v11beta/

 

Cheers!

Link to comment
Share on other sites

Guest RebuiltJorge

Thanks again, this works well, nice touch with the onUpdate function, when I get more time to work on this, I'll see what I can do about creating a plug-in, it sounds fun

Link to comment
Share on other sites

Guest RebuiltJorge

Ok, so I almost have this wrapped up, but I still have an issue,

I have an object that has four properties

 

dimension

radius

center[0]

center[1]

 

obviously center is an array that has two values

 

im trying to access each value individually

 

like so

				ShaderUtils.tweenTo([mc],"Twirl",2.4,{ center[0]:100, center[1]:300, dimension:[233], radius:[3] });

				of course center[1] and center[0] do not work, i get 'expecting colon before left bracket' syntax error; 


				//////////////////////////////////////////////////////////////////////////////////////////////////////////

				i tried this as well

				var vars:Object = { };
				vars.overwrite = 0;
				vars.ease = $easeType;
				vars[center] = [];
				vars[center][0] = 100;
				vars[center][1] = 300;
				vars[dimension] = 233;
				vars[radius] = 3;

				vars.onUpdate = function() {
					 var filter:ShaderFilter = new ShaderFilter(currentShader.shader);
					 $target.filters = [filter];
				}

				TweenLite.to(currentShader, $time, vars);

 

any ideas

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...