The Debugger

 

Complete source for lesson18

Source

Launch from Control Menu

Viewing variables and properties

Select the object first

Using the watcher

Must be scoped properly

_level0.myName

_level0.Ani1_mc.Ani2_mc.Ani3_mc.myName

Setting breakpoints

Step over

Step in

Step out

Remote Debugging

Publish settings

Theoretically the one on this page should work. Left-click on movie and select Debugger from popup menu.

Dragging Around

 

Source

To start dragging:

myClip_mc.startDrag();

To stop dragging:

myClip_mc.stopDrag();

And to constrain the movement when dragging:

myClip_mc.startDrag([lock, [left, top, right, bottom]]);

Source

Some target detection. You can tell if a movieClip is dropped on top of another movieclip:

myClip_mc._droptarget;

But it's weird and leftover from old Flash syntax. It won't return the correct scope directly, it returns the absolute path in slash syntax notation of the movie clip instance on which the MovieClip was dropped.

So, this:

myClip_mc._droptarget;

Returns "/target_mc"

So you need to use the obscure "eval" command:

eval(myClip_mc._droptarget);

Which returns "_level0.target_mc"

Duplicity

 

Source

To duplicate a movieClip:

counter = 0;

duplicate_btn.onRelease = function() {

counter++;

star0_mc.duplicateMovieClip ("star"+counter+"_mc", counter);

_root["star"+counter+"_mc"]._y = counter*10;

};

GOTCHA: You can't duplicate a movieClip if it's not there. Therefore, if you want to make things appear from "out of nowhere" you've got to have a movieclip on the stage. You can set it offstage or turn off its _visible property on the first frame.

GOTCHA: You must specify the layer for the clip to live on. If you don't, the new duplicate will replace the old duplicate.

Source

A fancier duplicator that uses random values for location, scale and alpha:

counter = 0;

duplicate_btn.onRelease = function() {

counter++;

star0_mc.duplicateMovieClip ("star"+counter+"_mc", counter);

_root["star"+counter+"_mc"]._y = Math.floor(Math.random()*100);

_root["star"+counter+"_mc"]._x = Math.floor(Math.random()*100);

_root["star"+counter+"_mc"]._alpha = Math.floor(Math.random()*100);

//Put the random value in a variable so its

//the same for both _yscale and _xscale

scaleVal = Math.floor(Math.random()*100);

_root["star"+counter+"_mc"]. _yscale = scaleVal;

_root["star"+counter+"_mc"]. _xscale = scaleVal;

};

NEW TRICK: Using _root and [ ] brackets to work with variable names for object names.

This will work:

_root["myClip"+someVariable+"_mc"]. _someproperty

But this won't:

myClip"+someVariable+"_mc". _someproperty