Mailing List
Home
Forum Home
Flash Pro
Subjects
Firework Effect
setInterval bug identified and fixed
setInterval bug identified and fixed
ScrollPane component doesn 't auto update
Help: MX 2004 How to script a print button to print the entire sli
Event Dispatcher between classes
memory management removeMovieClip /
MX2004 Dataset itemClassName
Order of events per frame
XML to Object help
Textfield prototype question
Flash and QuickTime VR
Reading and displaying RSS feeds in Flash MX
Flash MX 2004 Sucks
AW: [Flashcoders] Switch/Case vs If/else
AW: [Flashcoders] Switch/Case vs If/else
Flash Interface with 10mb xml file
Web Service Results
Listener Object 's best practice
 
AS2 Classes - WARNING: AS Newbie....

AS2 Classes - WARNING: AS Newbie....

2004-03-02       - By Andreas Weber

 Back
Reply:     1     2     3     4     5     6  

> An example of what would do this for instance would be a button that
> when pressed, created circles that could be moved around the stage.

Here we go:

1. Open a new Flash file and save it as testDragable.fla

2. Draw a circle and convert it into a symbol

  In the 'Convert to Symbol' dialogue
  - Behavior: MovieClip
  - Registration Point top-left
  - toggle 'Export for ActionScript'
  - Linkage Identifier: circle

  and now comes the important part -
  - AS 2.0 class : Dragable

 In this example we'll save the .as file in the same folder as
testDraggable.fla,
 usually you would save it in you classes folder. If your class path points
to
 a folder named classes, and this folder has several sub-folders than the
class
 name might look something like
   com.motiondraw.movieclip.Draggable

3. make a MovieClip button, instance name button_mc

4. on the first frame of _root put this code:

  button_mc.onRelease = function(){
    initObj = new Object();
    for(i=0;i<5; i++){
      initObj._x = Math.random() * Stage.width;
      initObj._y = Math.random() * Stage.height;
      this._parent.attachMovie('circle', 'circle'+i+'_mc',i, initObj);
    }
  }

5. Open a new .as file and save it as Dragable.as in the same folder as
testDragable.fla

6. Code in Dragable.as:

  class Dragable extends MovieClip{

    // empty constructor
    public function Dragable(){};

    public function onPress(){this.startDrag();}
    public function onRelease(){this.stopDrag();}
    public function onReleaseOutside(){ this.stopDrag();}
  }

7. Save, test and enjoy!


-- ---- ------
Andreas Weber
motiondraw.com




-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ------
Supported by Fig Leaf Software
-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ------
Lower Prices for Certified Training! Check out new lower prices for
Certified Macromedia Training from Fig Leaf Software. Expand your
skill set with courses in ColdFusion, Flash, Rich Internet
Applications and .NET in the new year.  Fig Leaf Software provides
the highest caliber instruction at our training centers in Washington  
D.C., Atlanta, Chicago, Baltimore, Northern Virginia, or on-site at
your location.

Get the details at http://training.figleaf.com/
-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- --
To unsubscribe, e-mail: flashnewbie-unsubscribe@(protected)
For additional commands, e-mail: flashnewbie-help@(protected)