Sunday, April 4, 2010

Can't get tween to work in action...

The code works below:

if (currentpage = ''friends'' {
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 new Tween (friends_btn.secondLine.para1,''_alpha'',Regular.easeOut,100,0,2,true);
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 }

but why won't this work?

new Tween (this[currentpage+''_btn''].secondLine.para1,''_alpha'',Regular.easeOut,100,0,2,tru e);

Can't get tween to work in action...

I have had this type of problem in the past.

Try this;

var cpBtn:String = currentpage+''_btn'';

new Tween (this[cpBtn].secondLine.para1,''_alpha'',Regular.easeOut,100,0,2,true);

Can't get tween to work in action...

no strangly it didn't work. I tried this already. Thanks anyway.


your first post looks mal-formatted, but is assigning currentPage to be ''friends''.聽 none of the rest of the code is doing that so a possible problem is the value of currentPage.

use trace(currentPage) to confirm.

the other issue is your use of ''this'' in a tween function and that's likely to be problematic.聽 to remedy, create a timeline reference and use that to coerce your string into an object.


trace(currentpage);

if (currentpage == ''friends'') {
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 new Tween (friends_btn.secondLine.para1,''_alpha'',Regular.easeOut,100,0,2,true);
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 }

ok the trace reports currentpage = friends.The tween works with this code. All I want to do is replace the friends_btn with: currentpage+''_btn''

Currentpage can be 8-10 different pages so the code saves me replicating the if command 8-10 times.

In nearly all other computer languages it would simply be: (currentpage+''_btn''.secondLine


try:

var tl:MovieClip=this;

new Tween (tl[currentpage+''_btn''].secondLine.para1,''_alpha'',Regular.easeOut,100,0,2,true) ;

  • oil industry
  • No comments:

    Post a Comment