[flexcoders] Re: Null object error on test for null

2010-08-17 Thread Sunil D
Which line does the null pointer error occur on? 

Not that this is you problem, but I always check for null when casting with 
'as'. 

Sunil

--- In flexcoders@yahoogroups.com, Tom McNeer tmcn...@... wrote:

 In the function below, I begin by testing to see if a particular object is
 null (the array of ComboBoxes that represent the children of a Repeater,
 which may or may not exist). The element is defined in MXML, though of
 course it may be null.
 
 But if it *is *null, a null object reference error is thrown. Could someone
 please explain this for me? (SDK 3.5, by the way).
 
 public function handleFilterChange():void{
 if(filterCombo!=null){
 for(var i:int=0;ifilterCombo.length;i++){
 for(var j:int=0;jfilterCombo[i].length;j++){
 var cb:ComboBox = filterCombo[i][j] as
 ComboBox;
 cb.selectedItem=null;
 }
 }
 }
 }
 
 -- 
 Thanks,
 
 Tom
 
 Tom McNeer
 MediumCool
 http://www.mediumcool.com
 1735 Johnson Road NE
 Atlanta, GA 30306
 404.589.0560





[flexcoders] useVirtualLayout not working for simple Image based itemRenderer

2010-03-03 Thread Sunil D
Hi all,

I ran into an issue where my List control was creating an itemRenderer for each 
list item even though useVirtualLayout=true. Not sure if this is a known issue, 
or really even a bug. I found several ways to work around the problem.

The issue seems to be that if I use a simple itemRenderer that extends Image 
(or one that just includes an Image), the layout classes (VerticalLayout and 
TiledLayout, and probably others) are determining how many renderers to use 
based on the renderer's size. But since the Image hasn't been loaded yet, the 
sizes are zero and so it thinks it should create all of the renderers.

The strange thing is that if I just use the Image as a drop-in itemRenderer 
(i.e. set the itemRenderer property to mx.controls.Image this problem doesn't 
happen. Weird.

Below is some simple, contrived code to show the problem (use the profiler, or 
look at the trace statements).

I didn't find this to be a problem with the Halo List. I also tried several 
versions of the Gumbo SDK, with the same results. Sound like a bug or just 
something to be aware of?

Thanks,
Sunil

main app:
?xml version=1.0 encoding=utf-8?
s:Application xmlns:fx=http://ns.adobe.com/mxml/2009; 
   xmlns:s=library://ns.adobe.com/flex/spark 
   xmlns:mx=library://ns.adobe.com/flex/halo
   xmlns:ns=library://ns.adobe.com/flex/mx
   xmlns:local=*
   minWidth=1024 minHeight=768
   creationComplete=onCreationComplete() 

fx:Script
![CDATA[
import mx.collections.ArrayCollection;

[Bindable]
protected var array:ArrayCollection;

protected function onCreationComplete():void
{
var tmp:Array = [];
for (var i:int = 0; i  100; i++)
{
var o:Object = {};
// In my real world case I am using 
different images
o[source] = 
http://www.google.com/intl/en_ALL/images/logo.gif;;
tmp.push(o);
}
array = new ArrayCollection(tmp);
}
]]
/fx:Script

s:List height=50% horizontalCenter=0
useVirtualLayout=true dataProvider={array}
itemRenderer=ThumbnailRenderer/
/s:Application


renderer (ThumbnailRenderer.mxml in the local package)
package
{
import mx.controls.Image;

public class ThumbnailRenderer extends Image
{
public static var count:int = 0;

public function ThumbnailRenderer()
{
super();
count++;
trace(count);
// Setting minHeight/minWidth or including some other 
component
// who's size can readily be determined fixes the 
problem
//minWidth = 40;
//minHeight = 40;
}

override public function set data(value:Object):void
{
super.data = value;
this.source = data.source;
}
}
}





[flexcoders] Re: Change grid font size via actionscript?

2010-03-03 Thread Sunil D
If you want to change a style in Actionscript, you need to use the setStyle 
method:

table.setStyle(fontSize, 12);

Sunil

--- In flexcoders@yahoogroups.com, Raymond Brown silenttr...@... wrote:

 We have a datagrid which we would like to change the fontsize of dynamically. 
 i.e.
 
 mx:DataGrid id=table/
 mx:Button label=+ click=increaseFontSize()/
 
 private function increaseFontSize(): void {
 table.fontSize += 4;
 }
 
 The problem is you can't do something like table.fontSize.  At least it 
 doesn't work for me.  I want to use a function so we can restrict the size 
 increase and decrease in another function.





[flexcoders] Re: A question about stage resizing

2010-02-19 Thread Sunil D
I think you're comparing apples and oranges here.

On the Flex side you're using Canvas inside a ViewStack. I don't have much 
experience w/Flash CS3, but I think it's safe to assume you're not using these 
controls on the CS3 side.

The ViewStack's dimensions will be that of the initial active child (per the 
docs). So when you switch to the larger Canvas, the larger Canvas knows there 
is not enough room and adds the scroll bars.

I can't say what's happening in your second case with CS3, but my guess is that 
the app is being sized to 800x600 and when you switch to the other view the 
stage or the HTML wrapper is not growing... so you need to either size the CS3 
app to 800x950 or build in some logic to add scrollbars when in the larger 
state.

--- In flexcoders@yahoogroups.com, Rohit Sharma rohit.sharma1...@... wrote:

 Hi George,
 
  i) The screen resolution was 1024 * 768 pixels.
 
 ii)  Width is 800 pixels for both the screens. The height increases from 600
 to 950 pixels.
  the 600 px screen looks fine and the 950 px screen comes cropped.
 
 I guess I have answered your questions.
 Looking for some suggestions.
 
 Thanks,
 Rohit
 
 On Fri, Feb 19, 2010 at 8:26 PM, GeorgeB grg_b...@... wrote:
 
 
 
  Hi Rohit,
 
  Let's clear out some few details:
  You say:
 
  1. *The application has two screens , first one being 800 * 600 and
   second one being 800 * 950. In the html file I have provided the
   width and height as 100%. Now, when I move from screen 1 to screen  2, I
  am not seeing a scroll bar. The second screen comes as cropped.
  *
  Q. What is your actual screen resolution at the time? (I mean the one your
  system is setup for?)
 
  2. *First canvas is of height 600 and second canvas
   is of height 950.
  *
  Your screen setup in the first place is *Width* 800pix by *Height* 600pix
  and in the second is *Width* 950pix by *Height* 800pix
 
  So, what is that you think it's happening?
 
  Thanks
 
  George
 
 
  --- In flexcoders@yahoogroups.com, Rohit Sharma rohit.sharma1982@
  wrote:
  
   Hello All,
  
   I have a question about the way stage resizing occurs in flex.
  
   Please consider the two scenarios :-
  
   i) In Flash CS3, I gave my application a stage size of 800 * 950. The
   application has two screens , first one being 800 * 600 and
   second one being 800 * 950. In the html file I have provided the width
   and height as 100%. Now, when I move from screen 1 to screen 2,
   I am not seeing a scroll bar. The second screen comes as cropped.
  
   ii) Whereas in Flex, I provide my application width and height as 100%
  and
   html width and height also as 100%. I am using a viewstack whose
   height and width also is 100% and inside the viewstack I have individual
   canvas for each screens. First canvas is of height 600 and second canvas
   is of height 950. In this case I am able to see scroll bars when I move
   from first screen to second screen.
  
   I am not able to see why its not happening in CS3 whereas its happening
  in
   Flex.
   Looking for some pointers.
  
   Thanks,
   Rohit