-
where is my mind
Hi there,
is it possible to swap movieclips throug actionscripting, eg: when you click a button the button switches into a movieclip. This is NOT the effect I need, it's just an example.
greetings, robin
-
there is no need to do what you say, just make everything movieclips, and your set
-
where is my mind
there is need
I'm not telling you you're wrong, but I need this
greetings
Robin
-
no logically it is impossible to ever need that ability, because everything a button does a movie can also do, my suggestion is to select your button, and on the property inspector change it to a movie clip,
-
where is my mind
now I see
I explained it not right
What I want is that through a variable on a button, the movieclip on the stage changes into another movieclip, like the 'swap' button in your instance palet
robin
-
you need to give all your movie clips that the movie might swap out with a linkage name, right click the movieclip in the library and choose linkage, give a name and then add the following code to the first frame of your movie
Code:
MovieClip.prototype.swap = function(linkage, instanceName){
var insNam = (instanceName == undefined) ? linkage : this._name;
this._parent.attachMovie(linkage, insNam, this.getDepth());
}
now all of your movieClips have a new method "swap" call it like this
Code:
Movieclip.swap(linkageName);
so...
swaps the movie clip names "bob" with a movie clip in the library with a linkage name of "test"
hope this helps
-
where is my mind
extra detail
Hi there,
you've given me
bob.swap("test");
which works, and is quite a help. Thanx, but I need to fix one more thing, and I haven't got a clue on how to start.
Now, I can only change from one to another, but what I need to do is that no matter which movieclip is put in there, it changes to the one I want.
You see? I don't want to give in "bob", but something like an instance name that is equal for all the movieclips, because if I'm not mistaking, flash doesn't remember the instancename after the first swap, or does it?
greetings...
Robin
-
because of the way I set this up for you if you called
bob.swap("test");
it swaps out bob with the linked movieclip called "test" and yes it does remember the movies name bob stays bob
you can then call
bob.swap("anotherLinkedMovie");
and it will work fine, if you want to change the name of bob after it swaps then call
bob.swap("linkedMovie", "newName");
as for all that other stuff your were talking about, please explain yourself better
-
(instanceName == undefined) ? linkage : this._name
care to expain that little if then statement for those who don't understand
-
what that line of code does is make the instance name argument to the method not required,
if you call
bob.swap("mc", "henry");
it swaps with links movie "mc" and renames the instance "henry"
bob.swap("mc");
simply swaps with links movie "mc" but keeps the same name it had before. I do this using the code
var insNam = (instanceName == undefined) ? this._name: instanceName;
this._parent.attachMovie(linkage, insNam, this.getDepth());
if you don't give it an instance name "instanceName" is "undefined" so the first line of code is an if statement
(instanceName == undefined)
if it is true meaning the method was called with our "instanceame" argument, then variable insNam is set eq to the linkage name, otherwise it get the name you specify,
CRAP I now see a problem, I wrote it to fast and made a simple mistake, any way here is the real method
Code:
MovieClip.prototype.swap = function(linkage, instanceName){
var insNam = (instanceName == undefined) ? this._name : instanceName;
this._parent.attachMovie(linkage, insNam, this.getDepth());
}
the code above will get the naming right sorry about that linckx
-
where is my mind
positioning
here i am again...
everything works fine, except that he puts the swapped cast member in the upper left corner. How can I change that?
don't bother about the little error, I bet you a thousand dollars I make more mistakes than you did today in the next ten minutes
grtz
robin
-
what do you mean "he puts the swapped cast member in the upper left corner. How can I change that?" who is "he" why top left?
if you want to move a movie clip around just change it's x and y position like this
movie._x = 100;
movie._y = 350;
-
That how can I do if that is a MC,not a linkage?
e.g.
_root.a.b.c.d.e
swap with
_root.skin.sk1.e
Red -- one of the psychological primary hues.
-
that's a nice swap proto but is there any way to drill down through the original mc's properties and get the swapped one to inherit them?, because i can do it by individually swapping values but there must be an easier way of swapping properties?
~bugged
imageWeaver gallery
microsite direct download
"Have you ever noticed? Anybody going slower than you is an idiot, and anyone going faster than you is a maniac."
-
ok i've managed to pull together this but it's not ideal.. you call it same as b4
Object.prototype.copyProperties = function(toObj, propertyStr, exclude) {
if (this instanceof Array) {
for (var i = 0; i<this.length; i++) {
if (typeof (this[i]) == "object") {
toObj[i] = this[i] instanceof Array ? new Array() : new Object();
this[i].copyProperties(toObj[i], propertyStr, exclude);
} else {
toObj[i] = this[i];
}
}
} else {
for (var i in this) {
var index = propertyStr.indexOf("#"+i+"#");
if ((exclude && index == -1) || (!exclude && index != -1)) {
if (typeof (this[i]) == "object") {
toObj[i] = this[i] instanceof Array ? [] : {};
this[i].copyProperties(toObj[i], propertyStr, exclude);
} else {
toObj[i] = this[i];
}
}
}
}
}
ASSetPropFlags(Object.prototype, ["copyProperties"], 1);
MovieClip.prototype.swap = function(linkage, instanceName) {
var insNam = (instanceName == undefined) ? this._name : instanceName;
var tempObj = new Object();
this.x = this._x;
this.y = this._y;
this.xs = this._xscale;
this.ys = this._yscale;
this.r = this._rotation;
this.a = this._alpha;
this.v = this._visible;
this.copyProperties(tempObj, "#x#y#xs#ys#");
tempObj._x = tempObj.x;
tempObj._y = tempObj.y;
tempObj._xscale = tempObj.xs;
tempObj._yscale = tempObj.ys;
tempObj._rotation = tempObj.r;
tempObj. _alpha = tempObj.a;
tempObj. _visible = tempObj.v; this._parent.attachMovie(linkage, insNam, this.getDepth(), tempObj);
};
~bugged
imageWeaver gallery
microsite direct download
"Have you ever noticed? Anybody going slower than you is an idiot, and anyone going faster than you is a maniac."
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|