Duplicating or moving a MC to a different level in hierarchy

  • yossarian
  • Newbie
  • Newbie
  • yossarian
  • Posts: 8

Post 3+ Months Ago

That's a mouthful for a subject, but it's fairly descriptive.

The one sentence summary of what's confounding me is that I want to be able to move a MovieClip from one parent clip to another and I can't figure out how.

There's a similar one sentence video of what's got me stuck on Vimeo here: ( http://www.vimeo.com/3828949 - it's being processed, will be up in a half hour or so).

Here's an image of what I'm trying to do

The slightly longer / wordy version is below.


I'm using Flash 8 (CS2).

In the past, I screwed up one of our games by not loading the dozens of external .swf files in a managed manner. This meant that the game was at mercy of loads completing in time (the shame, the shame!).

To amend this for the current game (a game very close in play experience to Phoenix Wright), I'm loading all 1.6 megabytes of assets up front.


My movie structure is this:

_root -> canvas

Canvas is an MC that is the full size of the root.

canvas -> asset_container

The asset_container is an empty MC that is created at runtime and used to place assets as they are loaded.

I then pass an array of filenames (different filenames per game mission) to an AssetLibrary class that I've written.
This class creates a new MC for each asset required inside the asset_container.

So, for example, I pass an array like this

["ePhone.swf", "hughs_plate.swf", "punch.swf", "punch_mv.swf", "salad_bowl.swf", "salad_bowl_mv.swf"]

And I end up with this

_root -> canvas -> asset_container -> ePhone
_root -> canvas -> asset_container -> hughs_plate
_root -> canvas -> asset_container -> punch
_root -> canvas -> asset_container -> punch_mv
_root -> canvas -> asset_container -> salad_bowl
_root -> canvas -> asset_container -> salad_bowl_mv

etcetera (there are about 60 things in total).

Ok, so so far so good. They all load in a nice controlled fashion.
Once loaded, I can get the handle to any of them by calling


So, it's easy enough to grab any clip that I want and display, fade in / out, animate individual clips etc.

So what's the problem?

The ePhone MC is one of the assets loaded in this manner.
It provides a mobile phone style interface for the game.
It has a number of screens inside it that can fade in and out.
A few of these screens show evidence items that the player has collected.
The same item of evidence can appear on more than one screen. Therefore, it makes sense to load an evidence asset once and just duplicate it as required.

The way the ePhone is built is like this:

ePhone -> screenX -> buttonX -> content

the plan was to replace the 'content' clip with art representing the item the player had found. The functionality hangs on each Button so I can swap out what fills the content MC without removing any functionality.

To facilitate this, I thought I could do something like:

var foodPlate : MovieClip = assetLibrary.getAsset("hughs_plate");
var tempMC : MovieClip = foodPlate.duplicateMovieClip("tempMC", ePhone.screenX.buttonX.getNextHighestDepth());
ePhone.screenX.buttonX.content = tempMC;

In other words, I thought I could duplicate a MC that is at this level:


and the replace the item at this level:


with the duplicate.

However, this doesn't work and is clearly a butchering of the way Flash works.
I know how to loadMovie or attachMovie a clip into


but of course loadMovie requires another load off disk and attachMovie requires assets to live in the Library, not on the stage.
I want to load everything up front and then manipulate assets as required.

Potential Solutions?

I'm not sure if there are any. I may have to load the items straight into one ePhone Screen at load time and then just set visible to false on all the ones I don't use. I'm not really sure, it seems like a crappy way to do this. The problem is that I may end up having 3 evidence screens... or 4... or whatever... it would be much nicer to just duplicate the screen inside the phone and then as and when required, I would just replace the contents of the button with whatever item had been found and then trigger visible.

Ideally, I'd be able to duplicate a clip from one level in the hierarchy straight into another clip (replacing that clip's contents as would happen with a loadMovie).
Alternatively, I'd be able to force one clip to change it's place in the hierarchy. Less pretty but could amount to the same thing (i.e. duplicate, then force down a few levels, then remove the 'content' clip and sit the new clip where it was).

Any ideas?

Post Information

  • Total Posts in this topic: 1 post
  • Users browsing this forum: No registered users and 6 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum

© 1998-2017. Ozzu® is a registered trademark of Unmelted, LLC.