Futurescale, Inc.
PureMVC Home
The PureMVC Framework
Code at the Speed of Thought
Over 10 years of community discussion and knowledge are maintained here as a read-only archive.
New discussions should be taken up in issues on the appropriate projects at
https://github.com/PureMVC
PureMVC Architects Lounge
Announcements and General Discussion
General Discussion
Call a Command Every Frame
Pages: [
1
]
« previous
next »
Author
Topic: Call a Command Every Frame (Read 12564 times)
danmvc
Jr. Member
Posts: 13
Call a Command Every Frame
«
on:
July 13, 2009, 12:57:25 »
Is it ok to call a command every frame? I'm just wondering since the command object is created every time it is called, won't this be a memory problem?
Logged
puremvc
Global Moderator
Hero Member
Posts: 2871
Re: Call a Command Every Frame
«
Reply #1 on:
July 13, 2009, 01:40:41 »
Depends on what you want to do. If it's calling a proxy method, you might want a long-lived mediator to handle this.
-=Cliff>
Logged
danmvc
Jr. Member
Posts: 13
Re: Call a Command Every Frame
«
Reply #2 on:
July 14, 2009, 01:20:32 »
Well I was just messing around with having a box that the user could scale. The proxy holds the data of the width and height of the box. On mouse move, the mouse position is sent to the command, the command figures out what the new size of the box should be, updates the proxy, and tells the mediator how to visually represent the new box size.
The mediator I'm using is 'long-lived,' in that it is my main module mediator. I'm just not sure what's going on under the hood when I send a notification every frame that is mapped to a command. Is the command actually created on every call?
Logged
Tekool
Sr. Member
Posts: 192
Re: Call a Command Every Frame
«
Reply #3 on:
July 14, 2009, 02:38:00 »
Here I think that all this work would better have to be done by only one mediator. You don't need a proxy to store the mouse position data, it's only a view concern, except if your mouse position is sent on a network for a multiplayer game or something else. And even in this case, you'll have the mouse position first "stored" by a mediator.
Try not to use the main mediator for this, create a BoxMediator or something specific. And then you're mediator can subscribe to the ENTER_FRAME event of the box Sprite/MovieClip. I don't think that you need a command for that, but as Cliff previously said, it all depends on your needs.
«
Last Edit: July 14, 2009, 02:40:14 by Tek
»
Logged
danmvc
Jr. Member
Posts: 13
Re: Call a Command Every Frame
«
Reply #4 on:
July 15, 2009, 12:39:55 »
I was thinking just a mediator would be fine, but I was trying to use the MVC framework pretty much just to learn the thing. But my concern then was that there would be logic inside the mediator, I didn't think this was proper. For instance, assume that the box has properties like minimum width or a maximum boundary. During the resize, I would need to perform logic that constrains the resizing to these areas. I would think that that type of logic would traditionally be inside a controller object.
I guess it would be fine if the mediator can communicate directly with the proxy, to reference it's minimum maximum properties, is this proper?
Logged
puremvc
Global Moderator
Hero Member
Posts: 2871
Re: Call a Command Every Frame
«
Reply #5 on:
July 15, 2009, 01:57:52 »
Have a look at the HelloFlash demo. I think you'll find some useful ideas there.
http://trac.puremvc.org/Demo_AS3_Flash_HelloFlash
-=Cliff>
Logged
Pages: [
1
]
« previous
next »
Stack Overflow
GitHub
Linked In
Google Plus
Twitter
Powered by SMF 2.0.15
|
SMF © 2006-2007, Simple Machines LLC
|
Content © 2006-2018, Futurescale, Inc.
Loading...