Jump to content
Search Community

WEIRD TIMELINE MAX BEHAVIOR

ryanhungate test
Moderator Tag

Recommended Posts

Hey GS... I am getting some weird behavior when creating array's of TimelineMax... I am iterating through a loop where I am defining main menu items, and submenu items... submenu holders etc... way too much code to bother you with, but the problem is, it seems like my TimelineMax instances are getting overwritten. I am using a container TimelineMax to do the work.

 

Inside my for loop, this is where I am assigning the TimelineMax instance to a data property of my button class...

 

var sub:Object = new Object();

                   sub = MASTER[i]['BUTTON_SET'][0]['L1_HOLDER'];

                   MASTER[i]['MAIN_BUTTON'].data.submenu_ref = sub;

                   MASTER[i]['MAIN_BUTTON'].addEventListener(buttonEvent.BUTTON_CLICK, handleDown);
                   MASTER[i]['MAIN_BUTTON'].addEventListener(buttonEvent.BUTTON_OVER, handleOverLevelOne);
                   MASTER[i]['MAIN_BUTTON'].addEventListener(buttonEvent.BUTTON_OUT, handleOutLevelOne);    

                   var ro1:Object = returnLevelOneObject(MASTER[i]['MAIN_BUTTON']);

                   MASTER[i]['MAIN_BUTTON'].data.TEXT_TINT         = ro1.TEXT_TINT;
                   MASTER[i]['MAIN_BUTTON'].data.TEXT_TINT_ALPHA    = ro1.TEXT_TINT_ALPHA;
                   MASTER[i]['MAIN_BUTTON'].data.OVER_BLUR         = ro1.OVER_BLUR;
                   MASTER[i]['MAIN_BUTTON'].data.BG_TINT             = ro1.BG_TINT;
                   MASTER[i]['MAIN_BUTTON'].data.BG_TINT_ALPHA     = ro1.BG_TINT_ALPHA;
                   MASTER[i]['MAIN_BUTTON'].data.TWEEN_WIDTH         = ro1.TWEEN_WIDTH;


                   var MTL:TimelineMax = new TimelineMax({paused:true});
                   var MASTER_TL:TimelineMax;


                   MTL.append(TweenMax.to(MASTER[i]['MAIN_BUTTON'].button_bg, .25,{alpha:1, width:ro1.TWEEN_WIDTH + ro1.OVER_BLUR,blurFilter:{blurX:ro1.OVER_BLUR,blurY:ro1.OVER_BLUR},colorTransform:{tint:ro1.BG_TINT, tintAmount:ro1.BG_TINT_ALPHA}}));

                   MTL.append(TweenMax.to(MASTER[i]['MAIN_BUTTON'].text_holder, .25,{alpha:1,colorTransform:{tint:ro1.TEXT_TINT, tintAmount:ro1.TEXT_TINT_ALPHA}}) );
                   MTL.append(TweenMax.to(sub.submenu_holder,.25,{alpha:1,
                       onStart:function()
                       {

                           sub.submenu_holder.visible = true;
                          ////// a bunch of code in this function, pointless to show
                       }

                       /// of course timelines is an array defined in the class file.
                       timelines.push({MASTER:MASTER_TL,MAIN:MTL});


 

ok, so when I hit my button over function

        private function handleOverLevelOne(e:buttonEvent):void
       {
           if(e.currentTarget != cb)
           {
               cb = e.currentTarget;
               if (e.data.timeline['MASTER'] != null) {        e.data.timeline['MASTER'].kill();    }

               var o:Object = e.data.submenu_ref;
               mmh.expandMaskWidth(500);
               mmh.removeEventListener('out',resetTheMenuPosition);                    

               TweenMax.delayedCall(.25,preCheck);

               function preCheck():void
               {                
                   if(e.data.over_button)
                   {
                       if(mmh.needs_scroller)
                       {
                           mmh.expandMaskWidth(500);    
                           mmh.scroller.killTween();
                       }
                       sm.setActiveLevelOneButton(e.currentTarget);
                       e.data.timeline['MASTER'] = new TimelineMax();
                       e.data.timeline['MASTER'].append( e.data.timeline['MAIN'].tweenTo( e.data.timeline['MAIN'].duration ) );
                   }
               }
           }
       }

 

but the funny thing is the submenu that shows up is the last ( sub ) object that I created... like it is getting overwritten on every loop. Do you have any ideas why this would happen?

 

Thanks.

 

Ryan

Link to comment
Share on other sites

Yikes - that's a lot to follow, Ryan. And why are you using nested and anonymous functions like that? Kinda risky. I'm 99.9% sure the problem has something to do with your code, not a bug/issue in TimelineMax but it's tough to troubleshoot based just on the code you posted. Could you post a simplified FLA that demonstrates the issue so that I could publish it and see immediately for myself? I often find that isolating the issue in a separate FLA can quickly reveal what's going on.

 

And again, nested functions are often the source of trouble because they're deleted when the parent function finishes running. Maybe try eliminating those (restructuring so they're not nested).

Link to comment
Share on other sites

(I was using nested TimelineMax's because I had found that they were getting overwritten while iterating through the array, so I tried to assign it to beat the problem but it didnt work. The trouble I am running into seems to be that when the users (mine during testing) mouse movement is too fast, Tweens dont end up where they need to be, on mouseOut... If I wait for the tween to finish, it works, but its like they do not make it back to the 0 playhead of the tween if the mouse out is too fast.)

 

well, putting a simple fla together would be a bit tricky at this point, since the project is getting pretty big and reliant on font loading and 8 other classes... but I am working with the Gaia site xml to start... and I am making a 3 level menu system based on that structure by adding a parameter called 'submenu_of' inside of the tag... so If I have

 

my code will optionally create a 3 level menu system that puts (title) inside the (level 1 = just, level 2 = because, active button = bla) based on what is in those tags... so that is why you are seeing the weird array in my button code.

 

About the nested stuff, to be honest, I just recently changed that after trying to get a better fluid movement and the ability to add a pause(); to the menu system by using TimelineMax. I am storing a bunch of variables inside the data property because I am writing up a cool menu that tweens out, and glows, and drops down, so storing color data, and original size data is a must... so I figured why not store the TweenMax into the data property as well?

 

I am not adding the submenu as a child to each each button, I am keeping everything separate. Ill re write what I have done to place all the TimeLineMax code into the buttonOver functions again and re post the results, but this has been a trial and error for me, was kind of hoping that you would just "know" what the problem was :)

 

Ryan

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