开发者

Flash: Transferring loaded object from one class to another

开发者 https://www.devze.com 2022-12-21 21:57 出处:网络
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 :

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 开发者_如何学Pythona 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!


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消