There seems to be difficulties cropping clips with clips created in ActionScript.
like createEmptyMovieClip, duplicateMovieClip, setMask()
Can you find a solution for this ?
There seems to be difficulties cropping clips with clips created in ActionScript.
like createEmptyMovieClip, duplicateMovieClip, setMask()
Can you find a solution for this ?
What difficulty are you having?
Well, I can’t find a way to mask a movieclip with another created with pure ActionScript.
The only way is to use mc created in Flash design which is not a solution.
Do you think I can crop a clip in other way using only ActionScript ?
Tnx.
Well you can only use 1 mask per movie clip, maybe that is the problem?
Also, if you are just using createEmptyMovieClip, what are you masking? Are you duplicated a clip from the library? Or a clip on the stage? Or are you using the Drawing API?
All I do is ActionScript, not Flash Design
So
Normally, the 1st movieclip should crop all children to it’s original dimensions. This is not the case in MX, at least text box doens’t conform to this.
So what I have to do is to crop this notty children and I’m thinking to duplicate the 1st mc and use it as a mask for the children.
If I use a Flash Design mc, it works, but I have to use an ActionScript mc, since I don’t know what the original mc will be like (box, filled circle, star, etc.)
Well yeah, but I don’t understand how you can mask an empty movie clip.
It is empty. There is nothing to mask, or to have mask it.
Can you show me the script you are using?
It is not empty. I populate it with ActionScript figures. Why do ya think I need to crop an empty clip ?
Source code
MaskedClip = function (name, x, y) {
_root.createEmptyMovieClip(name, 2);
obj = eval("_root."+name);
mainclip.duplicateMovieClip(“clipper”, 5);
// clipper._x=mainclip._x+50;
mainclip.setMask(box);
trace(clipper._alpha);
setProperty(box, _x, 100);
setProperty(clipper, _height, 500);
// clipper._width=500;
// trace(clipper._width);
setProperty(name, _x, x);
setProperty(name, _y, y);
// setProperty(mainclip, _width, 300); // strange behavior
with (obj) {
beginFill(0xAAAAAA, 50);
lineStyle(1, 0xFFFFFF, 100);
lineTo(300, 0);
lineTo(300, 100);
lineTo(0, 100);
lineTo(0, 0);
endFill();
}
obj.createEmptyMovieClip(“childbox”, 1);
with (eval(obj.childbox)) {
beginFill(0xFFAA00, 50);
lineStyle(1, 0xFFFFFF, 100);
moveTo(200, 50);
lineTo(400, 50);
lineTo(400, 150);
lineTo(200, 150);
lineTo(200, 50);
endFill();
}
};
box1 = new MaskedClip(“mainclip”, 100, 200);
I don’t think this is a workable script anymore but it’s enough to get an idea.
Did you write this code yourself?
This looks like you were attempting Object Oriented Programming, but at the same time, it doesn’t. Like you use obj and new Object, but I don’t see any constructor prototypes.
I don’t know much OOP though, I am extremely novice in it.
One thing I noticed in your script though is that you use the setMask to mask an object called “box” (no quotes), but throughout the script, you create no object called “box”.
Alright, well it is 4:30am here. I have to get to bed now.
I will work more on this tomorrow if I can.
But so far to me… it looks like your code is all sorts of screwey, but what do I know :q:
OOP in ActionScript is a little bit differend than in C++ or st. like that.
box is an Flash Design mc This one works as a mask, but the clipper won’t
Quotes or no quotes, there’s no problem with my code I assure you. It should work.
The code is messy after many attempts to debug and test some theories.
Just try to mask an AS mc with another AS mc (no Flash Design in it).
Tnx 4 trying.
Yeah, OOP is probably a tad bit different in AS. I tried studying OOP, but it gave me a headache, so I considered myself unprepared for it at the moment. I know the basics of it though.
Also, on another note, some of the code in your file is… outdated.
setProperty is way old. Lines like setProperty(box, _x, 100) and setProperty(clipper, _height, 500) can be changed into box._x = 100 and clipper._height = 500.
Well, the reason I used setProperty is cuz you can’t just use
a= function(name) {
createEmptyMovieClip(name, 15);
name._x=10 // this won’t work
}
name being a string like a(“my_mc”);
You have to either use
obj=eval(name);
obj._x=10;
or simply
setProperty(name, _x);
I assure you setProperty is not at all obsolete, it is used in Flash ActionScript Help (ActionScript Dictionary…)
But pls, just help me if u can with that masking
Well you could use something like _root[name] I believe.
And I will see what I can do about that masking.
How about something like this?
MovieClip.prototype.buildSquare = function(fillColor, fillAlpha, lineThickness, lineColor, lineAlpha, x, y, xscale, yscale) {
this.beginFill(fillColor, fillAlpha);
this.moveTo(-50, -50);
this.lineStyle(lineThickness, lineColor, lineAlpha);
this.lineTo(-50, 50);
this.lineTo(50, 50);
this.lineTo(50, -50);
this.lineTo(-50, -50);
this.endFill();
this._x = x;
this._y = y;
this._xscale = xscale;
this._yscale = yscale;
};
_root.createEmptyMovieClip("box1", 1);
_root.box1.buildSquare(0xE6E6E6, 100, 1, 0x000000, 100, 100, 200, null, null);
_root.createEmptyMovieClip("box2", 2);
_root.box2.buildSquare(0xFF9900, 100, 1, 0x000000, 100, 150, 250, null, null);
//_root.box1.setMask(_root.box2);
Great!
The key was using “this”. And I solved my problems with the children including textfields.
Thank you very much! :hat:
No problem man. I am glad you got everything working
:: Copyright KIRUPA 2024 //--