Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
MrMiyagi

Access of "texFields" propertyarray trough a function.

Recommended Posts

Hello,

 

I am trying to call a function that contains timelinemax, tweenmax and splittextfield. The problem is that the textFields property does not seem to work from inside this function. I get the following error message from all 3 lines inside the function where i call the function parameter "nameofthesplittextfieldvariable".textFields :

 

Access of possibly undefined property textFields through a reference with static type String.

 

Here is how my function needs to work:

 

var text1:SplitTextField = new SplitTextField(this.pic1_mc.txt1);

function myfunction(nameofthesplittextfieldvariable:String, delaynumber:int):void
{
timeline.appendMultiple(TweenMax.allFrom(nameofthesplittextfieldvariable.textFields, 1, {y:"-100", autoAlpha:0, ease:Elastic.easeOut}, 0.05));

       for (var i:int = nameofthesplittextfieldvariable.textFields.length - 1; i > -1; i--) {
timeline.insert(
TweenMax.to(nameofthesplittextfieldvariable.textFields[i], 2, 
{blurFilter:{blurX:10, blurY:10}, x:Math.random() * 650 - 100, y:Math.random() * 350 - 100, scaleX:Math.random() * 4 - 2, 
            scaleY:Math.random() * 4 - 2, rotation:Math.random() * 360 - 180, autoAlpha:0, delay:delaynumber, ease:Quad.easeIn, 
			repeat:0, repeatDelay:1.2}) 
			  );
}
}
myfunction('text1', 8);

 

 

This works beautiful without the function, but would like to make it all happen without repeating code, so would be thankful for a solution of how to make the textFields property work with the function? Thank you!

Link to comment
Share on other sites

You passed the literal text (String) "text1" instead of the reference to the actual SplitTextField object :) Don't put quotes around it.

 

BAD: myfunction('text1', 8);

GOOD: myfunction(text1, 8);

Link to comment
Share on other sites

Thanks,

 

I changed myfunction('text1', 8); to--> myfunction(text1, 8);

 

It seems something is still wrong because the same error appears with another new one.

I might verywell have some beginner mistakes in my code.

 

I get the following errors:

 

1119: Access of possibly undefined property textFields through a reference with static type String. (this error comes 3 times referring to every line inside the function containing "nameofthesplittextfieldvariable.textFields.length" or "nameofthesplittextfieldvariable.textFields")

 

and

 

1067: Implicit coercion of a value of type com.greensock.text:SplitTextField to an unrelated type String. ( refers to myfunction(text1, 8); )

 

 

Thanks for help! :-)

Link to comment
Share on other sites

I think what Jack is trying to say is that your function's first parameter should be typed not as a String but rather a SplitTextField object. You are trying to pull the textFields from nameofthesplittextfieldvariable, which the string class doesn't have, its part of the SplitTextField class.

Link to comment
Share on other sites

Ok,

 

This worked. Just changed the

 

function myfunction(nameofthesplittextfieldvariable:String, delaynumber:int):void

to -->

function myfunction(nameofthesplittextfieldvariable:Object, delaynumber:int):void

 

Works perfect. Thank you.

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