tag:robotlegs.tenderapp.com,2009-10-18:/discussions/questions/592-changing-views-resize-signal-and-performanceRobotlegs: Discussion 2018-10-18T16:35:28Ztag:robotlegs.tenderapp.com,2009-10-18:Comment/80999582011-06-22T09:02:58Z2011-06-22T09:03:00ZChanging views, resize signal, and performance<div><p>Re performance question. That is regarding automatic mediation.
Ie, if you wanted all your sprite to be magically mediated and de
mediated when added / removed from view. But you wouldn't do that,
would you :)</p></div>neilmanuelltag:robotlegs.tenderapp.com,2009-10-18:Comment/80999582011-06-23T08:30:24Z2011-06-23T09:16:34ZChanging views, resize signal, and performance<div><p>I have another question.</p>
<p>Where do you put the sound? In views? I have a more general
soundlib class that handels most of the sound functions. Where to
put it? (I know that there is no right answer, but what would you
do?)</p>
<p>By the way, the other questions in my original post,
anybody?</p></div>Christentag:robotlegs.tenderapp.com,2009-10-18:Comment/80999582011-06-23T08:44:33Z2011-06-23T08:44:33ZChanging views, resize signal, and performance<div><p>1/ I'd use flex states to switch between views and since that's
pure view logic there's no need to involve any controller like
classes for that.<br>
Then, regarding having view2 setup fully before showing, you could
simply hide view2 as long as the data it needs is being retrieved
and then show it when all data is loaded.</p>
<p>2/ there's again no need to involve the framework for the resize
event, since all display objects can listen to the stage resize
event directly. That would only be necessary if some kind of
calculation needs to be made based on the stage dimensions AND that
result would be needed by various views.</p>
<p>3/ regarding sound: that's pure view logic as well</p></div>creynderstag:robotlegs.tenderapp.com,2009-10-18:Comment/80999582011-06-23T08:57:41Z2011-06-23T09:16:34ZChanging views, resize signal, and performance<div><p>1/ But what if I dont want the code to run before I want to use
the view?</p>
<p>2/ But if the view is not added (not using states) to stage yet
it can not listen to it, and I want to give the dimentions before I
add it so that it can setup before beeing shown to the users. I
also just wondered it I want to send a general signal out to all
views about resize, pause, updat, error, whatever. What would be a
good way of dooing it?</p>
<p>3/ Ok</p></div>Christentag:robotlegs.tenderapp.com,2009-10-18:Comment/80999582011-06-23T09:02:59Z2011-06-23T09:03:00ZChanging views, resize signal, and performance<div><p>Re sounds, I think it depends on the use of sound.</p>
<p>If its streaming, keep it external and have a model of urls.</p>
<p>Personally I would embed my sounds in a SoundLibrary class. And
again it depends on how they are used to how I would have them
accessed.</p>
<p>Sound is not always view, is the music of an mp3 player view? I
would say in that case it is part of what is being modeled.</p>
<p>I think that IS down to personal choice and the use case you
are.implementing.</p></div>neilmanuelltag:robotlegs.tenderapp.com,2009-10-18:Comment/80999582011-06-23T09:25:46Z2011-06-23T09:25:46ZChanging views, resize signal, and performance<div><p>Yes, I think sound can be a mix.<br>
I would guess that I have my sounds paths in a model, the files in
an external assets folder, and the calling of the sound in views,
but the handling of the sounds? Maybe in a controller (or view
helper file)?</p>
<p>In the sound handler I check if the sound is downloaded, if the
sound is muted. And play it if it is. Also if it is a looping sound
and it is set to play but is not downloade yet it will begin when
it is fully downloaded. This is the logic I don't know where to
put?</p></div>Christentag:robotlegs.tenderapp.com,2009-10-18:Comment/80999582011-06-23T10:07:19Z2011-06-23T10:07:19ZChanging views, resize signal, and performance<div><p>I gotta be honest, games is not my thing, so I don't feel I can
give you high performance related advice... so I'd best duck out
:)</p></div>neiltag:robotlegs.tenderapp.com,2009-10-18:Comment/80999582011-06-23T10:34:21Z2011-06-23T10:34:21ZChanging views, resize signal, and performance<div><p>Ok thanks.</p>
<p>How about changing views. I havent found any good exampels of
how to do it. It is two totaly different views. The normal exampels
I have seen ussualy is one "page", where elements come and go. But
I want to change the whole "page" whith another.</p>
<p>And is there a good way of sending an event or signal to all the
active views? All the views listen to some sigelton class maybe? Or
someway to make a contoller call all the views?</p></div>Christentag:robotlegs.tenderapp.com,2009-10-18:Comment/80999582011-06-23T13:49:33Z2011-06-23T13:49:33ZChanging views, resize signal, and performance<div><blockquote>
<p>1/ But what if I dont want the code to run before I want to use
the view?</p>
</blockquote>
<p>What code are you talking about? The code to retrieve the data
shown in the view?<br>
If that is the case you can let the mediator dispatch a
RetrieveSpecificDataSignal which is mapped to a command that
retrieves the data.</p>
<blockquote>
<p>2/ But if the view is not added (not using states) to stage yet
it can not listen to it, and I want to give the dimentions before I
add it so that it can setup before beeing shown to the users. I
also just wondered it I want to send a general signal out to all
views about resize, pause, updat, error, whatever. What would be a
good way of dooing it?</p>
</blockquote>
<p>The containing class can pass the dimensions to the view when
instantiating it.</p>
<p>Obviously if you have several views that need to listen to the
same signal, you can mediate all of them and let their mediators
pass the signal to them. I'm not saying you should never let views
communicate through the framework, I'm just pointing out that in
most cases it's unnecessary.</p>
<blockquote>
<p>How about changing views. I havent found any good exampels of
how to do it. It is two totaly different views. The normal exampels
I have seen ussualy is one "page", where elements come and go. But
I want to change the whole "page" whith another.</p>
</blockquote>
<p>As I said that's perfectly doable with flex states</p></div>creynderstag:robotlegs.tenderapp.com,2009-10-18:Comment/80999582011-06-23T14:22:46Z2011-06-23T14:22:46ZChanging views, resize signal, and performance<div><p>Say you have:<br>
view 1: this post we are looking at now<br>
View 2: the overview over all post in this forum</p>
<p>I want to change from view1 to view2. But before I show view2 to
the user I want it compleatly rendered. (so not like this webpage,
that renders when it changes.)</p>
<p>But I dont want to render all the pages on this site when a user
enters the site and save it to memory.</p>
<p>Use case:<br>
user push button in view1<br>
view2 starts rendering<br>
view2 complete rendering<br>
view 2 switches with view 1</p>
<p>(and by rendering Im simplifying, in flash I need to setup all
the graphic items from the data, start animation, eventlisteners,
sounds, and whatever the view needs to do to look nice. This can be
a lot of code to start running if the user chooses not to look at
view2.)</p></div>Christentag:robotlegs.tenderapp.com,2009-10-18:Comment/80999582011-06-23T14:39:40Z2011-06-23T14:39:40ZChanging views, resize signal, and performance<div><p>Either you mediate the containing view (the one that
instantiates view1 and view2) and dispatch a signal to "prepare"
all data needed by view2, or - I'd definitely choose this option -
when the user pushes the button in view1 you instantiate and hide
view2 and add it to the stage. Then when view2 completely has been
rendered show it.<br>
Is there a particular reason why you wouldn't want to do that?</p></div>creynderstag:robotlegs.tenderapp.com,2009-10-18:Comment/80999582011-06-24T06:57:50Z2011-06-24T06:57:50ZChanging views, resize signal, and performance<div><p>Yes I dont want it to be instansiated before I show it, so the
code dont start.</p>
<p>I properbly should say that view 1 has mediator 1 and view 2 has
mediator 2.</p></div>Christen