views:

51

answers:

2

Hi,

I hope I can explain this properly. I'm using flashDevelop for an avatar creation engine. I have a movieclip(class) called body_view which is structures like this :

body_view -> 10 visual body components -> each component needs to have a jpeg loaded

Then there is a body_model class which is extended from the body_view class and is responsible for all loads/saves/interactions now body_model class is as follows:

body_models -> variables holding (values) -> populateView (function)

Now through the populateView function I need to populate the components of body_view but the issue is if I load a jpeg/swf on a function it comes on stage. I do not want it on stage I want it in its perticular place in the body_view

I hope someone can help me out!

A: 

If I understand it right this is one of the ways I would perceive it :

  • The model is in charge of loading.
  • The view listens to the the model for completed loading requests.
  • For consistency both the view and the model share a same value object containing the list of body part IDs etc.
  • Once the view gets notified one of the awaited images is loaded it adds it to the appropriate body part.

So if you have something similar and the "body parts" are getting loaded on the stage instead of the desired location it's probably the populate() method being screwed up.

Theo.T
Basically I do not want to have anycode in the view, I want it strictly to be for design purpose. So when something gets loaded from outside, I just want it to be placed in the body_view perticular movieclip.
Fahim Akhter
+1  A: 

Since a Loader is a DisplayObject, you can add it (and thereby the image or swf it loads) to any DisplayObjectContainer, like a Sprite or MovieClip, using addChild(), schematically something in the lines of this:

var loader:Loader = new Loader();
loader.load(new URLRequest(urlToImage));
thePlaceWhereYouWantTheImage.addChild(loader);

Also, you can move a loader (or other DisplayObject) from one place to another by using addChild() again:

otherPlace.addChild(loader);

It will then be removed from its current position in the display list and added to the new.

Lars
Yeah Fahim, do what Lars suggests. Using URLLoader for a display-list item is probably not what you want to do.
alecmce
That's perfect Lars, thanks for the help :)
Fahim Akhter