Jump to content
GreenSock

fs_tigre

Tweening using input fields [SOLVED]

Recommended Posts

Hi,

 

This is my first time working with inputFields in Actionscript 3.0 and I’m lost.

 

What I want to do is create two input fields and one button, one inputField to control the X position of a movieClip and the other inputField to control the Y position of the same movieClip and be able to use the button to tween it with a CLICK event, to the position specified in the input fields.

 

Can some be so kind and show me how to do something like this?

 

Thanks

Link to comment
Share on other sites

function onClick(event:MouseEvent):void {
   TweenLite.to(mc, 1, {x:Number(myXField.value), y:Number(myYField.value)});
}

Link to comment
Share on other sites

First of all thanks a lot for your reply.

 

I know I know, but could you please help me with the code for the text fields? Sorry!

 

I will understand if you don’t have the time for this.

Link to comment
Share on other sites

I know I know, but could you please help me with the code for the text fields? Sorry!

I don't understand - are you saying you don't know how to put the TextFields on the stage?

Link to comment
Share on other sites

What I don't know is how to get the value from the input Field and use it in TweenLIte class.

 

Sorry! but most of what I do are animations using TweenLite, so I only know a little bit of actionscript 3.0 (still learning) that's why I said that if you don't have the time I will understand it since this has nothing to do with your wonderful tween engine.

 

Thanks

Link to comment
Share on other sites

No problem - that's what I was trying to communicate in the first code snippet - did you notice what I plugged in for the x and y values? Let's say you name your TextInput component for the x-coordinate "myXField". To get the value, you just use myXField.value. It will return a String, though, so just cast it as a Number by wrapping it in Number(). Here's the code again:

 

function onClick(event:MouseEvent):void {
   TweenLite.to(mc, 1, {x:Number(myXField.value), y:Number(myYField.value)});
} 

 

If, however, you're using a regular TextField instance of type "input", then you get its value using the "text" property, so in that case the code would look like:

 

function onClick(event:MouseEvent):void {
   TweenLite.to(mc, 1, {x:Number(myXField.text), y:Number(myYField.text)});
} 

Link to comment
Share on other sites

I had to come back to thank you again for your help!

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