Jump to content
Search Community

TweenMax - require an if at X Y co-oridnates then play clip?

madina test
Moderator Tag

Recommended Posts

Can anybody please help?

I require a clip to play when it reaches a specific axis... how do I do this?

The clip must also dissappear when it is no longer at that axis.

 

Any ideas?

 

Heres my code:

 

stop();

import gs.*;

import gs.easing.*;

 

 

mainStage.stage2.onRelease = function() {

TweenMax.to(mainStage, 2, { motionBlur:true, delay:0.3, _x:-230, _y:-230, ease:Back.easeOut});

 

}

mainStage.btn1.onRelease = function() {

TweenMax.to(mainStage, 2, { motionBlur:true, delay:0.3, _x:-230, _y:-230, ease:Back.easeOut});

 

}

 

mainStage.btn2.onRelease = function() {

TweenMax.to(mainStage, 2, {motionBlur:true, delay:0.3, _x:-1230, _y:-230, ease:Back.easeOut});

 

}

 

mainStage.btn3.onRelease = function() {

TweenMax.to(mainStage, 2, {motionBlur:true, delay:0.3, _x:-230, _y:-1340, ease:Back.easeOut});

 

}

 

mainStage.btn4.onRelease = function() {

TweenMax.to(mainStage, 2, {motionBlur:true, delay:0.5, _x:-1230, _y:-1340, ease:Back.easeOut});

 

}

 

Thanks in advance

 

:?

Link to comment
Share on other sites

What do you mean by "axis"? Are you wanting to play() a MovieClip timeline animation when an ActionScript-driven tween causes your object to reach certain coordinates? Are you tweening to those coordinates or does your tween move past them? I don't see any code in your post that has anything to do with trying to play a clip at a certain position. If you need to check the _x/_y position during a tween, you could use an onUpdate, but it seems odd that you'd want to play() when it reaches certain coordinates and then hid the clip as soon as it's not on those coordinates because it may flash on the screen for 1 frame and then disappear (unless your tween uses those coordinates as the destination coordinates in which case you could just use an onComplete).

 

Also, why are you using the old "gs" package name? It should be "com.greensock" now. MotionBlurPlugin was released first in v11 which uses the "com.greensock" package name. Are you a Club GreenSock member? MotionBlurPlugin isn't in the public downloads - it's only for Club GreenSock members. Don't forget to activate() the plugin first too.

import com.greensock.*;
import com.greensock.plugins.*;
TweenPlugin.activate([MotionBlurPlugin]);

Link to comment
Share on other sites

  • 2 weeks later...

Apologies I'm fairly new to GreenSock/Actionscript.

 

I am a GreenSock member some confusion over code previously supplied by the publisher.

Thanks for the notification I have now fixed this (see code at bottom of reply)

 

When co-ordinates are reached I require only one clip to appear when destination is complete/reached.

The others must fade/animate out.

 

If you take a look at my file I think you will have a better understanding of what I'm trying to achieve...

http://www.madina.co.uk/tmp/018_019.swf

 

I think this what is required is the 'onComplete' function you mentioned and possibly the 'onStart' function

 

Do you have an example or know here I might be able to find relevant usage of this code?

 

P.S. I am unsure how to activate the MotionBlur plugin.

 

code - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - >

 

stop();

import com.greensock.*;

import com.greensock.plugins.*;

TweenPlugin.activate([MotionBlurPlugin]);

 

 

mainStage.stage2.onRelease = function() {

TweenMax.to(mainStage, 2, { motionBlur:true, delay:0.2, _x:-230, _y:-230, ease:Back.easeOut});

 

}

mainStage.btn1.onRelease = function() {

TweenMax.to(mainStage, 2, { motionBlur:true, delay:0.2, _x:-230, _y:-230, ease:Back.easeOut});

 

}

 

mainStage.btn2.onRelease = function() {

TweenMax.to(mainStage, 2, {motionBlur:true, delay:0.2, _x:-1230, _y:-230, ease:Back.easeOut});

 

}

 

mainStage.btn3.onRelease = function() {

TweenMax.to(mainStage, 2, {motionBlur:true, delay:0.2, _x:-230, _y:-1340, ease:Back.easeOut});

 

}

 

mainStage.btn4.onRelease = function() {

TweenMax.to(mainStage, 2, {motionBlur:true, delay:0.4, _x:-1230, _y:-1340, ease:Back.easeOut});

 

}

 

< - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - code

Link to comment
Share on other sites

Your activation code is right, but make sure that you actually have the MotionBlurPlugin.as file in the com/greensock/plugins directory (it comes in the Club GreenSock membership download which you can get by logging into your account at http://www.greensock.com/account/ and you must be "Really Green" or higher to get it).

 

As for the onComplete, it'd look kinda like this:

 

TweenMax.to(mc, 1, { motionBlur:true, delay:0.2, _x:-230, _y:-230, ease:Back.easeOut, onComplete:myFunction});
function myFunction():Void {
   //your other code here...
}

 

But you might want to use a TimelineLite instead and just sequence those tweens from the beginning (when someone clicks one of the buttons), like (pseudo code):

 

var timeline:TimelineLite;
btn1.onRelease = function():Void {
   if (timeline != undefined) {
       timeline.kill(); //kills any animations that are currently occurring, like if the user clicks one button and then while it's tweening, they click another.
   }
   timeline = new TimelineLite();
   timeline.append( TweenMax.to(mc1, 1, { motionBlur:true, delay:0.2, _x:-230, _y:-230, autoAlpha:100, ease:Back.easeOut}) );
   timeline.appendMultiple( TweenMax.allTo([mc2, mc3, mc4], 1, {autoAlpha:0}) );
}

Link to comment
Share on other sites

Hi Thanks for this...

I think its the second script I'm after.

 

However I have to often rely on 'script assist' to get my code working.

I have no idea where to place this code?

Does it completely replace the existing code?

Is it placed somewhere in the existing code or clip?

 

Sorry for my lack of knowledge I do hope you can help this novice scripter.

 

MC

Link to comment
Share on other sites

I hate to say it, but if you rely on script assist and couldn't follow this code, you probably need to team up with a developer to help you out on your project or do some reading to get up to speed yourself on ActionScript basics. There's no reason to feel bad about being a newbie or anything. We've all been there. But I don't have time to walk you through all the basics or spoon-feed each script to you for your particular FLA (maybe someone else will want to chime in with that though). There are some great books out there and plenty of resources online for learning ActionScript. It'll take some time, though. Kirupa.com, actionscript.org, gotoandlearn.com, and lynda.com are a few. And I've got a "getting started" article about tweening at http://www.greensock.com/get-started-tweening/ but I think you'll need more than that.

Link to comment
Share on other sites

Hhhmmm frustrating that I need to learn lots of unnecessary actionscript to understand where to place this specific code.

I don't expect be walked through the code but I would have a greater understanding actionscript seeing it in working in situ.

 

I hate to say and am not being funny but I reckon you could have showed me where the code went in less time than it took writing your last post.

Never mind I'll bash my head against this monitor for about eight hours I'll get there in the end. LOL

 

Still friends yeah?

Link to comment
Share on other sites

Of course, still friends :)

 

The reason I didn't tell you where to put the code is because it's not really about where to put the code. That code wasn't even written for your specific project. I didn't name all the variables as you'd surely need them because I don't have your FLA to look at. Once I start down that road, it opens Pandora's box - I'd be willing to bet it would spawn a bunch more questions that deal with basic ActionScript concepts which isn't really what this forum is for. And again, I just don't have time (I wish I did). The code I posted was simply to illustrate a concept and wasn't intended to be copied & pasted into your FLA. Sorry man. Again, maybe someone else has time to pitch in and walk you through it.

Link to comment
Share on other sites

OK well this is the closest I've managed to get with this...

 

http://www.madina.co.uk/tmp/018_019v2.swf

 

It works ok I'm sure the code could possibly be better.

Perhaps it needs an iF statement to allow an animated 'out' or end transition.

 

Here's the FLA if anyone cares to take a look...

 

http://www.madina.co.uk/tmp/018_019v2.zip

 

 

mainStage.btn1.onRelease = function() {
TweenMax.to(mainStage, 2, {  motionBlur:true, delay:0.2, _x:-230, _y:-230, ease:Back.easeOut, onStart:myFunction});
function myFunction():Void {
mainStage.panel01.gotoAndPlay("over");
mainStage.panel02.gotoAndPlay("out"); 
mainStage.panel03.gotoAndPlay("out"); 
mainStage.panel04.gotoAndPlay("out"); 

}
}
mainStage.btn2.onRelease = function() {
TweenMax.to(mainStage, 2, {motionBlur:true, delay:0.2, _x:-1230, _y:-230, ease:Back.easeOut, onStart:myFunction});
function myFunction():Void {
mainStage.panel01.gotoAndPlay("out");
mainStage.panel02.gotoAndPlay("over"); 
mainStage.panel03.gotoAndPlay("out"); 
mainStage.panel04.gotoAndPlay("out");

}
}

mainStage.btn3.onRelease = function() {
TweenMax.to(mainStage, 2, {motionBlur:true, delay:0.2, _x:-230, _y:-1340, ease:Back.easeOut, onStart:myFunction});
function myFunction():Void {
mainStage.panel01.gotoAndPlay("out");
mainStage.panel02.gotoAndPlay("out"); 
mainStage.panel03.gotoAndPlay("over"); 
mainStage.panel04.gotoAndPlay("out"); 

}
}

mainStage.btn4.onRelease = function() {
TweenMax.to(mainStage, 2, {motionBlur:true, delay:0.4, _x:-1230, _y:-1340, ease:Back.easeOut, onStart:myFunction});
function myFunction():Void {
mainStage.panel01.gotoAndPlay("out");
mainStage.panel02.gotoAndPlay("out"); 
mainStage.panel03.gotoAndPlay("out"); 
mainStage.panel04.gotoAndPlay("over"); 

}
}

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