[flexcoders] Re: Animated dashed lines

2008-07-22 Thread havardfl
--- In flexcoders@yahoogroups.com, havardfl [EMAIL PROTECTED] wrote:

 In a project I'm working on I would like to represent data flowing
 through the system with dashed/dotted lines moving between two or more
 points.
 
 I've done one implementation using the lineGradientStyle function to
 create dashes. This works, but I'm not pleased with the CPU load while
 the script is running. I'd like to draw 100+ lines, and my method of
 doing it isn't cutting it.
 
 Does anyone know a great way of drawing animated dashed/dotted lines
 without using much CPU time?


This is my implementation btw:

static public function DrawStippledShape2(g:Graphics,
points:Array, pattern:Array=null, alphas:Array=null,
colors:Array=null, thicknesses:Array=null, offset:Number=0):void
{
  g.moveTo(points[0].x, points[0].y);
  var pat2:Array = [];
  var patsum:Number = 0;
  for each (var p:Number in pattern){
patsum += p;
  }
  for (var i:int = 0 ; i  pattern.length ; i++){
pat2[i] = pattern[i] / patsum * 255;
  }
  
  for (var i:int = 1 ; i points.length ; i++){
var p1:Point = points[i-1];
var p2:Point = points[i];


var m:Matrix = new Matrix;
var ptemp:Point = p2.subtract(p1);
var rot:Number = (Math.atan2(ptemp.y, ptemp.x));   
  
m.createGradientBox(patsum,patsum,0,offset, offset);


//note(rot.toString());
m.rotate(rot);   
  
g.lineStyle(5,0);

g.lineGradientStyle( GradientType.LINEAR, colors, alphas,
pat2, m, SpreadMethod.REFLECT, InterpolationMethod.LINEAR_RGB);

//g.beginGradientFill(GradientType.RADIAL, [0xFF,
0x00FF00], [1,1], [0,128],m);

g.lineTo(p2.x, p2.y);
  }
}



[flexcoders] Animated dashed lines

2008-07-21 Thread havardfl
In a project I'm working on I would like to represent data flowing
through the system with dashed/dotted lines moving between two or more
points.

I've done one implementation using the lineGradientStyle function to
create dashes. This works, but I'm not pleased with the CPU load while
the script is running. I'd like to draw 100+ lines, and my method of
doing it isn't cutting it.

Does anyone know a great way of drawing animated dashed/dotted lines
without using much CPU time?



[flexcoders] Re: DataGrid ItemEditor being closed when other component is updated

2007-06-06 Thread havardfl
Tried setting a constant width and height to the datagrid and the
list. Tried placing list and datagrid in separate boxes, each with a
fixed height an width.

Didn't make a difference. Does anyone have any other ideas? 

--- In flexcoders@yahoogroups.com, Alex Harui [EMAIL PROTECTED] wrote:

 If the DG thinks it needs to be re-layed out, it will close its session.
 
  
 
 Try locking the width/height of the List.  It might stop it from
 invalidating the parent container.  Wrapping the List in another
 container might work as well.
 
  
 
 
 
 From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
 Behalf Of havardfl
 Sent: Tuesday, June 05, 2007 6:38 AM
 To: flexcoders@yahoogroups.com
 Subject: [flexcoders] DataGrid ItemEditor being closed when other
 component is updated
 
  
 
 I'm having some trouble with an editable DataGrid... I have one
 DataGrid that is editable, and then a List that is not.
 
 The List is bound to an XMLListCollection (Same thing happens
 ArrayCollection), which gets items added to it constantly.
 
 Now, when I click one of the columns in the editable DataGrid, the
 itemeditor gets opened, but is closed the moment the second DataGrid
 is updated... (If I use a DataGrid instead of a List as the second
 item, the closing of the ItemEditor only seems to happen once the
 second DataGrid has enough items to create a ScrollBar).
 
 Has anyone else experienced this, and does anyone know of a solution?
 
 Example Code:
 ?xml version=1.0 encoding=utf-8?
 mx:Application xmlns:mx=http://www.adobe.com/2006/mxml
 http://www.adobe.com/2006/mxml 
 layout=vertical creationComplete=onCreated(event) xmlns:local=*
 mx:Script
 ![CDATA[
 import mx.collections.ArrayCollection;
 
 [Bindable]
 private var dp1:ArrayCollection;
 [Bindable]
 private var dp2:ArrayCollection;
 private var t:Timer;
 private function onCreated(event:Event):void
 {
 dp2 = new ArrayCollection();
 dp2.addItem({b:Try editing this});
 
 t = new Timer(1000);
 t.addEventListener(TimerEvent.TIMER, onTimer);
 t.start();
 
 dp1 = new ArrayCollection();
 } 
 private function onTimer(event:TimerEvent):void{
 dp1.addItem({a:1});
 }
 
 ]]
 /mx:Script
 
 mx:DataGrid dataProvider={dp2} editable=true
 mx:columns
 mx:DataGridColumn headerText=test dataField=b editable=true/
 /mx:columns
 /mx:DataGrid
 mx:List dataProvider={dp1} labelField=a/
 /mx:Application





[flexcoders] DataGrid ItemEditor being closed when other component is updated

2007-06-05 Thread havardfl
I'm having some trouble with an editable DataGrid... I have one
DataGrid that is editable, and then a List that is not.

The List is bound to an XMLListCollection (Same thing happens
ArrayCollection), which gets items added to it constantly.

Now, when I click one of the columns in the editable DataGrid, the
itemeditor gets opened, but is closed the moment the second DataGrid
is updated... (If I use a DataGrid instead of a List as the second
item, the closing of the ItemEditor only seems to happen once the
second DataGrid has enough items to create a ScrollBar).

Has anyone else experienced this, and does anyone know of a solution?

Example Code:
?xml version=1.0 encoding=utf-8?
mx:Application xmlns:mx=http://www.adobe.com/2006/mxml;
layout=vertical creationComplete=onCreated(event) xmlns:local=*
  mx:Script
![CDATA[
  import mx.collections.ArrayCollection;
  
  [Bindable]
  private var dp1:ArrayCollection;
  [Bindable]
  private var dp2:ArrayCollection;
  private var t:Timer;
  private function onCreated(event:Event):void
  {
dp2 = new ArrayCollection();
dp2.addItem({b:Try editing this});

t = new Timer(1000);
t.addEventListener(TimerEvent.TIMER, onTimer);
t.start();

dp1 = new ArrayCollection();
  }  
  private function onTimer(event:TimerEvent):void{
dp1.addItem({a:1});
  }

]]
  /mx:Script
  
  mx:DataGrid dataProvider={dp2} editable=true
mx:columns
  mx:DataGridColumn headerText=test dataField=b editable=true/
/mx:columns
  /mx:DataGrid
  mx:List dataProvider={dp1} labelField=a/
/mx:Application






[flexcoders] Visibility of components

2007-05-31 Thread havardfl
I have an application where several different components in different
containers spread around the application should be bound to external
data. These bindings need to know when the component is actually
on-screen to know when to start fetching data.

What is the easiest way of doing this, that is determine whether a
series of components are on-screen?



[flexcoders] TileList showing wrong data after using removeItemAt when scrolled

2007-05-11 Thread havardfl
I have a rather strange error occuring, which to me seems like a bug
with the TileList...

I have a small application with a TileList and a Button.
The Tilelist has an XMLListCollection as a dataprovider.

On Initialization I add 100 entries to the collection. They all come
up nicely in the TileList. I then scroll to the bottom of the tillist
and click the button.

The button calls removeItemAt on 5 items in a part of the collection
that is not visible.

When I then scroll up, the items I deleted are gone from the TileList
as they should, but so are some of the first items in the collection. 

If I print the contents of the collection, the first items are still
there, but they aren't shown in the TileList...

If I run the excact same code, but keep the items to be removed
visible when I click the button, it all works fine.

mx:Script
![CDATA[
import mx.collections.XMLListCollection;   
[Bindable]
private var dp:XMLListCollection = new XMLListCollection(); 

private function onInit():void{
  for (var i:int = 0 ; i  100 ; i++)
dp.addItem(p p={i}/); 
}

private function ondelete(event:Event):void{
  for (var i:int = 0 ; i  5 ; i++)
dp.removeItemAt(20);
}

]]
/mx:Script
mx:TileList id=tile dataProvider={dp} width=200 height=300
rowHeight=20 labelField=@p columnWidth=40/
mx:Button label=Delete click=ondelete(event)/