SunQuest
 
       Flash
  Home arrow Flash arrow Page 2 - Basic Flash ActionScript for Designers
IBM developerWorks
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Dedicated Servers  
Actuate Whitepapers 
Moblin 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
FLASH

Basic Flash ActionScript for Designers
By: Adi Reddy Mora
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 109
    2005-06-01

    Table of Contents:
  • Basic Flash ActionScript for Designers
  • Buttons, Movie Clips, and Making them Draggable
  • Navigating, URLs, and Loading Images
  • Loading External MP3 Files

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT

    Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here

    Basic Flash ActionScript for Designers - Buttons, Movie Clips, and Making them Draggable


    (Page 2 of 4 )

    Buttons and Movie Clips

    Buttons can be used to control movies. To accomplish this, you could directly attach actions to the button or movie clip with the on() function. Alternatively, you could write actions in the Timeline using event handler functions with instance names of button or movie clips. This second method is a better practice becuause it handles all your code at one common place instead of spreading it out over all buttons and clips.

    See the example below:

    // Event handler function for button with instance name
    // “button1_btn” which executes the code inside the
    // function when the button is pressed
    button1_btn.onPress = function(){
              anim_mc.gotoAndPlay(5);
    }

    You can use other events in this way as well, such as onRelease, onRollOver, onDragOver, onKeyUp, etc. They also work on movie clips and their instance names.

    Dragging Movie Clips

    You can use the global startDrag()function or the MovieClip.startDrag()method to make a movie clip draggable. This would work with games, customizable interfaces, scroll bars, etc. A movie clip remains draggable until explicitly stopped by stopDrag() method or until another movie clip is targeted with startDrag() method. Only one movie clip at a time can be dragged in a movie.

    Let us see an eample below:

    // Starts dragging when “anim_mc” is pressed
    anim_mc.onPress = function() {
                anim_mc.startDrag();
    };
    // Stops dragging when “anim_mc” is released
    anim _mc.onRelease = function() {
                anim_mc.stopDrag();
    };

    startDrag() has two optional set of parameters that allow you to control the dragging functionality. The first is a boolean true or false parameter, which allows you to lock the dragging to the centre of the movie clip. Using "false" doesn’t lock the dragging to center, and "true" locks it to centre. The default is false.

    anim_mc.startDrag(false);

    The second set of parameters allows you to control the dragging to a specific area of your movie. You should specify 4 values (left, top, right, bottom) based on your movie size.

    anim_mc.startDrag(false, 0, 0, 200, 400);

    More Flash Articles
    More By Adi Reddy Mora


       · Sir my name is "GagandeepCheema", Since few days I am trying to get forward with...
     

    FLASH ARTICLES

    - Using XML and ActionScript with Flex Applica...
    - Interfaces and Events with ActionScript and ...
    - Manipulating Data with ActionScript in Flex ...
    - ActionScript Syntax for Flex Applications
    - ActionScript in Flex Applications
    - A Closer Look at Apollo`s File System API
    - Using the File System API
    - ActionScript 101
    - Flash Buttons
    - Advanced Flash Animation
    - Creating Your First Animated Movie with Flas...
    - Flash: Building Blocks
    - Building Preloaders
    - Fun Things to Do with Movie Clips in Flash MX
    - Referencing Movie Clips in Flash MX







    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway