Now: Tutorial for Web and Software Design > Flash > Action Script > Flash Content
> Set Property [Bookmark it]
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


[Bookmark][Print] [Close][To Top]
  • Prev Article-Flash:

  • Next Article-Flash:
  • Related Materias
    Shape Transformations
    Flash 8 Tutorial - Shape T
    Create Flying Hearts Effec
    Mouse Follower in Flash
    Communicating Between Acti
    Flash Game (Exclusive Tuto
    Opposeable Mouse Effect
    Use FSCommand With the Bro
    Getting URL
    Self-Animating Objects and
    Topics
    Photoshop Tutorial
     

    Special Effect

      3D Effect
      Photoshop Articles
    Programming Tutorial
     

    C/C++ Tutorial

      Visual Basic
      C# Tutorial
    Database Tutorial
     

    MySQL Tutorial

      MS SQL Tutorial
      Oracle Tutorial
    Graphic Design Tutorial
     

    Coreldraw Tutorial

      Illustrator Tutorial
      3D Graphics Articles
    Webmaster Articles
     

    Domain Service

      Web Hosting
      Site Promotion
    Java Tutorial&Articles
     

    Java Servlets

      JavaEE Tutorial
     

    JavaBeans Tutorial

    XML Tutorial&Articles
     

    XML Style Tutorial

      AJAX Tutorial
      XML Mobile
    Flash Tutorial&Articles
     

    Flash Video

      Action Script
      Flash Articles
    OS Tutorial&Articles
     

    Linux Tutorial

      Symbian Tutorial
      MacOS Tutorial