 |
 |
|
|
|
 |

11-19-2008, 11:55 PM
|
|
|
Funky Repeater Problem (Please help !!!)
In my attached code, if you edit one item of the first VBox first TextArea,
after typing the first character you can't type anymore.
If you edit one item of the second VBox first TextArea, after leaving that
TextArea you can't change anymore of the TextAreas in VBox 2.
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
backgroundGradientColors="[0xffffff, 0xffffff]"
horizontalAlign="left">
<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.controls.*;
[Bindable] private var ac1:ArrayCollection = new ArrayCollection([
"This is the first string in the application ArrayCollection.",
"This is the second string in the application ArrayCollection.",
"This is the third string in the application ArrayCollection.",
"This is the fourth string in the application ArrayCollection."
]);
[Bindable] private var ac2:ArrayCollection = new ArrayCollection([
"This is the first string in the application ArrayCollection.",
"This is the second string in the application ArrayCollection.",
"This is the third string in the application ArrayCollection.",
"This is the fourth string in the application ArrayCollection."
]);
private function myChangeHandler(event:Event):void{
ac1.setItemAt(entryText1[event.currentTarget.instanceIndices].text,
event.currentTarget.instanceIndices);
}
private function myFocusOutHandler(event:FocusEvent):void{
ac2.setItemAt(entryText2[event.currentTarget.instanceIndices].text,
event.currentTarget.instanceIndices);
}
]]>
</mx:Script>
<mx:Label text="Change Event"/>
<mx:VBox width="100%" height="100%">
<mx:Repeater id="rp1" dataProvider="{ac1}">
<mx:TextArea id="entryText1" text="{rp1.currentItem}" editable="true"
width="100%" height="20" change="myChangeHandler(event);"
borderThickness="0" selectable="true"/>
</mx:Repeater>
</mx:VBox>
<mx:Label text="Focus Event"/>
<mx:VBox width="100%" height="100%">
<mx:Repeater id="rp2" dataProvider="{ac2}">
<mx:TextArea id="entryText2" text="{rp2.currentItem}" editable="true"
width="100%" height="20" focusOut="myFocusOutHandler(event);"
borderThickness="0" selectable="true"/>
</mx:Repeater>
</mx:VBox>
</mx:Application>
|

11-20-2008, 01:24 AM
|
|
|
Re: Funky Repeater Problem (Please help !!!)
"Greg Lafrance" <webforumsuser@macromedia.com> wrote in message
news:gg28mt$a2l$1@forums.macromedia.com...
> In my attached code, if you edit one item of the first VBox first
> TextArea,
> after typing the first character you can't type anymore.
>
It seems like what's happening is that you get into a feedback loop where
you change an item in the ac and it causes the whole repeater to render
again. I got it closer with this, but it's still a bit screwy in the focus
dept.
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
backgroundGradientColors="[0xffffff, 0xffffff]"
horizontalAlign="left">
<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.controls.*;
[Bindable] private var ac1:ArrayCollection = new ArrayCollection([
"This is the first string in the application ArrayCollection.",
"This is the second string in the application ArrayCollection.",
"This is the third string in the application ArrayCollection.",
"This is the fourth string in the application ArrayCollection."
]);
[Bindable] private var ac2:ArrayCollection = new ArrayCollection([
"This is the first string in the application ArrayCollection.",
"This is the second string in the application ArrayCollection.",
"This is the third string in the application ArrayCollection.",
"This is the fourth string in the application ArrayCollection."
]);
private function myChangeHandler(event:Event):void{
/* deliberately make an error, since the Flex team
used that brilliant mechanism as the only way to
determine the repeater is done executing. */
try {
var makeError:Object = rp1.currentItem;
} catch (error:Error) {
//the repeater has executed, so we now want to
ac1.setItemAt(entryText1[event.currentTarget.instanceIndices].text,
event.currentTarget.instanceIndices);
return;
} finally {
//do nothing. we wanted an error
}
}
private function myFocusOutHandler(event:FocusEvent):void{
ac2.setItemAt(entryText2[event.currentTarget.instanceIndices].text,
event.currentTarget.instanceIndices);
}
]]>
</mx:Script>
<mx:Label text="Change Event"/>
<mx:VBox width="100%" height="100%">
<mx:Repeater id="rp1" dataProvider="{ac1}">
<mx:TextArea id="entryText1" text="{rp1.currentItem}" editable="true"
width="100%" height="20" valueCommit="myChangeHandler(event);"
borderThickness="0" selectable="true"/>
</mx:Repeater>
</mx:VBox>
<mx:Label text="Focus Event"/>
<mx:VBox width="100%" height="100%">
<mx:Repeater id="rp2" dataProvider="{ac2}">
<mx:TextArea id="entryText2" text="{rp2.currentItem}" editable="true"
width="100%" height="20" focusOut="myFocusOutHandler(event);"
borderThickness="0" selectable="true"/>
</mx:Repeater>
</mx:VBox>
</mx:Application>
|

11-20-2008, 05:34 AM
|
|
|
Re: Funky Repeater Problem (Please help !!!)
Thanks for the suggestion. I think I may use some other component for what I am
trying to do. This funky focus issue is fairly irritating.
As for what I am trying to do, I'm building a file list in the application,
where the list is a bunch of paths to files, such as Windows .rc files.
The paths are stored in an ArrayCollection, but I need to present them to the
user so they have the opportunity to edit the paths if necessary.
I would have preferred putting them all in one TextArea, but I didn't know how
to use myTextArea.text += ac.getItemAt(myIndex); and be able to add a newline
so each AC entry is on the next line in the TextArea.
Then after the user updates the text in the TextArea, I would just write out
whatever remains in the TextArea.text to file, but once again, the newlines
must be retained in the file I write to.
In this scenario there is no updating of the AC, but I need those newlines to
take effect within the TextArea and in the written file.
Thanks again for your help Amy!
|

11-20-2008, 01:43 PM
|
|
|
Re: Funky Repeater Problem (Please help !!!)
"Greg Lafrance" <webforumsuser@macromedia.com> wrote in message
news:gg2sdq$34p$1@forums.macromedia.com...
> Thanks for the suggestion. I think I may use some other component for what
> I am
> trying to do. This funky focus issue is fairly irritating.
>
> As for what I am trying to do, I'm building a file list in the
> application,
> where the list is a bunch of paths to files, such as Windows .rc files.
>
> The paths are stored in an ArrayCollection, but I need to present them to
> the
> user so they have the opportunity to edit the paths if necessary.
>
> I would have preferred putting them all in one TextArea, but I didn't know
> how
> to use myTextArea.text += ac.getItemAt(myIndex); and be able to add a
> newline
> so each AC entry is on the next line in the TextArea.
>
> Then after the user updates the text in the TextArea, I would just write
> out
> whatever remains in the TextArea.text to file, but once again, the
> newlines
> must be retained in the file I write to.
>
> In this scenario there is no updating of the AC, but I need those newlines
> to
> take effect within the TextArea and in the written file.
>
> Thanks again for your help Amy!
Why not just use a List? If you use itemIsEditor, I think that it will
update your AC for you.
|

11-21-2008, 04:44 AM
|
|
|
Re: Funky Repeater Problem (Please help !!!)
I ended up just using a TextArea and writing the file from there. That way the user can easily delete entire blocks of lines. Line endings render fine.
Thanks for your help Amy!
|

11-21-2008, 04:44 AM
|
|
|
Re: Funky Repeater Problem (Please help !!!)
"Greg Lafrance" <webforumsuser@macromedia.com> wrote in message
news:gg5dqk$d4h$1@forums.macromedia.com...
>I ended up just using a TextArea and writing the file from there. That way
>the user can easily delete entire blocks of lines. Line endings render
>fine.
>
> Thanks for your help Amy!
Not sure how helpful I was, but you're welcome ;-)
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|