Hi,
I would like a simple way of changing the gfx of a movieclip in the similar way that you do in director etc. sprite.member = member(“boat.gif”)
I’m not into that gotoandstop stuff. Doesn’t feel right, + makes the javascript code less reusable.
Hi,
I would like a simple way of changing the gfx of a movieclip in the similar way that you do in director etc. sprite.member = member(“boat.gif”)
I’m not into that gotoandstop stuff. Doesn’t feel right, + makes the javascript code less reusable.
I don’t think there is quite similar one in Flash… That’d be real good if it can be done like that…
You can create an empty movieclip that holds content movieclip and change it to another movieclip with, say, attachMovie() function to the empty movieclip to do it???
Ok, just replace the current graphic in the movie clip with a new one using the attachmovie. As long as it keeps the current properties of the prev movie clip I guess it could be done that way.
Quite annoying though having to manage the z-pos when I just wanna swap the graphic…
How are people dealing with this!? I really not prefer to use the timeline.
I dont understand what you mean here… managing zpos? You wouldnt have to manage any of that with a ‘swap’ with attachMovie. The only zpos youd be doing would be the depth argument - something which would be the same for each attachMovie since you are attaching to replace.
To retain the properties of the previous, you would use a container clip (as CyanBlue mentioned) for those properties and just attach the clips within that.
The gotoAndStop stuff is a common way of handling this - and the big advantage that Flash has over Director - that kind of encapsulation and embedded timelines. Of course Flash doesnt do everything Director does, but there are usually ways of handling the same desired outcome, as in, with this case, the attachMovie command to handle a type of sprite member swap.
Hello and thanks for the tips!
I just wanted to make sure there wasn’t any hidden trick for doing such stuff.
managing zpos, oh, was just thinking of a new attach would require new ids and zpos etc.
But create an empty clip,
create a dummy container runtime,
and attach the gfx to the dummy will be the way to go.
So a simple spriteManager to wrap such functionality together will be ok.
Still, it’s so so weird that long process of “tagging up” internal library gfx for use with actionscript…
I mean, loadMovie to an external jpg does this the way you want it! but thats just for external stuff…
yeah, MX made the linkage setting for movieclips (used in attaching movieclips) a little easier by adding the ability in the
symbol creation dialog and letting it copy the library item name as the linkage ID, but I think its just a result of how Flash internally
handles the library items - how each is not (for whatever reason) available to access through actionscript without that explicit
declaration.
so in doing something like that, first create the ‘container’ which if not done manually in the authoring environ, can be created with
createEmptyMovieClip, then attach each movieclip with the desired image into that empty clip using the same depth for each
(you dont even really have to worry about the name). Using the same depth will cause the new one to replace the previous.
When you apply transformations or movement to the clip, you’d be using the empty clip as it represents the actual ‘sprite’ where
as the attached clip is the ‘member.’ Using some MX techniques, you can have it act like Director a bit
this.createEmptyMovieClip("sprite1", 1).addProperty("member",function(){ return this.$member;},function(m){this.$member = m;if (m == null){ this.member_mc.removeMovieClip(); }else{ this.attachMovie(m, "member_mc",1); }});
Then all youd do is use something like
sprite1.member = “myLinkageID”;
and that movieclip (sprite1 as I named it) will have attached to it the movieclip in the library with the linkage ID of “myLinkageID”.
setting the member to null will clear it.
:: Copyright KIRUPA 2024 //--