Share Posted February 18, 2015 main_Player.txtScroll.tf.x = 0; main_Player.txtScroll.tf.y = 0; main_Player.txtScroll.x = 166; main_Player.txtScroll.y = 182; main_Player.txtScroll.width = main_Player.txtScroll.tf.width; scrollWords(); function scrollWords():void { main_Player.txtScroll.tf.wordWrap = false; main_Player.txtScroll.tf.autoSize = TextFieldAutoSize.CENTER; if(main_Player.txtScroll.tf.width >= 136) { goForwardTween(tf); } } function goForwardTween(tf:TextField):void { TweenMax.to(tf, 3, {x:248, delay:1, onComplete:goBackTween, onCompleteParams:[tf] }); } function goBackTween(tf:TextField):void { TweenMax.to(tf, 3, {x:-tf.width, delay:1, onComplete:goForwardTween, onCompleteParams:[tf] }); } Hi guys haven't been here in awhile here goes ..... ...basically what I have is a TextField inside a MovieClip, and if the text inside the TextField exceeds a certain size it moves back & forth so that the far right of the MovieClip moves to the far left of the mask and far left of the MovieClip moves to the far right of the mask. But for some reason I cant seem to get it to move it populates the TextField ok .. but wont TweenMax.to functions even if the text is larger than the mask. hope someone can help... Steven Link to comment Share on other sites More sharing options...
Share Posted February 18, 2015 Hm, have you added trace() commands inside the various functions and conditional logic to verify that your code is executing the way you expect? In other words, is (main_Player.txtScroll.tf.width >= 136) true? If you're still having trouble, would you mind zipping up a reduced test case FLA that we can publish to clearly see the problem? You're saying that absolutely nothing moves, right? (You can hit the "more reply options" to get to a screen where you can attach a file) Link to comment Share on other sites More sharing options...
Author Share Posted February 18, 2015 hope this helps you to understand what I am trying to achieve thanks in advance Steven scroller_demo.zip Link to comment Share on other sites More sharing options...
Share Posted February 18, 2015 Hi Steven, I'm confused here. It appears your zip only includes a swf, and in that swf I see animation. We need the fla in order to test the code. I'm not sure what we are supposed to be looking for though as your swf shows animation and you are claiming that TweenLite.to() doesn't work. also, i would make sure you are passing the textfield into your functions properly, start by adding this trace function goForwardTween(tf:TextField):void { trace("tf is : " + tf); TweenMax.to(tf, 3, {x:248, delay:1, onComplete:goBackTween, onCompleteParams:[tf] }); } I'm sure if we saw your FLA it would alleviate a lot of guesswork. 1 Link to comment Share on other sites More sharing options...
Author Share Posted February 19, 2015 import com.greensock.*; import com.greensock.easing.*; import flash.text.TextField; import flash.display.MovieClip; var spc:Number = 0; var maskWidth:Number = 300; var mc:MovieClip = new MovieClip; addChild(mc); mc.x = 150; mc.y = 10; var tf:TextField = new TextField(); mc.addChild(tf); mc.tf.x = 0; mc.tf.y = 0; mc.tf.text = "0123456789123456789012345678901234567890123456789"; trace(mc.tf.text); scrollWords(); function scrollWords():void { mc.tf.wordWrap = false; mc.tf.autoSize = TextFieldAutoSize.CENTER; if(mc.width >= maskWidth) { goForwardTween(mc); } } function goForwardTween(mc:MovieClip):void { spc = (mc.width/2)-(maskWidth/2); TweenMax.to(mc, 3, {x:spc, delay:1, onComplete:goBackTween, onCompleteParams:[mc] }); } function goBackTween(mc:MovieClip):void { spc = (mc.width/2)-(maskWidth/2); TweenMax.to(mc, 3, {x:-spc, delay:1, onComplete:goForwardTween, onCompleteParams:[mc] }); } Hi sorry ... I not used to posting things :/ here is my fla. I figured out the animation before I posted it but cant get it to work correctly. As the size of the tf & therefore the size of the mc will be dependant on the tf.text, it doesn't report back the correct tf.text.size so cannot in turn correct the animation x values. as shown on the png I posted. Thanks in advance Steven changed code and still not work... but should lol scroller_demo (2).zip Link to comment Share on other sites More sharing options...
Share Posted February 19, 2015 Hi, it seems you were trying to get the width of the mc and TextField too early. The following code should trace an accurate width. import com.greensock.*; import com.greensock.easing.*; import flash.text.TextField; var spc:Number; mc.tf.x = 0; mc.tf.y = 0; mc.tf.text = "0123456789123456789012345678901234567890123456789"; mc.tf.wordWrap = false; mc.tf.autoSize = TextFieldAutoSize.CENTER; mc.width = mc.tf.width; //width should be correct now trace("width " + mc.tf.width); scrollWords(); function scrollWords():void { if(mc.width >= 300) { goForwardTween(); } } function goForwardTween():void { spc = (mc.width/2)-150; TweenMax.to(mc, 3, {x:(mc.width/2)+spc, delay:1, onComplete:goBackTween}); } function goBackTween():void { spc = (mc.width/2)-150; TweenMax.to(mc, 3, {x:(mc.width/2)-spc, delay:1, onComplete:goForwardTween}); } Not exactly sure about the rest of the logic in the code, but I don't think there are any issues with what GSAP is doing. Pretty sure you can take it the rest of the way now that the width is working. 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now