Your Ad Here

Set Property


This tutorial is going to cover how to use the "setProperty" action to change different propeties of an object using action scripts only.

We're going to use the "scale property" for this tutorial as an example.

In addition to that, you're going to be introduced to using "input" text fields to change the values.

1:

  • Start by converting the object you desire to change its properties to a Movie Clip and add an Instance Name to it, I called mine flashtext.
  • Create a button. This button is going to be used to apply the actions.

Now let's add the following action to your button:

on (release) {
setProperty("flashtext", _xscale, "200");
setProperty("flashtext", _yscale, "200");
}

The above action sets the property of flashtext, which is the instance name of our movie clip, to increase its X and Y scales 200%

image01
Fig 1

The scale property is only one of the many properties that can be chosen from a drop-down menu as shown in Fig1.

2:

Going well? Ok, let's make this more dynamic now and allow the user to enter whatever value he desires. We're going to use input fields for this.

  • Select the Text Tool, choose "Input Text" in the properties bar and draw 2 fields on the stage. image02
  • Select one of the text fields and go to the Properties bar. Add a variable name to it, I called on of them xinput and the other one yinput. image03
  • Modify the previous Action Script to the following:

on (release) {
setProperty("flashtext", _xscale, xinput);
setProperty("flashtext", _yscale, yinput);
}

Notice, we replaced the values with the variable names. This means whatever value is entered into the text fields will be entered there! Make sure the value is set to expression, meaning without the quotation marks "".

Test your movie!

Conclusion:

What we did:

  • Converted the object to a Movie Clip and added an instance name to it
  • Created a button to set the values on release
  • Added an action to the button to change the scale property of our Movie Clip.
  • Took this one step further by adding Input Fields to allow users enter whatever value they desire, added a variable name to each field

Flash is eaaaasy ;)

Download *.fla



Author's URL: AEvision
Thank you for voting.
Rate this Materials:
Bad 
1 2 3 4 5 Excellent
Share print this page subscribe to newsletter subscribe to rss

Our Flash tutorials provide you with step-by-step instructions on how to create beautiful Flash animations and integrate them into your website. More Flash & Swish: Most Popular Materials | Fresh Materials | More Flash Tutorials at FlashPerfection.com

No comments yet...
Add comments to "Set Property"

Captcha