[flexcoders] Re: Problem with LinearAxis on an horizontal axis

2009-04-14 Thread enriirne
 LinearAxis should do just what you expect

You are right, I realized only yesterday that *Axis also have the xField 
property, which does exactly what I needed :)

Enri



[flexcoders] Problem with LinearAxis on an horizontal axis

2009-04-12 Thread enriirne
For what I know, LinearAxis computes the *number* of samples, not a property on 
the data provider.

I would like to plot my samples linearly on the horizontal axis.
For example, I must plot with a LineChart these samples:
{day:3 value:1}
{day:5 value:4}
{day:6 value:8}

I'd like to put LinearAxis' min=1 and max=10, where 1 and 10 are day number.
Then I'd like to see value=1 in the first third of the area, 4 and 8 close 
together, then some space till the maximum day number, which is 10.

But, as I said, LinearAxis reasons on the number of samples, which in my case 
is 3. The only workaround I found is to artificially add empty samples for days 
1,2,4,7,8,9,10

Is there a bettere way?

Enri



[flexcoders] Bidirectional binding on a DateField hangs the player

2009-03-18 Thread enriirne
sdk: 3.2 or 3.3
player: 9 or 10

I believe that there are two bugs when binding a value object to a date field, 
and the date field back to the value object.
I'd like to receive some opinions.

Say we have a value object:
  vo = {date:some date}
When we instantiate a new form for editing, we put in the createComplete event 
this:
  originalDate = vo.date;
  BindingUtils.bindProperty(dateField, 'selectedDate', vo, 'date');
  BindingUtils.bindProperty(vo, 'date', dateField, 'selectedDate');
  vo.date = originalDate;

First, I had to save the date properties, otherwise the bidirectional binding 
would clear it with the empty content of the date field. But perhaps here I'm 
doing something wrong.

Second, when we run the form two or three times, the player hangs, probably in 
an infinite loop. I will debug DateField.as, but I'd appreciate any comment 
before doing so.

Enri



[flexcoders] Re: Question about binding and circular reference

2009-03-18 Thread enriirne
Is there anything more sweet than write a long post and see it vanish in the 
air?
Perhaps Chrome plus Flexcoders' Rich-Text Editor (Beta) is asking too much :)

I'll try again, shorter version.

 Another approach, if you're set on binding: Rather than the outer
 component waiting for creationComplete on the inner component to set the
 model value, simply put code in the inner component that waits for
 creationcomplete and creates the component-model return bindings
 programmatically via BindingUtils.

Hi Josh.
I didn't give up on bidirectional binding, but I admit to be close to the metal 
:)
The strategy that seems to work is this:
- a value object with two methods: saveOriginal and restoreOriginal, also 
useful to manage the form's cancel button
- binding through BindingUtils into createComplete
- a mono-binding for date fields, because of a bug in DateField.as

Here is some code. In case of interest, I'll post the implementation.
bindForCreate does a single bind, while bindForUpdate does two.

Enri

// a form
  [Bindable]
  public var vo:SomeVO;
  
  [Bindable]
  private var voOut:SomeVO;
  
  private var cws:Array = []; // used later to unbind
  
  private function creationComplete():void {
if (vo.isNew) {
  extend(cws, bindForCreate(vo, 'date', datefield, 'selectedDate'));
  extend(cws, bindForCreate(vo, 'name', nameField, 'text'));
} else {
  voOut = new SomeVO();
  vo.saveOriginal();
  extend(cws, bindForUpdateException(vo, voOut, 'date', datefield, 
'selectedDate'));
  extend(cws, bindForUpdate(vo, 'name', nameField, 'text'));
  vo.restoreOriginal();
}
  }



[flexcoders] Question about binding and circular reference

2009-03-11 Thread enriirne
Say I have this:

// MyForm.mxml
[Bindable]
public var foo:String;

mx:Bindable source=foo destination=myText.text/
mx:Bindable source=myText.text destination=foo/

mx:TextInput id=myText/

Is there an elegant way to avoid that foo is cleared upon creation of MyForm?
Indeed, if I do this in the main app:

var mf:MyForm = new MyForm();
mf.foo = bar;
addChild(mf);

then myText is empty, probably because it's empty content is first assigned to 
foo due to the second binding.
The real problem I'm trying to solve is to use the same value object to show 
data to the user and to receive his/her changes.

Of course it works if I use two vos: say voIn and voOut, binding them 
accordingly.

Any ideas?

Enri



[flexcoders] Ever seen this bug? (busy loop + custom component + '\n')

2009-01-29 Thread enriirne
I've just submitted this bug. I wonder if any busy loop user (game, 
animations) have vere seen it.

Enri

See code below to reproduce the bug

Steps to reproduce:
1. add a busy loop: enter_frame or timer with 1 ms resolution
2. inside the loop set the text property of a Label or TextArea to 
'\n'
3. outside the loop, for example in a click event, addChild of a 
custom component extending Canvas (or any other container) and 
including anything
 
 Actual Results:
 a click on the application area doesn't show anything. If resized 
(when running on flash player) the custom component appears, but the 
display is corrupted and inconsistent
 
 Expected Results:
 the custom component is added and showed
 
 Workaround (if any):
 use '\r' instead of '\n'

Comments:
This seems a race condition. If timer resolution is set to 2 ms, the 
bug appears less frequently. If set to 3 ms the bug disappears (all 
this on a recent notebook)
I've found this bug both on flash player 9 and 10, and on air 1.5
I suspect that this bug appears also using PopupManager.

# begin code: sampleApp.mxml
?xml version=1.0 encoding=utf-8?
mx:Application 
  xmlns:mx=http://www.adobe.com/2006/mxml; 
  applicationComplete=f()
  
  mx:Script
![CDATA[
  private function f():void {
//var t:Timer = new Timer(1);
//t.start();
//t.addEventListener(TimerEvent.TIMER, function (e:*):void 
{test.text = '\n' });
addEventListener(Event.ENTER_FRAME, function (e:*):void 
{test.text = '\n' });// with '\r' works
addEventListener(MouseEvent.CLICK,  function (e:*):void {
  addChild(new MyComponent);
});
  }
]]
  /mx:Script
  mx:Label id=test/
/mx:Application
# end sampleApp.mxml

# begin code: MyComponent.mxml
?xml version=1.0 encoding=utf-8?
mx:Canvas xmlns:mx=http://www.adobe.com/2006/mxml;
  mx:Button/
/mx:Canvas
# end MyComponent.mxml
 
 




[flexcoders] Re: Why this error with getDefinitionByName?

2009-01-16 Thread enriirne
@Howard:
   Is this in a SWF that's loaded into another SWF? If so see
no, it's a simple line on an empty application

@Josh:
 symbol, the class won't be compiled in. Try adding a reference to 
Ok, it works, but my TextInput was just an example. Mine is a problem 
with reflection: I made a recursive descent function that extracts all 
events dispatched by a control. The problem is that describeType needs 
an object, and I haven't found a way to get an instance of a non 
imported thing. Note that I take the control's name reading an mxml 
application as an xml file (in air, of course)

This must be a problem regarding the compiler domain. I don't know if 
I can dinamically create something that resides in a non imported 
module.

As a workaround, I'll create an instance for every controls :)

Enri



[flexcoders] Why this error with getDefinitionByName?

2009-01-15 Thread enriirne
trace(getDefinitionByName('mx.controls::TextInput'));

ReferenceError: Error #1065: Variable TextInput is not defined.

Enri