[flexcoders] Passing variables from .swf to .swf

2009-01-21 Thread Adrian Williams

Hi All,

   I've been researching this challenge and am not sure which of the 
methods I've found is the best...need some input on this one.


   I have a dashboard application (dashboard.swf) that uses multiple 
swfloaders to load the various widgets that the user needs (which are 
also .swf's).  The trick is that I need to pass a variable into the 
widgets to let them know which user logged in which allows the widget to 
load the data specific to that user. 

   I've seen a method that utilizes a localConnection to pass a 
connection string, a method and parameters...my concern is the local 
connection...there can be up to 20 widgets on a dashboard and opening an 
LC for each doesn't seem like it's be efficient...


   Help?!

Thanks,
Adrian


RE: [flexcoders] Passing variables from .swf to .swf

2009-01-21 Thread Tracy Spratt
How about just having a central data model?

 

Tracy Spratt 
Lariat Services 

Flex development bandwidth available 



From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On
Behalf Of Adrian Williams
Sent: Wednesday, January 21, 2009 11:53 AM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Passing variables from .swf to .swf

 

Hi All,

I've been researching this challenge and am not sure which of the
methods I've found is the best...need some input on this one.

I have a dashboard application (dashboard.swf) that uses multiple
swfloaders to load the various widgets that the user needs (which are
also .swf's).  The trick is that I need to pass a variable into the
widgets to let them know which user logged in which allows the widget to
load the data specific to that user.  

I've seen a method that utilizes a localConnection to pass a
connection string, a method and parameters...my concern is the local
connection...there can be up to 20 widgets on a dashboard and opening an
LC for each doesn't seem like it's be efficient...

Help?!

Thanks,
Adrian

 



Re: [flexcoders] Passing variables from .swf to .swf

2009-01-21 Thread Adrian Williams

Hi Tracy,

   We are already using a cental db here...we are running a pretty 
massive DB via SQL, use C#.Net for our control layer and use Flex/AS for 
our presentation, which calls for the data using a WSDL...the dashboard 
is for project managers...when they login to the dashboard, I need to be 
able to pass their loginId to the widgets so they can load the various 
data points for the project that person manages...i.e.  widget-A loads 
project statistics...and it needs to know which project's statistics to 
load...the only way it will know that is by having the userId that 
logged in.


   Or am I not understanding what you are referring to as a central 
data model?


Adrian

Tracy Spratt wrote:


How about just having a central data model?

 


Tracy Spratt
Lariat Services

Flex development bandwidth available



*From:* flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] 
*On Behalf Of *Adrian Williams

*Sent:* Wednesday, January 21, 2009 11:53 AM
*To:* flexcoders@yahoogroups.com
*Subject:* [flexcoders] Passing variables from .swf to .swf

 


Hi All,

I've been researching this challenge and am not sure which of the 
methods I've found is the best...need some input on this one.


I have a dashboard application (dashboard.swf) that uses multiple 
swfloaders to load the various widgets that the user needs (which are 
also .swf's).  The trick is that I need to pass a variable into the 
widgets to let them know which user logged in which allows the widget 
to load the data specific to that user. 

I've seen a method that utilizes a localConnection to pass a 
connection string, a method and parameters...my concern is the local 
connection...there can be up to 20 widgets on a dashboard and opening 
an LC for each doesn't seem like it's be efficient...


Help?!

Thanks,
Adrian

 


RE: [flexcoders] Passing variables from .swf to .swf

2009-01-21 Thread Tracy Spratt
I mean a data model in the flex app itself.  I like the singleton
pattern myself.

 

Also remember, content loaded in a SWFloader can communicate directly
with main app data via the dom (Application.applicatin,
parentApplication).  And the main app can access public members of
loaded content via the content property.  There are coupling theory
issues with these approaches if that is a concern to you.

 

Tracy Spratt 
Lariat Services 

Flex development bandwidth available 



From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On
Behalf Of Adrian Williams
Sent: Wednesday, January 21, 2009 12:28 PM
To: flexcoders@yahoogroups.com
Subject: Re: [flexcoders] Passing variables from .swf to .swf

 

Hi Tracy,

We are already using a cental db here...we are running a pretty
massive DB via SQL, use C#.Net for our control layer and use Flex/AS for
our presentation, which calls for the data using a WSDL...the dashboard
is for project managers...when they login to the dashboard, I need to be
able to pass their loginId to the widgets so they can load the various
data points for the project that person manages...i.e.  widget-A loads
project statistics...and it needs to know which project's statistics to
load...the only way it will know that is by having the userId that
logged in.

Or am I not understanding what you are referring to as a central
data model?

Adrian

Tracy Spratt wrote: 

How about just having a central data model?

 

Tracy Spratt 
Lariat Services 

Flex development bandwidth available 





From: flexcoders@yahoogroups.com
[mailto:flexcod...@yahoogroups.com] On Behalf Of Adrian Williams
Sent: Wednesday, January 21, 2009 11:53 AM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Passing variables from .swf to .swf

 

Hi All,

I've been researching this challenge and am not sure which
of the methods I've found is the best...need some input on this one.

I have a dashboard application (dashboard.swf) that uses
multiple swfloaders to load the various widgets that the user needs
(which are also .swf's).  The trick is that I need to pass a variable
into the widgets to let them know which user logged in which allows the
widget to load the data specific to that user.  

I've seen a method that utilizes a localConnection to pass a
connection string, a method and parameters...my concern is the local
connection...there can be up to 20 widgets on a dashboard and opening an
LC for each doesn't seem like it's be efficient...

Help?!

Thanks,
Adrian

 



Re: [flexcoders] Passing variables from .swf to .swf

2009-01-21 Thread Adrian Williams

Hi Tracy,

   Oh if only it were that easy!! Looks like it's gonna have to be much 
deeperhere's why...


   A project manager can have any number of projects they run...
  
   The dashboard is setup so they have access to all their projects via 
one dashboard


   Basically, when they login, I get a list of all the projects they 
manageand then create a simple viewStack with tabNavigator, one tab 
for each of the projects they run. Each tab has the same widgets, only 
loaded with the data specific to the project for the tab they are 
looking at (much akin to having several tabs opened in Firefox, all of 
them on Amazon, yet on each one, I'm looking for a book different from 
the other tabs.)


   The widgets are simple stand-alone apps that are repatedly used in 
each tab...i.e. projectStatistics.swf is used once on every tab (i.e. 
for every project) on the dashboard.  For each instance of the widget, 
it needs to know the project name so it can query the data for that 
specific project. 

   All of this is created dynamically in my actionscript (will paste 
below).  In addition, the user can customize (and persist in the db) 
their widget configuration for each project (tab). So, with my 3-column 
layout, they might have, on [Tab1] Project 1,  column 1, Widgets A, C 
and D while on [Tab2] Project 2, column 1, Widgets A, B, F, Q. All of 
this persistence is read from the database upon their login and the code 
simply builds their dashboard, tabs and widgets based on their last know 
setup. 

   Since this is so dynamic, I don't think I can get away with trying 
to access any static public variables via application.application.  I've 
taken a look at your example on cflex.net on manipulating the .content 
property, but it looks like I need to specifically reference each of the 
loaded widgets, which is not very simple considering their dynamic 
loading...


   Any other ideas? And I cannot seem to find much regarding the data 
model in flex you mentioned...


Best,
Adrian
   private function 
getGapWidgetConfigurationsResult(event:ResultEvent):void

   {
   gapWidgetConfigs = event.result as ArrayCollection;
   buildViewstack();
   }
   
   private function buildViewstack():void

   {
   for each (var project:Object in projectsArray)
   {
   var projectName:String = project.label;
   var newCanvas:Canvas = new Canvas();
   newCanvas.id = canvas + projectName;
   newCanvas.label = projectName;
   newCanvas.percentHeight = 100;
   newCanvas.percentWidth = 100;
   dashboardMainViewstack.addChild(newCanvas);
   
   var newHBox:HBox = new HBox();

   newHBox.id = hbox + projectName;
   newHBox.percentHeight = 100;
   newHBox.percentWidth = 100;
   newCanvas.addChild(newHBox);   
   
   for (var i:int = 0; i  3; i++)

   {
   var newVBox:VBox = new VBox();
   newVBox.id = col + i + projectName;
   newVBox.percentWidth = 33;
   newVBox.percentHeight = 100;
   newVBox.setStyle(borderStyle, solid);
   newVBox.setStyle(borderThickness, 1);
   newVBox.setStyle(cornerRadius, 4);
   newVBox.setStyle(horizontalAlign, center);
   newVBox.setStyle(horizontalCenter, 0);
   newVBox.setStyle(paddingTop, 5);
   newVBox.setStyle(paddingBottom, 5);
   newVBox.setStyle(backgroundColor, #FCF3D3);
  
newVBox.addEventListener(MouseEvent.MOUSE_DOWN,setMouseDownTrue);
  
newVBox.addEventListener(MouseEvent.MOUSE_UP,setMouseDownFalse);
  
newVBox.addEventListener(DragEvent.DRAG_ENTER,checkAndHandleDE);
  
newVBox.addEventListener(DragEvent.DRAG_DROP,checkAndHandleDD);
   
   newHBox.addChild(newVBox);
   
   for each (var widgets:Object in gapWidgetConfigs)

   {
   if (widgets.DisplayColumn == i + 1  
widgets.BcgGroup == projectName  widgets.Active == 1)

   {
   var newPanel:SuperPanelPlus = new 
SuperPanelPlus();

   newPanel.id = widgets.PanelId;
   newPanel.title = widgets.Title;
   newPanel.y = 0;
   newPanel.percentHeight = widgets.Height;
   newPanel.percentWidth = 98;
   newPanel.collapsed = 

RE: [flexcoders] Passing variables from .swf to .swf

2009-01-21 Thread Tracy Spratt
Well it is only the architecture that is simple.  If you have complex
requirements, the implementation will be complex as well.

 

Data model is a generic term for some accesible structure that holds
data, not a class.  It is not static.

 

In the creationComplete handler of each of your child swf's, you might
have something like:

var xmlProject:XML =
Application.application.MyModel.getProjectData(ProjectId);

 

That assumes the data is already in the model.  If a data service call
is required, you would need do something like:

Application.application.MyModel.fetchProjectData(ProjectId);  

 

Then have a listener or ChangeWatcher listeneing to a model property.
When the data call returns in myModel, it sets the value of the bindable
property, and the watcher in the child swf is called with the retrieved
data.

 

But the core idea is that all components communicate via the model.

 

Using a model and events is probably best, but you can also go
straight through dom references.  Listeners can be added to dynamically
created components, so you would not need specific, named references to
the child swfs.  You would listen for the applicationComplete event, as
in my example, then pass the project Id or something into the child swf.
If you passed it in via a setter, you could invoke the get data from
within that function.  Of if you already have the project data ready
when you load the swf, pass it in.

 

Tracy Spratt 
Lariat Services 

Flex development bandwidth available 



From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On
Behalf Of Adrian Williams
Sent: Wednesday, January 21, 2009 3:45 PM
To: flexcoders@yahoogroups.com
Subject: Re: [flexcoders] Passing variables from .swf to .swf

 

Hi Tracy,

Oh if only it were that easy!! Looks like it's gonna have to be much
deeperhere's why...

A project manager can have any number of projects they run...

The dashboard is setup so they have access to all their projects via
one dashboard

Basically, when they login, I get a list of all the projects they
manageand then create a simple viewStack with tabNavigator, one tab
for each of the projects they run. Each tab has the same widgets, only
loaded with the data specific to the project for the tab they are
looking at (much akin to having several tabs opened in Firefox, all of
them on Amazon, yet on each one, I'm looking for a book different from
the other tabs.) 

The widgets are simple stand-alone apps that are repatedly used in
each tab...i.e. projectStatistics.swf is used once on every tab (i.e.
for every project) on the dashboard.  For each instance of the widget,
it needs to know the project name so it can query the data for that
specific project.  

All of this is created dynamically in my actionscript (will paste
below).  In addition, the user can customize (and persist in the db)
their widget configuration for each project (tab). So, with my 3-column
layout, they might have, on [Tab1] Project 1,  column 1, Widgets A, C
and D while on [Tab2] Project 2, column 1, Widgets A, B, F, Q. All of
this persistence is read from the database upon their login and the code
simply builds their dashboard, tabs and widgets based on their last know
setup.  

Since this is so dynamic, I don't think I can get away with trying
to access any static public variables via application.application.  I've
taken a look at your example on cflex.net on manipulating the .content
property, but it looks like I need to specifically reference each of the
loaded widgets, which is not very simple considering their dynamic
loading...

Any other ideas? And I cannot seem to find much regarding the data
model in flex you mentioned...

Best,
Adrian
private function
getGapWidgetConfigurationsResult(event:ResultEvent):void
{
gapWidgetConfigs = event.result as ArrayCollection;
buildViewstack();
}

private function buildViewstack():void
{
for each (var project:Object in projectsArray)
{
var projectName:String = project.label;
var newCanvas:Canvas = new Canvas();
newCanvas.id = canvas + projectName;
newCanvas.label = projectName;
newCanvas.percentHeight = 100;
newCanvas.percentWidth = 100;
dashboardMainViewstack.addChild(newCanvas);

var newHBox:HBox = new HBox();
newHBox.id = hbox + projectName;
newHBox.percentHeight = 100;
newHBox.percentWidth = 100;
newCanvas.addChild(newHBox);   

for (var i:int = 0; i  3; i++)
{
var newVBox:VBox = new VBox