[flexcoders] Re: Datagrid sort order: is there a natsort() such as in PHP?

2008-05-06 Thread dougco2000
You have to do a sortCompareFunction, ala

mx:DataGridColumn dataField=number
sortCompareFunction={sortOnNumber} /

and then create something like:

private function sortOnNumber( obj1:Object, obj2:Object ):int
{
if( obj1[number]  obj2[number] ) {
return -1;
}
else if( obj1[number] 
obj2[number] ) {
return 1;
}
else {
// They are equal so do
another col sort if you want
if( obj1[ID]  obj2[ID] ) {
return -1;
}
else if( obj1[ID] 
obj2[ID] ) {
return 1;
}
else {
return 0;
}
}
}


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

 
 
 Datagrid sort order: is there a natsort() such as in PHP?
 
 
 This is sort order on some strings:
 
 1
 10
 11
 2
 21
 23
 
 This natsort order on the same strings:
 1
 2
 10
 11
 21
 23
 
 In short, it deals sanely with a numeric string suffix.  Anything like
 that in Flash/Flex out-of-the-box?
 
 -- John





[flexcoders] Re: Combobox And Datagrid

2008-04-28 Thread dougco2000
I found success in these cases using dataChange, see
http://blog.dougco.com/coding/flex/datagrid-with-multiple-pulldowns/
for more details.

-d


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

 Hi Friends .. 
 
 I am writting a simple code in which i have one datagrid with two
coloumns . in first coloumn iam using combobox as itemrenderer.
 but this combobox is working abnormally when more and more item are
added to the grid or when scroll bar appears .
 some one told me that this problem is solved in flex 3 but it is not .
 i have compiled and run this code on three version of flex i.e Flex
2.0.1 ,Flex 2.0.1(Hot Fix Three),
 and Flex Three.
 But the application is behaving in different ways in both version .
plz help me to find the problem.
 i am sharing my code with u plz run it and help me
 
 !-- Application.mxml --
 ?xml version=1.0?
 !-- dpcontrols/DataGridSpecifyColumns.mxml --
 mx:Application xmlns:mx=http://www.adobe.com/2006/mxml;
creationComplete={init()}  
 
  
 mx:Script
   ![CDATA[
   import mx.collections.ArrayCollection;  
   [Bindable]
   public var gridDataProvider:ArrayCollection;
   public function init():void
   {
   gridDataProvider = new ArrayCollection();
   var del:Object = new Object();
   del.name = '';
   del.price = '';
   gridDataProvider.addItem( del );
   }
   ]]
 /mx:Script
 mx:DataGrid id=grid selectable=false
dataProvider={gridDataProvider} 
   mx:columns
   mx:DataGridColumn dataField=name 
 itemRenderer=ComboBoxRend/
   mx:DataGridColumn dataField=price /
   
   /mx:columns
 /mx:DataGrid
 
 /mx:Application
 
 !-- ComboBoxRend.mxml--
 ?xml version=1.0 encoding=utf-8?
 mx:ComboBox dataProvider={autoCompProvider} labelField=name
creationComplete={init()} xmlns:mx=http://www.adobe.com/2006/mxml;
width=50 paddingRight=5 paddingLeft=5 xmlns:fc=*
close={closeEventHandler()} 
 mx:Script
   ![CDATA[
   import mx.collections.ArrayCollection;
   import mx.controls.Alert;   
   public function closeEventHandler():void
   {
   data.name = this.selectedLabel ;
   data.price = this.selectedItem.price;
   var emptyRow:Object = new Object();
   emptyRow.name = '';
   emptyRow.price = '';
   ComboboxTest(this.parentApplication).gridDataProvider.addItem(
emptyRow );
   }
   [Bindable]
   public var autoCompProvider:ArrayCollection;
   public function init():void
   {
   autoCompProvider = new ArrayCollection();
   
   var emptyRow:Object = new Object();
   emptyRow.name = '';
   emptyRow.price = '';
   autoCompProvider.addItem( emptyRow );
   
   
   var del:Object = new Object();
   del.name = 'DELL';
   del.price = 100;
   autoCompProvider.addItem( del );
   
   var msft:Object = new Object();
   msft.name = 'MSFT';
   msft.price = 200;
   autoCompProvider.addItem( msft );
 
   var mot:Object = new Object();
   mot.name = 'MOT';
   mot.price = 300;
   autoCompProvider.addItem( mot );
   
 
 
   var yahoo:Object = new Object();
   yahoo.name = 'Yahoo';
   yahoo.price = 400;
   autoCompProvider.addItem( yahoo );
 
 
   
   
   }   
   
 ]]
 /mx:Script
 /mx:ComboBox
 
 
 Thanks Parkash Arjan..





[flexcoders] Re: How to Clear/Reset Item Renderers When the Data Provider Changes?

2008-04-03 Thread dougco2000
I had success with the dataChange event handler, see:

http://blog.dougco.com/coding/flex/datagrid-with-multiple-pulldowns/

--- In flexcoders@yahoogroups.com, Paul Whitelock [EMAIL PROTECTED] wrote:

 After a bit more investigation it appears that it might be a redraw
 issue since the last cell that is clicked is the one where the ghost
 data appears. 
 
 Is there a way to force the DataGrid and all custom renderers to
 redraw? I've tried calling validateNow() on the DataGrid but it did
 not have an effect.
 
 
 
 
 --- In flexcoders@yahoogroups.com, Paul Whitelock paul@ wrote:
 
  I have a single row DataGrid with a typed object bound as a data
  provider. When data is entered in all columns the handler for
  itemEndEvent updates another DataGrid and creates a new empty object
  that replaces the previous data provider for the DataGrid.
  
  Even though the data in the new object that replaces the old data
  provider is empty, the data that was previously entered in the
  DataGrid columns randomly fills one or two of the five columns that
  should be empty (it most often happens with two DateFields that are in
  custom item renderers). Though data appears in the column cell, if you
  try to get the data it comes back as null.
  
  Somehow the DataGrid or the custom item renderer is caching the
  previous data and randomly re-displaying it. I've tried setting the
  DataGrid data provider to null, then attaching the new empty object as
  the data provider, but the ghost data still comes back.
  
  Any ideas how I can clear this old data when I replace the data
  provider for the DataGrid so it doesn't reappear in columns that
  should be empty? Thanks.
 





[flexcoders] Re: How to set the datetime format in datagrid?

2008-04-03 Thread dougco2000
One way to display a human readable date in a datagrid and have it be
sortable, is to use labelFunction={convertDate} and have the server
send over unix milliseconds. This is important if you want to be able
to properly sort the column.

A sample function looks like:

private function convertDate(item:Object, column:DataGridColumn):String {
   var myDate:Date = new Date(item.Date);
   var months:Array = new Array();
   months = [, Jan, Feb, Mar, Apr, May, Jun, Jul,
Aug, Sep, Oct, Nov, Dec];
   var a:Array = new Array();
   var b:Array = new Array();

   a.push(myDate.getMonth());
   a.push(myDate.getUTCDate());
   a.push(myDate.getUTCFullYear());

   b.push(myDate.getUTCHours());
   b.push(myDate.getUTCMinutes());

   if (b[0]10) { b[0] = 0 + b[0] }
   if (b[1]10) { b[1] = 0 + b[1] }

   return months[parseInt(a[0])+1] + + a[1] +   + b.join(:);
} }


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

 Hi,
 
 I have a program the read datetime fields for SQL Server and show in
 datagrid.
 
 I do not know how to set the date format in datagrid
(mx:DataGridColumn),
 
 Please help me.
 
 Please let me know if you have demo link.
 
 Thanks.





[flexcoders] Re: What happens with dataProvider when you sort a List control?

2008-03-31 Thread dougco2000
You might find my posting helpful:
http://blog.dougco.com/coding/flex/datagrid-with-multiple-pulldowns/


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

 Hello, I just found both Flex and this group. So here a newbie problem:
 
 I have a DataGrid (AdvancedDataGrid even) that gets populated from an
 XML source. Selecting an item in the list selects it in another place
 of the application too (let's call it Space) and also some of the
 item's data is shown in a form. Additionally clicking the item in
 Space selects it in the list and that form is populated the same way.
 The way I link from Space to the list is through an id attribute of
 the Space items. Something like so:
 
 list.selectedItem = _xml_source.items.item.(@id==space_item.id);
 
 It all works well until I sort the DataGrid. Then that selection
 expression returns null. I've tried see why in the debugger, but I
 can't see it. What am I missing here?





[flexcoders] Re: Dynamically generated DataGrids having troubles with column width

2008-03-28 Thread dougco2000
I recall having to play around with this when I did this in the past,
just from memory I would suggest you try setting widths after you set
grid.columns by doing grid.columns[0].width = 100, etc. I think it
also would not work exactly if the total widths did not match the
grid, so you could try leaving the last one's width blank so it
auto-sets and see if that makes a difference.

-doug

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

 When DG created by AS and placed into tab navigator, it completely
 ignores its width, why?
 Here is an example:
 
 ?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.controls.dataGridClasses.DataGridColumn;
  import mx.controls.DataGrid;
  import mx.containers.Canvas;
  private function init():void {
  for(var i:int = 0; i  3; i++) {
  var canvas:Canvas = new Canvas();
  var grid:DataGrid = new DataGrid();
  grid.selectable = false;
  canvas.label = Panel2  + i;
  canvas.percentHeight = 100;
  canvas.percentWidth = 100;
  canvas.addChild(grid);
 
  grid.percentHeight = 100;
  grid.percentWidth = 100;
  grid.variableRowHeight = true;
 
  var columns:Array = new Array(new
 DataGridColumn(), new DataGridColumn(), new DataGridColumn());
  var nameColumn:DataGridColumn =
 DataGridColumn(columns[0]);
  nameColumn.dataField = name;
  nameColumn.headerText = Full Name;
  nameColumn.width = 100;
  nameColumn.minWidth = 100;
  var ipColumn:DataGridColumn =
 DataGridColumn(columns[1]);
  ipColumn.headerText = Addresses;
  ipColumn.dataField = addr;
  ipColumn.editable = false;
  ipColumn.wordWrap = true;
  var countColumn:DataGridColumn =
 DataGridColumn(columns[2]);
  countColumn.headerText = Data Count;
  //ipColumn.dataField = devices;
  countColumn.editable = false;
  countColumn.width = 100;
  countColumn.dataField = datac;
 
  grid.columns = columns;
 
  //grid.dataProvider = context_m.devices;
  navigator.addChild(canvas);
  }
  }
  ]]
  /mx:Script
  mx:TabNavigator right=10 left=10 top=60 bottom=40
 id=navigator
  /mx:TabNavigator
 /mx:Application
 
 I expect tabs to be looking identical, what is going on here? Any other
 approaches to achieve desirable result?





[flexcoders] Re: ComboBoxes + Label in ItemRenderer

2008-03-25 Thread dougco2000
You need to move your code that sets the label:

criticite.text = ( resultGravite * resultProbabilite ).toString();

into the doShow() routine since that is where the objects get (re)set
everytime the grid changes.

-doug

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

 Hello,
 
 How could I reference a label with a kind of 'selectedIndex' ?
 It might sound dummy, but I'd like to follow the idea
 (http://blog.dougco.com/category/coding/flex/) used with the
 CBs to apply it to a label...
 The problem is that the result in the label doesn't stay in its right
 place when I scroll the DG.
 
 Thx
 
 Here is the code below :
 
 mx:HBox xmlns:mx=http://www.adobe.com/2006/mxml;
 horizontalScrollPolicy=off  dataChange=gridScrolled()
 mx:Script
 ![CDATA[
   
 import mx.controls.DataGrid;
   
 [Bindable] private var graviteArray:Array = [ 
 { label:N/A, data:0},
 { label:Critique, data:3 },
 { label:Majeur, data:2},
 { label:Mineur, data:1} ];
 [Bindable] private var probabiliteArray:Array = [ 
 { label:N/A, data:0},
 { label:20%, data:1 },
 { label:40%, data:2},
 { label:60%, data:3},
 { label:80%, data:4} ];
 [Bindable] private var resultGravite:int;
 [Bindable] private var dgIndex:int;
   
 private var resultProbabilite:int;
 private var monChoix:String = 000;
   
 
 private function gridScrolled():void{
 if (data != null) { 
   monChoix = data.choix;
   }
   doShow( monChoix ); 
 }
   
 private function doShow(s:String):void{
 var v1:int = parseInt(s.substr(0,1)); 
 var v2:int = parseInt(s.substr(1,1)); 
 var v3:int = parseInt(s.substr(2,1));//? 
 
 gravite.selectedIndex = v1;
 probabilite.selectedIndex = v2;
   
 if ( gravite.selectedIndex == 0 ) { probabilite.enabled = false;
 }else{ probabilite.enabled = true; }
 }
   
 private function resultat():void{
 var n1:int = gravite.selectedIndex; 
 var n2:int = probabilite.selectedIndex; 
 dgIndex = this.parentApplication.dgSpec.selectedIndex;//???do I need
 this??
 var n3:int = dgIndex;//do I need this??
   
 resultGravite = graviteArray[n1].data;
 resultProbabilite = probabiliteArray[n2].data;
   
 data.choix = monChoix = n1.toString() + n2.toString() +
 n3.toString();
 
 criticite.text = ( resultGravite * resultProbabilite ).toString();
   
 doShow( monChoix );
 }
   ]]
 /mx:Script
 
 mx:ComboBox id=gravite width=83 dataProvider={graviteArray}
 change=resultat()/
   
 mx:ComboBox id=probabilite width=70
 dataProvider={probabiliteArray} change=resultat()/
   
 mx:Label id=criticite width=20 fontWeight=bold text=/
 
 /mx:HBox





[flexcoders] Re: Date object and daylight saving - need help

2008-03-24 Thread dougco2000
I have seen this also, I have a server function which sends back to
the client the UNIX time in seconds, and I find that I have to
manually tell the client to do the offset:

var myDate:Date = new Date( unixSecs - (8*60*60*1000) );
since I want the time/date in separate pieces:

a.push(myDate.getMonth());
a.push(myDate.getUTCDate());
a.push(myDate.getUTCFullYear());

b.push(myDate.getUTCHours());
b.push(myDate.getUTCMinutes());

I tried other time methods mentioned in the docs but no luck. This is
in flex2 fyi.

d

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

 Need a quick fix for this problem.
 
 When I print a date object it tell me the tiemzone offset is GMT-0400.
 
 However when I get a date object and call its getTimezoneOffset 
 function I get 5hrs not 4hrs.
 
 The difference is daylight savings and yes I have in my (XPPro) system 
 I have checked to adjust for daylight savings.
 
 The problem this is causing is that some date calcualtions I need to 
 make where I have to adjust for the timezoneoffset are one hour off.
 
 Seems odd to me...
 
 But is there a way to find out the correct current tiemzone offset i.e. 
 the 4 hrs flex prints rather than the 5 hrs it returns from the method 
 call.
 
 tks





[flexcoders] Re: ComboBoxes as ItemRenderer

2008-03-24 Thread dougco2000
My advice is to make the itemrenderer a separate component and use the
dataChange event in that component. I have an example at
http://blog.dougco.com/coding/flex/datagrid-with-multiple-pulldowns/
Hope that helps,

-doug

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

 Hi All !
 
 here is my problem since days :
 
 I have a combobox in a datagrid as an itemrenderer.
 Then another combobox in that same datagrid which is enabled=false.
 And I'd like to turn that combobox enabled to true, once something is
 selected from the first combobox.
 But I can't find out how to access the enabled=false combobox from the
 first one...?
 
 Any help would be greatly appreciated !
 Thx





[flexcoders] Re: Is this normal behaviour for DataGrid ?

2008-03-21 Thread dougco2000
I think you ran into the same thing I did, the datagrid will render
things oddly sometimes, I had to use the dataChange function in my
itemrenderer to get what I wanted.

I go into more detail at
http://blog.dougco.com/coding/flex/doesnt-seem-like-normal-behaviour-for-datagrid/
if that is helpful.

-d

--- In flexcoders@yahoogroups.com, Vaan S Lanko [EMAIL PROTECTED] wrote:

 Hello Flexies, just curious is this normal behaviour or am I doing 
 something stupendously wrong ?
 
 I have recreated this issue in a small project with 2 files,
 
 Service.as AS3 Class file
 
 package
 {
 public class Service
 {
 public function
Service(_name:String,_price:Number,_category:String)
 {
 super();
 this.name = _name;
 this.price = _price;
 this.category = _category;
 }

 public var name:String;
 public var price:Number;
 public var category:String;
}
 }
 
 and the main.mxml
 
 ?xml version=1.0 encoding=utf-8?
 mx:WindowedApplication
 xmlns:mx=http://www.adobe.com/2006/mxml; layout=vertical
 initialize=initData()
 

 mx:Script
 ![CDATA[
 import mx.collections.ArrayCollection;
 private var dataArray:Array = new Array();
 private var testArrayCollection:ArrayCollection = new 
 ArrayCollection();

 private function initData():void
 {
 dataArray.push(new Service(Blah 1,5.5,Cat1));
 dataArray.push(new Service(Blah 2,5.5,Cat1));
 dataArray.push(new Service(Blah 3,5.5,Cat1));
 dataArray.push(new Service(Blah 4,5.5,Cat1));
 }

 private function addToCollection():void
 {
 testArrayCollection.addItem(zomboCombo.selectedItem);
 }

 ]]
 /mx:Script
 mx:DataGrid dataProvider={testArrayCollection}
 mx:columns
 mx:DataGridColumn headerText=name dataField=name/
 mx:DataGridColumn headerText=price dataField=price/
 mx:DataGridColumn headerText=category
dataField=category/
 /mx:columns
 /mx:DataGrid
 mx:ComboBox labelField=name id=zomboCombo 
 dataProvider={dataArray}/mx:ComboBox
 mx:Button label=Add selected click=addToCollection()/

 /mx:WindowedApplication
 
 Run the app, select a Service with the combobox, hit the add 'selected 
 button' a few times (consecutively without changing the combo
selection) 
 and with your mouse hover over the datagrid. Only the last entry will 
 have a mouseover selection highlighted. I dont quite understand this 
 behaviour, can someone enlighten me to what it is i'm doing wrong,
or is 
 it a bug ?
 
 Cheers
 Vaan





[flexcoders] DataGrid setting selectedIndex causes text colors to change

2007-05-17 Thread dougco2000
Hi all,

I am building out a datagrid in AS, and the mx piece is:

mx:DataGrid id=tables dataProvider={gridData}
change=selectTable(event) sortableColumns=true width=100%
height=100% /

Now, when I create the grid, everything shows up great but at the end
of the populating the grid code I have a tables.selectedIndex = 3;
for setting a row by default.

This indeed selects that row, but the text in that row is WHITE now
instead of black! As I click/select other rows, the text there is
fine, but the initially selected row stays white no matter what.

Seems like a bug?

Thanks



[flexcoders] Placing a tooltip

2007-05-14 Thread dougco2000
I'd like to be able to control the placement of a tooltip, i.e. have
it appear to the left of the object. It seems to decide either above
or below the object normally. Anyone develop a way to do this?

thanks



[flexcoders] Loading image and handling IOErrorEvent

2007-05-09 Thread dougco2000
Hi, I am loading in images in a loop as follows:

imgs[j] = new Image();
pict = new Loader();
url = http://mydomain.com/images/test; + j + .jpg;
preq = new URLRequest(url); 
pict.load(preq);
imgs[j].addChild(pict);

and if I close my browser or navigate away during a load, I get a
popup from Flash saying Error #2044: Unhandled IOErrorEvent:.
text=Error #2036: Load Never Completed.

Now, I read another thread and tried using try-catch and also:
pict.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
but these do not help. Also, I think the IOErrorEvent is for
URLLoader, NOT just the standard Loader. The problem there is that
URLLoader doesn't return something I can use as an image and causes a
fault when adding it as a child to an Image.

So, can someone tell me how to use URLLoader to load an image so that
I can properly use IOErrorEvent?

Thanks!!!




[flexcoders] embedding multiple images programmatically

2007-04-27 Thread dougco2000
Hi all,

I have an array of image names (of PNGs on my server), and I want to
load these all up in an object list of images so I can show them when
needed in my application.

I've found an oddity where some of these, sometimes, don't load
properly for whatever reason and are blank when I need to show them.
So I am thinking I should just embed them. But since I have 50+
images, I'd like to run a loop to embed each one, and all the examples
of embedding show doing something like:

[Embed(source=logo.gif)]
[Bindable]
public var imgCls:Class;

and then mapping to an image. I'd rather not fill up my code with 50
separate variable defines, any easy way to iterate through this?

thanks!




[flexcoders] Flex variable for creation date?

2007-04-16 Thread dougco2000
I'm wondering if there is a way to reference a distinguishing variable
for a given app, such as a last-modified or build date? As we're
pushing out new versions of a given app it would be nice to have
something in the lower corner letting the user know the version they
are running without relying on the coder to update a version string
or something.

thanks



[flexcoders] Re: Versioning swf files for bug reporting

2007-04-15 Thread dougco2000
Check In system, ala CVS or SVN... http://www.nongnu.org/cvs/

d

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

 'scuse the ignorant question, but what is a CI system?
 
 --- In flexcoders@yahoogroups.com, bhaq1972 mbhaque@ wrote:
 
  Thanks Johannes. Can you suggest one. At the moment we just take the 
  bin folder generated by Flexbuilder and copy that to our webservers.
  
  what i was thinking was, if flexbuilder could add a build number 
  into the html wrapper, then we could use an ExternalInterface call 
  to extract that number and show it in our flex apps.
  
  
  --- In flexcoders@yahoogroups.com, Johannes Nel johannes.nel@ 
  wrote:
  
   why not get a proper CI system going. that will solve many issues 
  you had
   not even noticed you had.
   
   On 12 Apr 2007 06:49:12 -0700, bhaq1972 mbhaque@ wrote:
   
  Is there anything flexbuilder could generate and place into 
  the html
wrapper 
   
--- In flexcoders@yahoogroups.com flexcoders%
  40yahoogroups.com, Tom
Chiverton tom.chiverton@
   
wrote:

 On Thursday 12 Apr 2007, simonjpalmer wrote:
  Does anyone have a good practice for holding version numbers 
  in
a flex
  swf file for display to the user and magically incrementing 
  them
as
  part of the build process?

 We had ColdFusion generate the HTML wrapper page.
 It looked up the SVN revision and branch/tag information, and 
  put
that in the
 HTML title tag.

 --
 Tom Chiverton
 Helping to preemptively empower B2B portals
 on: http://thefalken.livejournal.com

 

 This email is sent for and on behalf of Halliwells LLP.

 Halliwells LLP is a limited liability partnership registered in
England and Wales under registered number OC307980 whose 
  registered
office address is at St James's Court Brown Street Manchester M2
2JF. A list of members is available for inspection at the
registered office. Any reference to a partner in relation to
Halliwells LLP means a member of Halliwells LLP. Regulated by the
Law Society.

 CONFIDENTIALITY

 This email is intended only for the use of the addressee named
above and may be confidential or legally privileged. If you are 
  not
the addressee you must not read it and must not use any 
  information
contained in nor copy it nor inform any person other than 
  Halliwells
LLP or the addressee of its existence or contents. If you have
received this email in error please delete it and notify 
  Halliwells
LLP IT Department on 0870 365 8008.

 For more information about Halliwells LLP visit 
  www.halliwells.com.

   
 
   
   
   
   
   -- 
   j:pn
   http://www.lennel.org
  
 





[flexcoders] passing variables to Timer handler routine

2007-04-10 Thread dougco2000
Hi all,

If I have an action (like putting up an alert popup, adding a child to
the canvas, etc) that needs to be delayed, it would be great to have a
good old sleep or something prior to the command, but I guess one
has to use Timers.

But since Timer calls a new function, how to best pass along any
objects or strings that it will need, other than have these as global
vars?

I tried something like this, but I can't reference the target as
shown, and you can't pass anything to the resetAlert from the listener.

function myAlert():void{
  var test:String=testing;
  var alertTimer:Timer = new Timer(3000,1);
  alertTimer.addEventListener(TimerEvent.TIMER,resetAlert,false,0,true);
  alertTimer.start();
}

function resetAlert(e:TimerEvent) {
  trace(traced test:+e.target.test);
}

I know it is something easy I'm missing, so thanks!



[flexcoders] passing data to an EventListener

2007-03-29 Thread dougco2000
I'm creating a number of buttons programmatically and I'd like to have
a unique value passed along to a function when each one is clicked.

So if I am doing something like:

for (i=0;i10;i++) {
  b = new Button();
  b.y = offset;
  b.label = click me;
  b.tooltip = button +i;
  b.addEventListener(MouseEvent.CLICK, butSelect);
  addChild(b);
  offset+=20;
}

And I want to have, let's say, i passed along to the butSelect
function, how is that done? I humored myself and tried doing
butSelect(i) but of course the mouseEvent is passed and you're not
allowed to provide any parameters to the function.

Thanks!



[flexcoders] Re: changing states from within a component

2007-02-27 Thread dougco2000
--- In flexcoders@yahoogroups.com, boy_trike [EMAIL PROTECTED] wrote:

 parentApplication.currentState = foobar;
 
 bruce


I've used:

import mx.core.Application;
Application.application.currentState = foobar;