Jump to content
GreenSock

X10

Members
  • Posts

    94
  • Joined

  • Last visited

Posts posted by X10

  1. Hi Vova,

    I tested your code and I didn't have any problems, I ran it at 20 FPS and while it was a little bit juddery, there were no obvious interruptions, I tried it at 31 FPS and that was also fine, so not sure if there is an issue with Flash here, possibly another software/hardware?

     

    X10

  2. This has been an interesting thread to read through, even if some of it was way over my head.

    Carl, thanks for the link, very interesting stuff, I didn't know you could change the FPS of the SWF like that. I also understand that Flash 9 and up does a similar thing automatically with regards to resources when the browser is minimised or you go to a different tab.

  3. Hello again HaunGo,

    I just did a quick search on the Greensock forums and found this thread which should help you get started: viewtopic.php?f=1&t=1723

     

    Also, I put together a little tutorial file for you (attached to this post), it's commented so you can see what bits are what, it's very very simple and doesn't have all the stuff the Greensock homepage intro has, but I hope this will help you get started.

     

    X10

  4. HI Aksel,

    Until Jack comes back with something more comprehensive I'll jump in with what immediately strikes me - you can only have 1 movieClip in each TweenLite instance, so you would have to do:

     

    var tween1:TweenLite = TweenLite.to(bildeKlipp,{autoAlpha: 0});

    var tween2:TweenLite = TweenLite.to(fadeTid,{autoAlpha: 0});

     

    then:

     

    tween1.play();
    tween2.play();

     

    You might consider using a TimelineLite/TimelineMax if you need to control the timing more effectively.

  5. Okay, so I got the tweens working via an array and they using a TweenMax.allTo command (while learning a little bit more about AS3!), so thanks Carl for the pointers to the resources!

     

    My query now is how to get all the points to have a random offset of +/- 10 for each tween.

     

    so for example:

     

    myTimeline.append(TweenMax.allTo(wave, 1.5, {bezierThrough:[{x:100,y:0}, {x:50, y:50}, {x:0, y:100}]),-1.4);

     

    I tried adding "+Math.random()*10" but it seems that this only works once, so all the tweens will be offset by that amount.

     

    I just wondered if I should create a function to generate a number, however would that mean having a function for all the x,y values on my curve?

    Would that even get around the random number generated only once?

     

    X10

  6. Hi DarkBrainComics.

    I'm by no means an expert here, so am sure others will give you a more thourough explanation, but a couple of things I noticed:

    1) Are you using AS2 or AS3? alpha:100 is an AS2 convention, you'd use alpha:1 for AS3

    2) You only need to import greensock once

    3) What is your FPS set at? You've set the tween to take 250 seconds, but they're only 124 frames apart so it could be an overwrite issue.

     

    Try this (assuming AS3):

     

    FRAME 1:

    import com.greensock.*;
    trace("fade in!");
    TweenLite.to(P1_mc, 2, {alpha:1});

     

    FRAME 125:

    trace("fade out!");
    TweenLite.to(P1_mc, 2, {alpha:0});

     

    And let us know if that works.

  7. Hi Carl,

    Many thanks for taking the time to respond, especially my mistyped code. I posted that late last night/this morning and was editing the names of the clips to make them more relevant to the query rather than the actual naming scheme and I forgot to change all the names correctly, as you have quite rightly picked up.

     

    Thank you for the link to the Kirupa thread, I am just reading over that now....of course there is a scope issue-D'Oh! :oops:

     

    X10

     

    Edit: Have just read the Kirupa thread and Calypso post, glad to see I'm not the only fool who thought you can reference a MC via .name or .id !

  8. Hello all,

    I've been playing more and more recently with the Greensock tweening platform and am having a lot of fun learning all sorts of useful tricks!

     

    At the moment I'm stumped on adding movieclips to a TimelineLite from the library.

    What I'm trying to acheive: I have several MovieClips (waveMovieClipA, waveMovieClipB, waveMovieClipC etc.) in my library that I want to add to the stage at a particular point in my Timeline to create a 'wave' animation that roughly follow a BezierThrough path. (Imagine the clips are particles of water going down a curly straw)

    I'll need to randomise when they enter the stage and how far they are from the path, but for now I am not able to even reference them on the timeline.

     

    I'm able to add the clips dynamically to the stage, but I haven't been able to add them to the TimelineLite, any assistance greatly appreciated.

     

    Sample Code:

    myTimeline.append(TweenLite.to(testExp1, 1, {bezierThrough:[{x:147, y:121}, {x:121, y:102}, {x:109, y:127}, {x:329, y:133}], orientToBezier:true}),3);
    
    function addwaveClips():void{
    for(var m:Number=0; m<50; m++) {
    var testWaveClip:expAbc = new waveMovieClipA();
    addChild(testWaveClip);
    testWaveClip.name = 'test'+m;
    testWaveClip.id = 'test'+m;
    testWaveClip.x = 680;
    testWaveClip.y = 10;
    trace("movieClip Instance Name = " + testWaveClip.name);
    trace("movieClip Instance ID = " + testWaveClip.id);
    
    }
    }

  9. Hi Carl,

    Thanks for the tip and the explanation.

    I've put that in, but the problem is that it doesn't seem to actually activate the function again, or if it does, it's not going through the if else statements.

    The function should slow the timer down to a 2 second interval on the countdown when it reaches 3:

     

       if (counter==3){
         clearInterval(intID);
         intID=setInterval(countdown,2000);
      } else if (counter==0) {
         trace("countdown complete");
         TweenLite.to(FilmGrainContainer, 1, {alpha:0,onComplete:killFilmGrain});
         clearInterval(intID);
      }

     

    but when the restart happens, it doesn't check those statements.

    Is there some sort of pointer that is stuck at the end of that if else statement from the first time it ran that needs to reset to get it back to the start of that if statement?

     

    X10

  10. Hi Carl,

    Firstly I just want to thank you for all your input here, it is very much appreciated!

    Secondly, I had a look at your video tutorials and I am very greatful for them, I have learnt a lot about TweenLite/Max that I didn't and have started to use these 'tips & tricks'.

     

    Clearly AS3 is very new to me as I didn't realise I had to restart the EventListener again.

    Your suggestion works perfectly.

     

    My problem now is that the counter function will not restart.

    Here is some simplified code:

     

    var countdown_time:Number=5;
    var counter:Number=countdown_time;
    var intID=setInterval(countdown,1000);
    var test1=String(countdown_time);
    
    function countdown(){
    counter--;
    CountDownText.countdown_txt.text=counter.toString();
    trace('counter says '+counter+' seconds');
    if (counter==3){
    	clearInterval(intID);
    	intID=setInterval(countdown,2000);
    } else if (counter==0) {
    	trace("countdown complete");
    	TweenLite.to(FilmGrainContainer, 1, {alpha:0,onComplete:killFilmGrain});
    	clearInterval(intID);
    }
    }
    
    CountDownText.countdown_txt.text=test1;
    trace(counter);
    
    var myTimeline:TimelineLite = new TimelineLite();
    myTimeline.append(TweenLite.to(myMC, 0, {alpha:0}) );
    ....
    myTimeline.append(TweenLite.to(myMC, 0.3, {alpha:1, onComplete:restart} ),0.5);
    
    
    function restart():void {
    trace('Total timeline lasted'+myTimeline.duration);
    myTimeline.restart()
    addEventListener(Event.ENTER_FRAME,filmGrain);
    TweenLite.to(FilmGrainContainer, 0, {alpha:1, onComplete:countdown});
    var intID=setInterval(countdown,1000);
    countdown_time = 5;
    counter = countdown_time;
    trace('I have now reset countdown_time to '+countdown_time);
    trace('and counter to '+counter);
    trace('Restarted :)');
    }

     

    This does start the numbers counting down again on restart, but it starts at 1, then jumps to 4, then goes down by 1 infinitely, so it's not going through the if statements in counter() again.

     

    I tried adding Dust1.addEventListener(Event.INIT,counter); and removing it in counter() when it reached 0, but that just threw an error.

     

    I realise this is now nothing to do with Greensock/TweenLite so I might take it to another forum, but as Carl has been so helpful here I thought I would post this follow-up.

     

    Thanks again.

    X10

  11. Carl, thanks again for your advice, all worked as expected.

    However this now leads me to restarting a TimelineLite issue.

     

    I took your advice and decided to put the calls into a TimelineLite, but now that I have killed the "dustContainer_mc", it doesn't seem to start up again when restarting the TimelineLite which I am doing via:

     

    myTimeline.append(TweenLite.from(Messaging4, 0.3, {scaleX:0,scaleY:0, ease:Back.easeOut,onComplete:restart} ),0.5);
    
    function restart():void {
    trace('Total timeline lasted'+myTimeline.duration);
    myTimeline.restart()
    }

     

    This is also true for the counter. Presumeably this is because both the counter and the event listener are outside of the TimelineLIte, so I'm assuming I need to put both 'dustContainer_mc' & 'counter' into a function(?) and append them to the beginning of the TimelineLite, but I think I'm missing something.

  12. Hi Carl,

    Thank you for the help, and the little video, very useful.

    Okay, so now that I put my film grain bits in a container and able to tween them seperately, I now have 2 more questions, and I suspect they aren't directly related to Greensock, but any help is greatly appreciated.

     

    1) The counter goes into a Dynamic Text field, I tried turning it into a MovieClip and tweening it so that when it reached 0 it dissapeared, however it doesn't seem to work. I tried putting more layers onto the counter text movie clip and they all tween as they should, but not the Dynamic Text - How can I tween this?

     

    2) Although I can now tween the Alpha of the film grain, technically it's still 'playing', does this mean it's still using resources?

    Is there anyway to stop this clip with Timeline until I restart the whole movie?

     

    Thanks again,

    X10

  13. Hi all,

    I'm quite new to all this but have read through most of the basic documentation.

    I'm having trouble with 2 things, 1 is how to apply something I have created using "Event.ENTER_FRAME" to a timeline and 2 is how to use a counter function with Tween and the Timeline.

     

    I have a AS3 Flash file with some movieclips on them, which I use as a grainy film effect (taken from here: http://www.republicofcode.com/tutorials ... old_grain/), these start as soon as the flash starts, see below code:

    addEventListener(Event.ENTER_FRAME,myEventHandler);
    function myEventHandler(event:Event):void {
    Dust1.alpha=Math.random();
    Dust1.x=Math.random()*688;
    Dust1.y=Math.random()*364;
    Dust1.rotation=Math.random()*360;
    var dustran1=Math.random()*0.65;
    Dust1.scaleX=dustran1;
    Dust1.scaleY=dustran1;
    ...
    }

     

    I also have a counter which counts down from 7 to 0:

     

    var countdown_time:Number=7;
    var counter:Number=countdown_time;
    var intID=setInterval(countdown,1000);
    var test1=String(countdown_time);
    
    function countdown() {
    counter--;
    countdown_txt.text=counter.toString();
    if (counter==3){
    	clearInterval(intID);
    	intID=setInterval(countdown,3000);
    
    else if (counter==0) {
    	trace("countdown complete");
    	clearInterval(intID);
    }
    }
    
    countdown_txt.text=test1;
    trace(counter);

     

    So the whole thing looks like an old grainy movie film leader intro.

    What I'm trying to do is control the grainy flicker effect with Tween and TimeLine, as I want the film grain effect to start to fade out when the counter reaches 1.

    I also have some text clips that I want to tween when the counter displays 3, 2 and 1 respectively.

    I don't want the grain affect playing again until the movie repeats.

    After the grain fades out and the counter finishes and the text clips have played I have other movieclips that need animating but this is the intro and I am trying to figure out how to apply these to Tween and TimeLine.

     

    I think there is probably some basic concept to Flash that I think I'm missing but I would appreciate any input you could give.

    Happy to supply my FLA file if needed!

     

    Thanks!

    X10

×