Results 1 to 7 of 7

Thread: Tween class

  1. #1
    Join Date
    Feb 2007
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Tween class

    Hello everybody

    have a problem, maybe someone out there can help me...

    I have a galery. It works fine. Now i want to add some FX when changing pictures. The problem is, the FX should start only when the picture has finished loading, so that the FX is visible.

    On the main-timeline i have this code:

    PHP Code:
    function ladeBild(paktBild) {  
        
    status_mc._visible 1;  
        
    bild bilder_theDataStore[paktBild].pic
        
    bildname bilder_theDataStore[paktBild].name_
        
    titel_txt.text bildname;  
        
    bild_mc._xscale bild_mc._yscale=100;  
        
    //bild_mc._alpha = 100; 
        
    loadMovie(bild"bild_mc");  
         
       
    this.onEnterFrame = function() {  
        if (
    bild_mc.getBytesLoaded()>=bild_mc.getBytesTotal() && bild_mc.getBytesLoaded()>12) {  
           
    delete this.onEnterFrame;  
           }  
       }; 

    // When i put the below code here, the FX works, but it starts before the
    // picture has finished loading... so no use putting it in here...

    //new Tween(bild_mc, "_x", Bounce.easeOut, -100, 300, 1, true); 
    //new Tween(bild_mc, "_alpha", Strong.easeOut, 0, 100, 5, true); 
    and on the Movieclip "bild_mc" i have this code:

    PHP Code:
    onClipEvent (load) { 
        var 
    0

    onClipEvent (enterFrame) { 
        if (
    this._url != this._parent._url && !this.loaded
        { 
            var 
    kilobytes Math.ceil (this.getBytesTotal () / 1024); 
            var 
    prozent Math.ceil ((this.getBytesLoaded () / this.getBytesTotal ()) * 100); 
            
    this._parent.counter_txt.text "Lade " prozent "% of " kilobytes "k"
            
    this._parent.loading_txt.text "Bild wird geladen - Bitte warten!"
            
    this._parent.status_mc._width prozent 2
            if (
    prozent == 100
            { 
                 
                
    i++; 
                
    // grosses bild bei bedarf anpassen START 
                
    if (this._width>_global.picmaxbreite) {  
                    
    this._width _global.picmaxbreite;  
                    
    this._yscale this._xscale;  

                } 
                    
    // grosses bild bei bedarf anpassen ENDE 
                
    if (== 15
                { 
                    
    this.loaded true
                    
    this._parent.counter_txt.text ""
                    
    this._parent.loading_txt.text ""
                    
    this._parent.status_mc._visible 0
                    
    delete i

    trace ("finished loading...");  // this is displayed !
    // I have here the FX, but it doesn't start/show ??!!
    new Tween(this"_x"Bounce.easeOut, -1003001true); 
    new 
    Tween(this"_alpha"Strong.easeOut01005true); 
    // 
                     
                

            } 
        } 

    I check the picture to be loaded, and then want to start the FX ... but the TWEEN does not start. is this because it is in a movieclip???

    Every help is appreciated...! Thanks in advance

    Clark Kent

  2. #2
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    Instead of making Flash work triple time (Loading, Checking, Acting)

    Why don't you "preload" your images off stage.

    Make an emptyMovieClip() off stage, then attach each image into it, then use your code to bring it over from the eMC to the bildMC.

    The picture will be loaded already, and you can use your working code that starts it right away.

    Does that make sense?


    Otherwise try this:

    Code:
    [trace ("finished loading...");  // this is displayed !
    // I have here the FX, but it doesn't start/show ??!!
    new Tween(_root.bild_mc, "_x", Bounce.easeOut, -100, 300, 1, true); 
    new Tween(_root.bild_mc, "_alpha", Strong.easeOut, 0, 100, 5, true); 
    //
    As most of your this comes within a clipEvent handler... levels can get confusing to the movie.
    {CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

  3. #3
    Join Date
    Feb 2007
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Hi

    Thank you very much for your reply.

    Sadly I can't preload the images as the infos come from an external XML-File.
    All pictures are loaded dynamically. Thumbs created and Big pictures display etc....
    and there can be a lot of pictures in each galery...!

    I also tried

    PHP Code:
    new Tween(_root.bild_mc"_x"Bounce.easeOut, -1003001true); 
    doesn't work neither...

    I am confused..?!

    Is there a way to check on the main-timeline (where the tween would work) if the picture has loaded?

  4. #4
    Join Date
    Feb 2007
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Oh no!!!

    I found it ... and .... i think I must apologize with you...

    what a stupid error! I really did'nt know...!

    the problem was, that i have on the main-timeline this code:

    PHP Code:
    import mx.transitions.Tween;
    import mx.transitions.easing.*; 
    But I need to put it also on the clip-event!!!!!!!!!!!!!! so I had to put it also into bild_mc in order to work...It seems that in Flash, when you import the class on the main timeline and use it on a ClipEvent you have to re-import the class!!!!

    Crazy! But I am happy I got the solution!!!!

    Thanks to all

    bye bye

  5. #5
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    Glad you got it... but err.. which ClipEvent are you using? on Load or on EnterFrame?
    {CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

  6. #6
    Join Date
    Feb 2007
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    The new Code on the bild_mc is:

    PHP Code:
    onClipEvent (load) {  
    import mx.transitions.Tween
    import mx.transitions.easing.*;  
        var 
    0;  
    }  
    onClipEvent (enterFrame) {  
        if (
    this._url != this._parent._url && !this.loaded)  
        {  
      .... 
    here comes rest of code... 
    that's it...

    thanks again,
    greets

    Clark Kent

  7. #7
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    Okay, I am just not used to seeing this code you have for the transitions. Seems to me you don't need it in both places.

    It should HAVE to come in a clipEvent, which means it can't work on the main time line by itself... so you should be able to remove it from there, and only have it on the MC.
    {CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •