Flex :: Avoiding Duplicate Data & Calculations In View-models?

Jul 26, 2011

I'm working on a Flex application that uses MVVM. I understand that it's recommended to have a 1-to-1 mapping between views and view-models. How then do I avoid performing the same calculations and storing the same data multiple times if it is needed in multiple views?

For example, imagine I have a program that can load project files consisting of a list of items. The main tab of my application has an export button that should only be enabled if the project is valid so I create an isExportEnabled property on the view-model for the main tab. The calculation for this involves validating the project by iterating though every item in the project and verifying some attribute on each. I have another tab which has a "Print Project Summary" button so the view-model for this tab has isPrintEnabled. The value for this flag is based on the same criteria, whether or not the project is valid.

I could put the logic for determining these values in their respective view-models, but then I end up calculating the same value twice when a project is loaded. I could move isValid to the domain model but then the model becomes denormalized. What if a saved project is edited without updating the "isValid" flag? I could make a global "Project View-Model" for the entire project which calculates whether the project is valid and then have isExportEnabled and isPrintEnabled delegate to that. However, then I end up with a hierarchy of view-models which this article recommends avoiding: Applying the Presentation Model in Flex

View 1 Replies


Similar Posts:


ActionScript 3.0 :: Passing Parameters To Function And Avoiding Duplicate Variable Definitions

Jun 18, 2009

I have shortened this example to keep it simple, otherwise I wouldnt be doint this

I need to pass different variables to function inForLoop each time.

Code:
function someFunction():void {
for (var i:int = 0; i < columns; i++) {
for (var j:int = 0; j < rows; j++) {

[Code]....

View 3 Replies

Set Variables In MXML While Avoiding Data Binding?

Jun 2, 2011

I love MXML but am starting to notice some of its drawbacks. The main one I'm struggling with is its larger memory usage due to the need for binding. In the super simple code snippet below, which I've tested on Flex 4.0[code]...

My main question: is there any way to set variables in MXML that doesn't eat up memory? I'm aware that I can do this explicitly in AS and keep MXML as a bare bone structure but was wondering if there was an alternative path.

Secondary question: why memory usage in c different from a and b? I've looked up at the intermediate code and it seems like the const case still sets up some binding logic but not as much and have been wondering why that is.

View 1 Replies

Actionscript 3 :: Manage Complex Models - Cache Data From Database?

Oct 24, 2010

My app has windows that are components. In my case, now I have 2 components that have a drop down list that show the current logged user lists. So when I use one component for the first time it make a request to database, save data in model, and load data from model, but when the second component opens, it will just load data from model. Easy for now: ListModel: this contains the current user lists.

Now I have another component but this needs the lists of another user. Where do I save these lists? I can't put in the ListModel as then will mix up with current user. Just a remind: there is not just 2 users. It might have more users, so it should be scalable.

View 1 Replies

Flex :: Get A View To Read Data?

Dec 6, 2011

I need to convert a lot of stuff in my profession - so I'm building a conversion tool for my phone with some of the conversions I use a lot. Now, I want to be able to build this properly. So far, here's my code:

[Code]...

View 2 Replies

Java :: View Data From Excel In Flex App?

Apr 4, 2011

I have a flex-application deployed on tomcat with blazeds. User constantly selects ranges excel-document. Now, a user enters a cell addresses in text fields (for example, C1: C20). But it is very inconvenient! How to display excel-data as a table in my application? I think, I can parse excel-document using Apach POI and transmit these data to the Flex-application. But there are other ways?

View 2 Replies

Flex :: Get Data From Datagrid In A View To A Label?

Oct 26, 2011

<mx:DataGrid id="dgAutoFill" x="11" y="234" width="934" dataProvider="{rssHln.lastResult.rss.channel.item}">
<mx:columns>

[Code]....

I'm trying to get the title from the selecteditem from this datagrid (which is filled by a rss-feed) in a label. I've searched for ways, but I can't find how I should get this done.

This is the eventhandler I've added to the datagrid, and the function:

dgAutoFill.addEventListener(ListEvent.ITEM_CLICK, showDetails);
public function showDetails(event:ListEvent):void {
lblTitle.text = ?;
}

View 1 Replies

Flex :: Send Data Between Pages In View Stack?

Feb 22, 2010

I have a login page (that working), if details is correct, i want to go to welcome page, and display the first name and last of the user.

Is ok to access to the label in the another page, and how can i do that

This is my code:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script>

[Code]....

View 1 Replies

Actionscript 3 :: Flex Mobile Persist View Data?

Sep 18, 2011

I built a simple hello world app to check out the Flash Builder 4.5 mobile capabilities.Here's how it works:The Default View asks for name in an textinput and has a continue button.When you click the continue button it pushes a new view in the viewNavigator which just displays "Hello " + name in a label.When you click anywhere in this view, it pops a view (i.e. itself) from the viewNavigator, to go back to the default view

I see only 1 issue with this:When I get back to the default view, it is in its initial state, i.e. the textInput is blank. It seems as if the viewNavigator created a new view of the default view's class and pushed this, instead of just removing the top view and displaying the previous one.I see this being especially problematic for programs which display data in a grid and you can click the data to view the detail...when you get back, the grid will be empty.

EDIT:
Project name: HelloWorld
Code below:[code]....

Clicking on screen 2 gets us back to initial screen. Notice the blank textInput

View 2 Replies

Flex :: Clone Function Duplicate Data

Feb 4, 2010

I've some strange behavior using ObjectUtil.copy() and ByteArray.writeObject/readObject(). I clone an ArrayCollection and sometime the result is two identical instance of the class. Example :

[Code]...

View 1 Replies

Flex Mobile 4.6 - Pass Data (selectedItem) From Master To Detail View In Splitview?

Dec 26, 2011

I have a tabbed view with in the second tab a splitview controller.

The master view shows a list. When selecting an item from that list it opens a second view with a new list by using navigator.pushView.

When I select an item in the second view/list it has to be passed to the detailview. Is there a simple solution available?

View 1 Replies

Flex :: Presentation Model Pattern Can View Specific Logic Reside In View?

Aug 15, 2011

I'm currently using RobotLegs with the Presentation Model pattern to develop a Flex 4 project. I understand that all business logic related to a View resides in the Presentation Model associated with that view, however, I am confused when it comes to View specific logic.For example, I have an indicator that needs to be positioned relatively to list items depending on which list item is selected. Is it acceptable in the Presentation pattern to put the logic that will position the indicator in the View and simply have that logic run in reaction to a selectedIndex property changing in the presentation model?The reason I am considering this is that since the Presentation Model does not have a reference to the view it is difficult to come up with an ideal solution for manipulating view components.

View 1 Replies

Flex :: Change A View From Inside A View?

Jun 13, 2010

I have one .mxml file (the Application) with a ViewStack (with 4 views) and a ControlBard, obviously I can change the views with it, but what I want to do is: in view #1 I have an image which I want to convert to a "hyperlink", so when I click it I go to View #2, is this doable? Also I would like to pass somehow some data (like a String) to that View #2 (lets say the it's a user avatar I click so I want to go to the second view which will show me his profile, that's why I need his name/id).

View 1 Replies

Flex :: Taken Push View Object Into Next View?

Sep 28, 2011

My problem is that when I try to pass an object from the navigator.pushView(view, dataobject), I can't figure out how to access the dataobject from actionscript. I can access {dataobject.property} from MXML easily, but I want to set a variable in the new view to the passed dataobjects property.

View 1 Replies

Flash :: View Data Passed To It?

May 26, 2010

I have a flash file that I am trying to debug. It loads a second flash file which it passes data to, and then that data is sent to a server. Unfortunately the data isnt coming out how it should.

I would like to know if anyone knows of a way to see what data is being passed to the embeded flash file from the original flash file. I need to make sure the data going to it is correct.

View 1 Replies

Actionscript 3 :: Push Data Into TabbedViewNavigator In View?

Apr 3, 2012

I have a view like this in my Flex mobile Application:

<s:View xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark" title="aaa" actionBarVisible="false" creationComplete="view1_creationCompleteHandler(event)">
<fx:Declarations>

[Code]....

And I want to send data(gelen) to tabbedviews (to views.HastabilgileriView/views.MenuView) How can I do that?

View 2 Replies

ActionScript 3.0 :: How To Use GPU For Calculations

Jan 28, 2011

I am working on a project at the Ruhr-University, where i have to determine the calculation speed of ActionScript, e.g. in calculating MD5 Hash values.Is it possible to use the GPU for the calculation? It would be the best, when i can use the GPU and the CPU for the calculations.I already know that ActionScript is running on the CPU und the GPU is used for video rendering.Is there a chance to use specifically the GPU for the calculation?

View 4 Replies

ActionScript 2.0 :: Using Eval For +/- Calculations ?

Apr 29, 2008

Basically I want to eval() a string like _level0.mc._x-=dist; where the "-" or "+" is a variable.You can paste this straight in and it should work.. only the last part (where it's doing the eval) doesn't.

Code:

this.createEmptyMovieClip("mc",this.getNextHighestDepth());
_level0.mc._x=200;
_level0.mc.createTextField("txt",_level0.mc.getNextHighestDepth(),0,0,200,200);[code]......

View 2 Replies

ActionScript 3.0 :: Merging Duplicate Data In Array

Jan 31, 2009

I am parsing data from an xml file into an array within my flash file. The nodes within the xml file have common data between them. What I am attempting to do is dynamically push the data in the array without duplicating data already contained in the array. For example I may have an xml file that looks like this:

<videos>
<video>
<title>video1</title>
<thumb>file1.jpg</thumb>
<group>group1</group>
[Code] .....

Say I want to push the "group" data into an array. When it gets to the third "video" node I want the array to see that "group1" already exists so instead of pushing a second reference of it into the array to actually push the secondary data ("title" and "thumb"> into a new array for "group1". I will later use that array to pull up a list of "group1" videos.

View 2 Replies

ActionScript 2.0 :: Avoid Redundant Data With Duplicate Mc?

Dec 30, 2009

I have a mc (squareContainer) that can be dragged around. It also contains other mc's that uses hittest and changes colour on mouseDown.I want to add another squareContainer (eg squareContainer2) that contains the same mc's with a couple of extra ones.. what is the best way to do this without duplicating instance names, functions and variables?

View 0 Replies

ActionScript 3.0 :: Duplicate Bitmap Without Losing Data?

Nov 22, 2010

I'm creating a mosaic application from facebook images and I have all of the coding working, my problem is I'm duplicating (cloning) Bitmap's in the final mosaic because obviously there aren't enough images on everyones facebook to make up the 1000+ images in a mosaic

See in the upperleft how all the images are very well defined, but then as the grid continues to the bottom and right each image gets less and less accurate until it is just one color...The code I am using is just,

ActionScript Code:
var myClone:Bitmap = new Bitmap(arrayBMD[index]);
addChild(myClone);

where arrayBMD is an array that holds each BitmapData for each Image.

View 7 Replies

Media Server :: Cannot View SharedObject Data In Admin Console

Mar 2, 2010

I'm attempting to view Shared Object data in my FMS Administration Console, but I consistently get the error:Object encoding error; terminating connection.I'm using Flex 3 with FMS 3.5, I'm positive that everything is using AMF3. The Shared Objects do seem to work. I can connect to the shared object through another instance of the app and pull saved data but they are not inspectable in the administration console. Also,very often when a new instance connects to the server I get a RangeError and all of my Flash Player instances crash.

View 9 Replies

ActionScript 2.0 :: Fade And Change Data For Each Duplicate Movieclip

Aug 3, 2009

mySQL called by PHP writes info to my xml file for feeding into flash. The movie displays x number of randomly called bits of info - an image, name and link - this is all handled by the sql query and php commands. It forms a nice wee xml file - good so far. In flash, I am using the duplicate movieclip function to display my info in a grid style and all encapsulated in a scrollable window. What I want to move on to do is have these "tiles" in the grid then fading out after x number of seconds and fading back in with a different set of results pulled from the xml file. I have made a few attempts but just can't seem to get my head around the arrays and ways I need to manipulate my existing code (below) to my requirements!

[Code]...

View 2 Replies

Silverlight :: Get Video Streaming Data From Flash Player To View On Phone?

Jan 30, 2012

Is it possible to investigate an html page that views a video streaming data using flash, and then use these data to view it on the phone? For example Al Jazeera website has a streaming service. I've looked through the html page and other resources using chrome developers tools. I found a lot of data, but couldnt figure it out which data I need.

View 1 Replies

Actionscript 3 :: Duplicate Dynamic Html Content Box And Call Different Data?

Dec 8, 2010

I'm working in Flash CS5 w/ActionScripting 3.0. I have a content box w/scroller that calls dynamic html on one page/part of my project's timeline.

I want to duplicate the exact same content box w/scroller, but need it to contain different data (call a different .htm doc), for another part of my site.

View 1 Replies

ActionScript 2.0 :: Limit To The Number Of Calculations It Can Perform?

May 20, 2004

How much can the flash player handle before it starts to slow down? What is the limit to the number of calculations it can perform?

View 2 Replies

ActionScript 3.0 :: Performing Calculations With Values Inside TextBoxes

Feb 6, 2011

I have two InputText boxes (Flash CS5 AS3). I will perform calculations with the values that are placed inside the boxes. How can I turn their values into numbers? I will eventually restrict the boxes to numeric values only.

View 3 Replies

ActionScript 2.0 :: Import Numbers For Calculations Into A Dynamic Text Box?

Jan 7, 2011

I am an animator who does a little actionscript from time to time (enough to get me in trouble) but am at a newbie lite experience stage. I have flash 8 (actionscript 2). I have formulated a calculator for my boss (not in animation, unfortunately) that has some very simple flash maths. I have previously loaded text into a swf from an external text file into a dynamic text box � easy enough. But in my simple calculator I�d like to add a pricing schedule which I can edit externally (without Flash, simply edit the text file) to change the prices on some stuff. Can this be done? Every time I try using the loadVariablesNum or LoadVars approach my calculations come up with a NaN error. I suspect you can�t load characters that are recognised as numbers from an external text file. Can I do it with XML (I have some very basic understanding) or do I need to use php and mySQL?

View 2 Replies

ActionScript 3.0 :: Number Arrays - Cannot Do Calculations For Large Values

Jun 12, 2011

I've been making arrays from numbers produced by the Collatz conjecture. But when the number where we start calculating exceeds over 1x10^16 program can't do any more calculations. It loses it's capability to handle odd numbers. Heres a part of my code that makes calculations:

ActionScript Code:
var a:Number;
var result:Array = new Array();
var count:int = 0;
function calculate(e:TimerEvent):void{
[Code] .....

View 6 Replies

ActionScript 2.0 :: BitmapData - Calculations Of The X,y Coordinates Of The Rectangle Cropping ?

Oct 6, 2007

After seeing the I've been told that movieclips aren't suited for games, what do you use? thread, I thought I would try to incorporate the approach into a game I'm currently programming to make it a little less processor intensive.

I have a giant movieclip of a football field, of which only 5-10% is shown at any given time. I'm guessing that flash still has to make calculations for the other 90-95% of the field every frame, even though it's of no use. From what I understand (not much), copyPixels seems like the perfect candidate for such a situation.

It seems simple, but I'm having trouble actually implementing it, and I'm not sure which actions are needed and what might be introducing unnecessary work. I have a movieclip (mc_field, exported for as), but if it would save the processor some effort,I could easily save this as a bitmap and export that for actionscript. The width and height of the final product (bitmap/BitmapData) will be Stage.width, Stage. height,respectively,and I can handle making the calculations of the x,y coordinates of the rectangle cropping (which part of the source bitmap I want to crop).I'm sure it's only 3 lines of code, and I know that there are a few examples online, but for some reason.

Say, for frame one, I want to take the field (either mc_field or bm_field) and copy 500px x 300px, starting at 140,230 from the source bitmap to mc_container.Then, for frame two, I want to copy 500px x 300px starting at 240,540 from the source bitmap to mc_container.

View 4 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved