Robotlegs basics on an Away3D project

darcey.lloyd's Avatar

darcey.lloyd

18 Oct, 2010 11:57 AM

Hi,

I am working on creating an Away3D scene with many items in it, carousel, sphere's, videos, swf overlays, swf underlays etc.

I am choosing robotlegs as my first framework, I understand the basics of mvc and am now trying to work out best structure and process to follow, so far I have this:

Folder structure:

events (events)
models (models + global variables for quick app config)
views (views)
controls (commands)
services (data services)
applicationContext.as (robot legs setup)
applicationBaseClass.as (base class)

All the examples I have run through have each view as a visible element on the page at start, my questions are:

Q1. If views are visible components at application startup where would I setup the Away3D view,scene,camera? Would this equate to Away3DView.as?

Q2. If each element in the 3D application has a unique and complex set of functionality, where and what would these 3D elements be classed as? Views?

Q3. I require to have multiple handlers for rendering via the on enter frame on the creation of the Away3D scene, where would this be done? I'm guessing not in the view. (as I said very new to this)

Q4. I require some, if not all 3D elements and the Away3D view and camera to be controlled/managed from somewhere as I need to manipulate them. Where is the best place to put this logic?

Q5. Once the Away3D view, scene and camera have been setup/init (I'm assuming this is a view component), where should I put the logic to start instantiating 3D elements in the scene at timed intervals?

Q6. Where would be the best place to patch in bulkloader with a visual preloader? I understand that an event can be fired into the framework on loading complete for other view components to become visible, but where would I init this code?

I understand there are some pretty basic things I am probably not understanding here and don't even know about.

I am trying to understand and obtain a good method of folderised separation of elements, structure and how to control them before I dive in and create something which works but is wrong on the framework.

Any information / help would be much appreciated.

Thanks

Darcey

  1. 2 Posted by Stray on 18 Oct, 2010 02:38 PM

    Stray's Avatar

    Hi Darcey, I'm afraid I've zero experience of Away3D so I can only give limited help, but I've answered what I can, and hopefully someone else will have more advice.

    > Folder structure:
    > events (events)
    > models (models + global variables for quick app config)
    > views (views)
    > controls (commands)
    > services (data services)
    > applicationContext.as (robot legs setup)
    > applicationBaseClass.as (base class)
    >

    All good, if by 'global variables' I can assume you mean a parameter object (or many of these) which are mapped as a singleton using injector.mapSingleton or injector.mapValue depending on whether it's immutable or has setters for the properties?

    > Q1. If views are visible components at application startup where would I setup the Away3D view,scene,camera? Would this equate to Away3DView.as?
    >

    Views can be added at runtime - most of mine are, as data arrives. But yes - Away3DView does sound like a class you'll need.

    > Q2. If each element in the 3D application has a unique and complex set of functionality, where and what would these 3D elements be classed as? Views?
    >
    er... depends what the functionality is. If you can see it, then it's view :)

    > Q3. I require to have multiple handlers for rendering via the on enter frame on the creation of the Away3D scene, where would this be done? I'm guessing not in the view. (as I said very new to this)

    A service dedicated to managing your onEnterFrame is one option. Another is AS3 signals. Robert Penner has done some interesting work on this specific issue (centralised enter frame dispatching) - go check out his blog.

    >
    > Q4. I require some, if not all 3D elements and the Away3D view and camera to be controlled/managed from somewhere as I need to manipulate them. Where is the best place to put this logic?

    Logic should always be in commands, models and services. Never in mediators. Mostly it's in commands if it requires the participation of more than one class.
    >
    > Q5. Once the Away3D view, scene and camera have been setup/init (I'm assuming this is a view component), where should I put the logic to start instantiating 3D elements in the scene at timed intervals?

    A timed event should come from a service. The view mediator will listen for the events, and then act on the view API to ask the view to instantiate 3D elements.

    >
    > Q6. Where would be the best place to patch in bulkloader with a visual preloader? I understand that an event can be fired into the framework on loading complete for other view components to become visible, but where would I init this code?
    >

    Probably in a command. Mostly people use a BootstrapCommand wired to ContextEvent.STARTUP_COMPLETE for preloading etc.

    It sounds like you're heading / thinking in the right direction. The biggest danger you face is winding up with lots of heavy code in your mediators. Steer clear of this and you'll be ok!

    Come back with more specific questions as you hit them, and hopefully someone with more Away3D knowledge than me will add to the sparse advice I've been able to give you here.

    Good luck!

    Stray

  2. 3 Posted by darcey.lloyd on 18 Oct, 2010 03:07 PM

    darcey.lloyd's Avatar

    Nice good info :) Thanks Stray..

    In response to your answers.

    [1]. The Global variables I mentioned would be something like a collection of public static vars for basic application config, should I be using something within robotlegs for this?

    [2]. Away3D is same as the rest at the end of the day. The functionality ranges from the basics of just moving around a simple 3D object to the latter where a 3D Object contains a gallery or timeline based application. Some will have a sub application within, some will overlay a preloaded swf or swf on demand via bulkloader. (this sub functionality I will keep out of robotlegs - well, at least for now).

    My current setup would be to have a class for the view and then another class which manages all this functionality, this controlling (control?) class would need to have access to nearly all views (if 3D objects inside the Away3D scene are views it would need reference to these too).

    [3]. I have been reading some info on the signals already. You mention a service, my understanding of services so far, well what I thought is to only process Input/Ouput events, data loading etc in them?
    I simply need to set a boolean to true/false for the enterframe 3D rendering to switch to different logic. I now assume the enter frame logic is programmed as a command. (as per your Q4 answer)

    [4]. Commands it is then as I require access to data from multiple classes and to manipulate many 3D items (which I'm now assuming views) at any one time.

    [5]. Perfect thank you :)

    [6]. This would partially tie in with Q1 then, as there may or may not be a graphical preloader using embedded assets, I think I'm answering some of my own questions typing this lol.... So I would simply listen for STARTUP_COMPLETE, fire off a command class on complete (BulkLoadAssets.as in Commands folder?). Is it wise to use a Command as a singleton for asset reference? Or is this where this question ties in with point no 1, does robotlegs have something to register/store variables?

    Thank you for your assistance, very valuable.

    Darcey

  3. 4 Posted by Stray on 18 Oct, 2010 03:28 PM

    Stray's Avatar

    >
    > 1. The Global variables I mentioned would be something like a collection of public static vars for basic application config, should I be using something within robotlegs for this?
    >

    I'd advise using a strong typed immutable VO to contain these rather than statics. One of the nice things about DI is that you can have far fewer statics. So - unless they really are static (Math.PI is pretty static I'd say) then it can be useful to treat them as values. Nothing will explode if you do use statics though, but it's a really good example of how DI is different, so I'd encourage you to use it just to help learn the ropes.

    > 2. Away3D is same as the rest at the end of the day. The functionality ranges from the basics of just moving around a simple 3D object to the latter where a 3D Object contains a gallery or timeline based application. Some will have a sub application within, some will overlay a preloaded swf or swf on demand via bulkloader. (this sub functionality I will keep out of robotlegs - well, at least for now).
    >
    > My current setup would be to have a class for the view and then another class which manages all this functionality, this controlling (control?) class would need to have access to nearly all views (if 3D objects inside the Away3D scene are views it would need reference to these too).

    Controllers = ick. Generally (always an exception). If you can put this logic into individual commands, do. Look at using Signals in and out of the mediators for those views, and the SignalCommandMap, to bite each piece of functionality into a Command rather than a big ugly controller object. Refactor out repeated logic to helper objects.

    >
    > 3. I have been reading some info on the signals already.
    > You mention a service, my understanding of services so far, well what I thought is to only process Input/Ouput events, data loading etc in them?
    > I simply need to set a boolean to true/false for the enterframe 3D rendering to switch to different logic. I now assume the enter frame logic is programmed as a command. (as per your Q4 answer)

    Great (reading signals already). I separate services/models on the basis of whether they fire events in their own sweet time, or only synchronous with an action on their API. A model is synchronous: I call a method, and during executing that method the model might fire an event. A service is asynchronous - you call a method, and sometime in the future you might get an event, and it might be one event or it might be at intervals.

    If your enterframe is happening on another object then yes, you'd just switch that on/off in a Command. But... generally Commands don't have access to mediators... so you might still prefer to segment this off in a Service.

    >
    > 4. Commands it is then as I require access to data from multiple classes and to manipulate many 3D items (which I'm now assuming views) at any one time.
    >
    Great - but accessing views directly from Commands isn't conventional. I can see the need for it here so you might need a model to represent (map) your view classes to get access to them.

    > 5. Perfect thank you :)
    >
    :)

    > 6. This would partially tie in with Q1 then, as there may or may not be a graphical preloader using embedded assets, I think I'm answering some of my own questions typing this lol....
    > So I would simply listen for STARTUP_COMPLETE, fire off a command class on complete (BulkLoadAssets.as in Commands folder?). Is it wise to use a Command as a singleton for asset reference? Or is this where this question ties in with point no 1, does robotlegs have something to register/store variables?
    >
    >
    State (stored vars) = Model. Commands are short-lived and die (are garbaged collected) so they can't hold state. Usually you'd have your service (that loads the assets) either create or populate a model or vo, mapped as a singleton or value.

    Think of the whole of the DI deal as being somewhere to generally organise and get access to stuff. It's like a really awesome filing system for your objects - a spotlight search that actually works! So, the norm is just to map what you need access to, and then inject it where you need access.

    Of course it's not quite as simple as that - there are rules like not injecting into your views and not injecting your services/models into your mediators, and models only sending, not listening for, events - but you'll pick that stuff up as you go.

    >
    > Thank you for your assistance, very valuable.

    :)

    Stray

  4. 5 Posted by darcey.lloyd on 19 Oct, 2010 08:46 PM

    darcey.lloyd's Avatar

    Just an FYI, this is what I am trying to convert to use the Robotlegs framework.

    http://www.allforthecode.co.uk/

    I will follow two paths on this build till I get the robotlegs version running.

    Thanks again for all your info, lots of test appz in progress from your info to get me going. ;)

    Darcey

  5. Stray closed this discussion on 13 Feb, 2011 03:02 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac