views:

104

answers:

1

I just finished a small task for school in Flash and I'm wondering about about the reasons to put Some actionscript in the scene and other in the movie clip.

Info: I'm using Flash CS3 and ActionScript 2.

I uploaded the file here, for anyone who wants to take a look: http://www.mediafire.com/download.php?2z2mivtmokg

Now, I did all the actionscript in the movie clip and I'm wondering, why doesn't it work when I try to do it from the Scene? Suppose I take all the code from the Actions layer in the clip, copy it, delete that layer, go to the scene, make and Actions layer there and past the code, why doesn't it work?

I've tried adding circle_mc(the name of my clip) to the code, but to no avail...

Can someone help me here? Trying to make it so that no code appears in the movie clip, cause I think that was my original assignment.

To further dig in: how should I go about deciding which code goes into the scene and which goes into the movie clip?

+1  A: 

If you are inside of a movieclip and you can use "this.something" it reffers to the movieclip you are working in...ie: "circle_mc", but if you go to the root timeline and create an actions layer you can't use "this" anymore, you have to reference the movieclip name. So, if you created a new layer on the root timeline called actions, you could paste this code in and it will still work (delete your old code, inside the mc too):

var stoppedOn = 2;

circle_mc.onPress = function()
{
    circle_mc.startDrag();
}

circle_mc.onRelease = function()
{
    circle_mc.stopDrag();
}

circle_mc.onRollOver = function()
{
    circle_mc.gotoAndPlay(stoppedOn);
}

circle_mc.onRollOut = function()
{
    circle_mc.stop();
    stoppedOn = circle_mc._currentframe;
}

I personally think your code stays more maintainable if you put all of your code on the root timeline. It will also prep you for working with Classes down the line. I would also reccomend learning AS3 in your spare time as it's really the way to go.

Joe
Yeah, got any good books or online courses? Free, preferably.
WebDevHobo
I think the best resource by far are the Lynda.com AS3 videos (not free). gotoandlearn.com is free and a pretty good at explaining more advanced stuff.
Joe