[flexcoders] Re: Best Practices: ArrayCollection of custom objects?

2008-12-16 Thread burttram
Thank you both for your time and replies.



[flexcoders] Re: Best Practices: ArrayCollection of custom objects?

2008-12-12 Thread burttram
Is this such a trivial question that people are passing up replying
in lieu of bringing light to my ignorance, or are there really no best
practices to speak of here?

The only way I've found so far to do this is to deprecate the
overridden method, but even then from time to time we'll get a strange
error (this doesn't happen all of the time):

1021: Duplicate function definition.

Seems pretty obvious what's causing it, but we have other classes that
use this same syntax that aren't generating the error...

Is there any reason we shouldn't do this, or is there another, more
acceptable way to accomplish what we're trying to do here?

public class DataTypes extends ArrayCollection
{
public function DataTypes(){
}

[Deprecated]
override public function addItem(item:Object):void{
}

public function addItem(item:DataType):void{
super.addItem(item);
}
}



[flexcoders] Best Practices: ArrayCollection of custom objects?

2008-12-10 Thread burttram
I have a class (DataType) that I've written that is intended to be
used in an ArrayCollection of these objects (DataTypes).  I would like
to guarantee that this ArrayCollection can only be populated with
objects of the DataType class.

My initial thought was to extended the ArrayCollection class in the
DataTypes class, then override the addItem() method and change the
item:Object argument to item:CustomObject (which extends Object). 
Evidently this isn't permissible in Flex (we're still using Flex 2 here).

Are there any best practices surrounding this task?  Can anyone offer
some advice on how I should go about ensuring that the objects added
to this ArrayCollection are objects of my custom class?

Thanks in advance.



[flexcoders] Re: Best Practices: ArrayCollection of custom objects?

2008-12-10 Thread burttram
Oh, just for clarification, item:CustomObject is actually
item:DataType, which extends Object for the purpose I'm concerned with
here.



[flexcoders] Re: sound.isBuffering true until 100% loaded?

2008-11-04 Thread burttram
Ahh, much improved after placing the progress event listener on the
Sound object instead of the loader object, but I still feel like Flex
is buffering the entire .mp3 before the isLoading property is flipped
to false.  

Maybe I'm not considering something here, but seems like all things
being equal, buffering 1sec of audio should take the same amount of
time regardless of file size, but it seems that particularly with
larger files buffering 1sec takes significantly longer.  

I'm actually still using Flex 2 and the documentation for the
SoundLoaderContext says that the bufferTime property is the number of
seconds (vs Milliseconds) to buffer and defaults to 1000 (~17mins?). 
Even if I change this property to 2, I still don't notice any change
in the time it takes to buffer each sound and begin playing...

Any thoughts?  tips?  hints?

Thanks in advance.




[flexcoders] sound.isBuffering true until 100% loaded?

2008-11-02 Thread burttram
Hi, I'm trying to write a little .MP3 player component that displays a
buffering state while the file is buffering, then swaps to a
different (audio-visual) state when buffering is complete and the
sound starts streaming:

request = new URLRequest(sound.mp3);
loader = new URLLoader(request);
loader.addEventListener(ProgressEvent.PROGRESS, loadProgressHandler);
_sound = new Sound(request, new SoundLoaderContext(1000, false));
_channel = _sound.play(0);

My plan was to monitor the isBuffering property of the Sound object,
however when I check _sound.isBuffering in the loadProgressHandler,
it's always true.

I also have an event handler for the loader's complete event, and
that's the first time I'm finding _sound.isBuffering = false.

Any help you can offer is much appreciated.





[flexcoders] Re: How to default an Accordian to a closed state (Flex 3)

2008-10-08 Thread burttram
 Have you thought of using includeInLayout to make the children of the 
 containers populating the Accordion have no dimension?  This will 
 visually look like the accordion is closed.

I was asking about this not long ago
(http://tech.groups.yahoo.com/group/flexcoders/message/127045) and
would be very interested in hearing how you solve this.  I'm using
Flex 2 instead of 3, but I would think that the suggestion above may
work for both products/cases.  Please post any progress you're able to
make!

Thanks in advance,
Brian



[flexcoders] Re: Accordion control question

2008-10-06 Thread burttram
Great, thank you both for your suggestions, I'll have a look into both
solutions.

-Brian



[flexcoders] Accordion control question

2008-10-03 Thread burttram
Is there any way to prevent and accordion control item from opening,
so that the header will just act as a button?

I'm currently trying to use an accordion control as kind of a menu,
such that several items with sub-categories will open to reveal a
treeview in the appropriate accordion block (sorry for my lack of
terminology), however there are several items that have no
sub-categories (i.e. Home and Contact).  

What I'd like to do is to prevent that default action of opening from
happening, and instead collapse all members of the accordion control
at the same time.  Example can be seen at
http://beta.2b-studios.com/BDB.html

Any advice or suggestions?

Thanks in advance for your time,
Brian



[flexcoders] Re: Tree node height problem on initial load

2008-05-27 Thread burttram
I couldn't find anywhere that I was setting RowCount to a number,
however your suggestion of explicitly setting the rowHeight worked
like a charm.  

Thanks a million.

-Brian



[flexcoders] Tree node height problem on initial load

2008-05-23 Thread burttram
I have a component I'm developing to, among other things, accept an
XMLListCollection as a dataProvider (the data is being supplied via a
remote object call, which is why I've elected to extend a component to
handle the reopening /dragdrop, etc).

Best I can tell I've got working great, vice one issue that I just can't
seem to resolve.  Essentially, the first time the component loads it
shows the nodes in the tree at an apparently random height that is
significantly taller than what my normal tree node height should be. 
It would appear that the nodes are being spaced evenly across an
arbitrary height of the tree which is greater in height than the 100%
I've specified for the tree to take up inside it's container.

I've included a screenshot of the behavior here, the left-hand image is
the initial, jacked up state, and the right-hand image is the very same
component instance after the contents are loaded the second time:

http://www.2b-studios.com/xmlTreeView_Problem.png
http://www.2b-studios.com/xmlTreeView_Problem.png

Any help you guys might be able to provide would be so very much
appreciated, I've been beating my head against the wall on this for
hours now.

Thanks in advance,
Brian



[flexcoders] Re: Events, itemRenderers, and the horizontalList control

2007-11-28 Thread burttram
Awesome, I'll check out your blog and look into that solution then.

Thank you very much.

-Brian



[flexcoders] Events, itemRenderers, and the horizontalList control

2007-11-27 Thread burttram
I have been trying to figure out how to do something and have finally
reached wits end today.  I must be missing some fundamental
understanding of something between events, itemRenderers, and the
horizontalList control...  I am very new to itemRenderers, so I suspect
this is where my problem lies.

Here's what I'm trying to do.  For the sake of example, I would like to
have a horizontalList control that gets dynamically populated with
n-number of interactive controls (all of the same class - for
simplicity's sake, I chose a list control.)  So basically, click on a
button (or other event) and dynamically add a new List control to the
horizontalList's dataProvider.  In order to do that, I have to tell the
horizontalList how to display the new control, which (unless I'm
mistaken) requires an itemRenderer.

Once those dynamic controls are created I need to operate on them
independently, so I'm trying to add an event listener to each of those
controls as they are added.  Seems easy enough using a call to
addEventListener at the time the new dynamic List control is created,
and I can even trap that event in the itemRenderer (or, so I think), by
adding a generic on change event handler in the itemRenderer which, in
turns, re-dispatches the original event...

I think this may be where I'm going wrong, however I'm at a loss on how
to achieve what I'd like to accomplish otherwise.

The problem is, the event listener that I added when the dynamic
component was created isn't being recognized, or I'm placing the event
listener on the wrong component.  The event from the itemRenderer
apparently fires, however it's not heard by the main application.

Any assistance you guys can provide would be hugely appreciated, I've
been banging my head on the desk for longer than I care to admit on this
and I'm still missing something...

Thanks in advance,
Brian

dynamicLists.mxml
?xml version=1.0 encoding=utf-8?
mx:Application xmlns:mx=http://www.adobe.com/2006/mxml;
layout=absolute creationComplete=init();
 mx:Script
 ![CDATA[
 import mx.events.ListEvent;
 import mx.controls.List;
 import mx.rpc.events.ResultEvent;
 import mx.collections.ArrayCollection;
 import flash.events.Event;
 import flash.events.MouseEvent;

 [Bindable] private var _items:ArrayCollection = new
ArrayCollection([Item1,Item2,Item3]);

 private var _listCount:int = 0;

 private function init():void{
  }

 //Add a new list component to the horizontalList control
 private function addListItem(event:MouseEvent):void{
 _listCount++;
 addList();
 }

 //Create a new dynamic list control
 private function getNewList():List{
 var newList:List = new List;
 newList.id = dynamicList_ + _listCount;
 newList.dataProvider = _items;
 newList.toolTip = newList.id;
 newList.addEventListener('change', handleListChange);

 return newList;
 }

 //handle an event change of the list
 private function handleListChange(event:ListEvent):void{
 trace('... handleListChange from ' +
event.currentTarget.id);
 }

 //add a list to the Horizontal List component
 private function addList():void{
 itemListAC.addItem(getNewList());
 trace('Added new List control: ' +
itemListAC[itemListAC.length-1].id);

if(itemListAC[itemListAC.length-1].hasEventListener('change')){
 trace('onChange event listener was successfully
placed on: ' + itemListAC[itemListAC.length-1].id);
 }else{
 trace('No onChange event listener was present on: '
+ itemListAC[itemListAC.length-1].id);
 }
 }
 ]]
 /mx:Script
 mx:VBox width=100% height=100% 
 mx:Button click=addListItem(event) label=Click to add a new
List (should be identical to the one at the bottom)/
 mx:HorizontalList id=itemsHList width=100% height=100%
itemRenderer=ListIR
 mx:dataProvider
 mx:ArrayCollection id=itemListAC
  /mx:ArrayCollection
 /mx:dataProvider
 /mx:HorizontalList
 mx:List id=staticList dataProvider={_items} width=100%
height=100% change=handleListChange(event) toolTip=staticList
 /mx:List
 /mx:VBox 

/mx:Application


ListIR.mxml
?xml version=1.0 encoding=utf-8?
mx:Canvas xmlns:mx=http://www.adobe.com/2006/mxml; width=100
height=300 creationComplete=init()

 mx:Metadata
 [Event(name=change, type=ListEvent)]
 /mx:Metadata

 mx:Script
 ![CDATA[
 import mx.events.ListEvent;
 import mx.collections.ArrayCollection;

 [Bindable] private var