Groups | Blog | Home
all groups > flash actionscript > september 2006 >

flash actionscript : Manipulating class-generated movieclips


Generic Nickname
9/24/2006 11:29:41 PM
To begin, I have been able to draw rudimentary shapes on the main timeline by
importing this class on the main timeline (first frame) and plugging in the
requisite parameters

Once the shapes are drawn I cannot seem to manipulate them on the main
timeline to make them move about and alpha up and down. Is there some way to do
this? [The first frame code is posted below the class code]. When I have
created movieclips without actionscript, then attached AS 2 classes to them I
can manipulate them. If there is not a way that I can manipulate AS-generated
clips on the main timeline, is this doable from within the class?

Thanks for your time.



//*** CLASS CODE ***

class BoxyRounded extends MovieClip {
var iN:String;
var d:Number;
var lst:Number;
var lsc:String;
var lsa:Number;
var x0:Number;
var y0:Number;
var fcc:String;
var fca:Number;
var w:Number;
var h:Number;
var cs:Number;
public function BoxyRounded(iN, d, lst, lsc, lsa, x0, y0, fcc, fca, w, h, cs)
{
_root.createEmptyMovieClip(iN, d);
with (iN) {
lineStyle(lst, lsc, lsa);
moveTo(x0+cs, y0);
beginFill(fcc, fca);
lineTo(x0+w-cs, y0);
curveTo(x0+w, y0, x0+w, y0+cs);
lineTo(x0+w, y0+h-cs);
curveTo(x0+w, y0+h, x0+w-cs, y0+h);
lineTo(x0+cs, y0+h);
curveTo(x0, y0+h, x0, y0+h-cs);
lineTo(x0, y0+cs);
curveTo(x0, y0, x0+cs, y0);
endFill();
}
}
}


//*** FIRST FRAME CODE ***

stop();
import BoxyRounded;
//function BoxyRounded(iN, d, lst, lsc, lsa, x0, y0, fcc, fca, w, h, cs)
var box3:BoxyRounded = new BoxyRounded("box3", _root.getNextHighestDepth()+1,
0, "0x00ff00", 0, 0, 0, "0x800000", 100, 50, 250, 100);
coldMiner
9/25/2006 12:37:18 AM
You should implement that in your class, example:

class BoxyRounded extends MovieClip {
var iN:String;
var d:Number;
var lst:Number;
var lsc:String;
var lsa:Number;
var x0:Number;
var y0:Number;
var fcc:String;
var fca:Number;
var w:Number;
var h:Number;
var cs:Number;
var boxMc:MovieClip;
public function BoxyRounded(iN, d, lst, lsc, lsa, x0, y0, fcc, fca, w, h, cs)
{
boxMc=_root.createEmptyMovieClip(iN, d);
with (iN) {
lineStyle(lst, lsc, lsa);
moveTo(x0+cs, y0);
beginFill(fcc, fca);
lineTo(x0+w-cs, y0);
curveTo(x0+w, y0, x0+w, y0+cs);
lineTo(x0+w, y0+h-cs);
curveTo(x0+w, y0+h, x0+w-cs, y0+h);
lineTo(x0+cs, y0+h);
curveTo(x0, y0+h, x0, y0+h-cs);
lineTo(x0, y0+cs);
curveTo(x0, y0, x0+cs, y0);
endFill();
}
}
public function boxChangeAlpha(s:Number){
boxMc._alpha = s;
}
public function boxMove(xx:Number, yy:Number){
boxMc._x = xx;
boxMc._y = yy;
}
}
/// frame code:
stop();
import BoxyRounded;
var box3:BoxyRounded = new BoxyRounded("box3", _root.getNextHighestDepth()+1,
0, "0x00ff00", 0, 0, 0, "0x800000", 100, 50, 250, 100);
box3.boxChangeAlpha(20);
Generic Nickname
9/25/2006 2:19:10 AM
coldMiner
9/25/2006 2:42:53 AM
uh... sorry.... did not tested it...
You have to change the line:

with (iN)

to:

AddThis Social Bookmark Button