[flexcoders] UIComponent.graphics not respecting a grandparent's clipContent

2007-11-26 Thread Erik Price
Hi,

I'm observing some strange behavior regarding the clipContent of a
Canvas as applied to some lines that are programatically drawn via one
of its grandchildren's Sprite.graphics object.  What I am seeing is
that the clipContent property is not respected by its grandchildren
(kids these days have no respect) if the intermediate child is not
outside of the Canvas's boundaries.

A diagram might help me explain this better:

Canvas id=workspace width=200 height=200 clipContent=true
  UIComponent id=drawingLayer width=200 height=200/
/Canvas

If I programatically add children to drawingLayer, and then use
those children's graphics property to draw lines programatically,
the lines will appear outside of workspace.

What is interesting is that if I change the width and height of
drawingLayer to 201 (so that a part of drawingLayer appears
outside the boundaries of workspace), then the
workspace.clipContent is respected and the lines are clipped as
expected.  Unfortunately, I cannot use this as a workaround because
workspace needs its scroll policies set to auto for other reasons,
and having drawingLayer outside of workspace would cause
undesirable scroll bars.

Am I describing a known bug?  (Btw I can post a 20-line sample
application that demonstrates this.)

Thanks in advance!

Erik


Re: [flexcoders] UIComponent.graphics not respecting a grandparent's clipContent

2007-11-26 Thread Erik Price
On Nov 26, 2007 2:29 PM, Daniel Freiman [EMAIL PROTECTED] wrote:

 This is by design.  Flex clipping is expensive (at least relative to not
 clipping), so Flex Containers don't clip unless measurement says they
 should.  Drawing isn't included in measurement.  You can use
 mx_internal::forceClipping but then you're using mx_internal.

Thanks for the response, Dan.  That makes a lot of sense, but it would
be great if the AS3doc for clipContent went into that detail.  I'll
check the bug database to see if it's already been logged and if not,
log it as a docs enhancement.

For anyone else who may run into this problem, I was able to use a
workaround following an approach something like this example:

Script
  private function handleResize(event:ResizeEvent):void
  {
drawingLayerMask.graphics.clear();
drawingLayerMask.graphics.drawRect(0, 0, workspace.width, workspace.height);
  }
/Script

Canvas id=workspace resize=handleResize(event)
  UIComponent id=drawingLayer mask={drawingLayerMask}/
  UIComponent id=drawingLayerMask/
/Canvas

Regards,

Erik


Re: [flexcoders] Parameter passing !! I am shocked

2007-06-07 Thread Erik Price
On 6/7/07, Guido [EMAIL PROTECTED] wrote:
 I'm not really familiar with technical specifications on how AS manages 
 argument references. However, I believe this has more to do with OO Paradigm 
 than with AS.

This is unrelated to the issue at hand.


 On 6/7/07, Jeffry Houser [EMAIL PROTECTED] wrote:
 
  I think you missed his point.
 
  He sent in obj as a parameter to a function. So objParam should be a
  reference to obj; and nulling one should definitely null the other.

Not really true.

I think it is more helpful to think of it this way (most popular
languages use this exact same design):

1. When a parameter is passed to a function or method call, it is
ALWAYS pass-by-value (i.e., makes a copy of it local to the function).
 But the thing being passed/copied is not the actual object itself,
but rather, a pointer or reference to an object.

2. Therefore, if you pass a reference to an object to a function or
method as a parameter, you have a COPY of the reference, but both your
in-function copy AND your out-of-function original both point to the
same object out there on the heap.

3. Therefore, if you set your parameter reference to null, you're
nulling out your local copy of the reference.  But the reference from
outside of the function still exists, and is not set to null (because
only the COPY was set to null).  Therefore, the object will not
magically disappear.

To summarize, you can't set an object to null in the first place.
You can only set references to objects to null.  Therefore, if you
have a reference to object A outside of your function, and a reference
to object A inside of your function, setting one to null does not mean
the other is set to null.

It's all pass by value, just keep in mind it's the REFERENCES that are
getting passed by value (i.e., copied), not the objects themselves.

e


[flexcoders] how to eliminate the grey background of a disabled TileList

2007-06-05 Thread Erik Price
Hi,

Caveat: this question is for a Flex 1.5 app.

Question: How do I prevent the TileList from creating a grey
background color when I set enabled=false ?
backgroundDisabledColor doesn't seem to apply to the selected item.

What I have done so far:  In my app I have a TileList component, whose
background color is normally #FF, that I have disabled by setting
its enabled property to false in the MXML file.  This resulted in
the entire TileList having a grey color over (or under) it, which is
the default behavior for a disabled TileList.  I found the
backgroundDisabledColor and set it to #FF, which ALMOST solves
the problem.  The remaining issue is that the currently selected item
in the TileList still has the grey background.  So, to paint a picture
of what it looks like, my disabled TileList has a white background for
all of the cells except the one that is selected.

Any advice you can provide would be gratefully appreciated.

Erik


Re: [flexcoders] Re: Error: default arguments may not be interspersed with other options

2007-04-30 Thread Erik Price
On 4/30/07, Shailesh Mangal [EMAIL PROTECTED] wrote:
 Thanks Bjorn,

 It certainly worked, So you keep two copies of SDK or is there a way
 to point FlexBuilder to this new version of FlexSDK and delete from
 its original location (/Applications/Adobe Flex Builder 2 Plug-in/Flex
 SDK 2/)

I symlinked the Flex SDK to /usr/local/flex_sdk and added that to my
$PATH, that way I can always change what the symlink is pointing to,
but all of my scripts and configuration can just reference
/usr/local/flex_sdk.

You will probably need to use 'sudo' to create the symlink.  It sounds
like for your setup, you'd need to issue this command:

  sudo ln -s /Applications/Adobe Flex Builder 2 Plug-in/Flex Sdk 2
/usr/local/flex_sdk


e


Re: [flexcoders] Dynamic UI requires view-aware Commands, no?

2007-04-30 Thread Erik Price
On 4/30/07, ben.clinkinbeard [EMAIL PROTECTED] wrote:

 Basically, when the user selects a certain task, I need to attach a
 set of screens to the stage and allow them to begin working. If they
 later choose a different option, I need to remove the existing stack
 and attach the new one.

I don't know enough about Cairngorm to say whether this would work
with that framework, but is this something that States can help you
with?  I.e., databind the states to the user's task selection in the
UI, and add the appropriate children to the display list in that
state?  This would let you keep your view code in the view and not
pollute your command

http://livedocs.adobe.com/flex/2/docs/0924.html#391089

e


Re: [flexcoders] Games in Flex / Apollo?

2007-04-27 Thread Erik Price

On 4/27/07, André Rodrigues Pena [EMAIL PROTECTED] wrote:


I was also considering to develop something for flex-based games. But I
think that, the only reason that could lead someone to do this would be the
AS3 capabilities but now Flash CS3 has come up with this technology, and it
has a bunch of other functionalities to help with gaming.




(True, but Flash CS3 is $699 more than the cost of the Flex SDK.)

e


Re: [flexcoders] Find and replace wih regex?

2007-04-27 Thread Erik Price
On 4/26/07, b_alen [EMAIL PROTECTED] wrote:
 I have a huge XML file with complex DTD. Now I have to parse this into
 something more usable by stripping the redundant tags and modifying
 some of them. I see two options:

 1. Recursivly visit all the nodes and handle them with if statements.
 2. Use RegEx to do some sort of find and replace.

 The second options seems easier and faster if someone can point me in
 the right direction. Or maybe some other ideas?

Just an idea - if your XML is coming from the server, perhaps running
an XSL transformation on the document would be easier and faster.

e


Re: [flexcoders] Re: Module GC question

2007-04-26 Thread Erik Price
On 4/26/07, kyle.vanvranken [EMAIL PROTECTED] wrote:
 UPDATE: So it would seem the hack method of forcing garbage collection
 for my test was actually causing the trouble.

 -
 try {
   new LocalConnection().connect('foo');
   new LocalConnection().connect('foo');
 } catch (e:*) {}
 -

 Without that code it seems to be working nicely now. I've had a test
 app running on my machine now for a bit with a timer every couple
 seconds reloading the simple module and it appears to be working as
 intended now. I don't really understand why forcing GC was causing it
 to eat up more memory then not forcing, but I am sufficiently
 satisfied that it seems to be working.

How are you sure that the hack was actually causing GC?  Is that
documented anywhere?

e


Re: [flexcoders] Re: Inserting data from Flex: FDS vs. HTTPService vs. RemoteObject

2007-04-25 Thread Erik Price
On 4/25/07, Scott Hoff [EMAIL PROTECTED] wrote:

 C or perl.  When people say CGI, do they refer to server side
 scripting in general or do they refer to a specific programming language?

Technically, CGI is a language-agnostic protocol to allow a web server
to communicate with another application on the host (such as a Python
script or a C binary, for example).  But in my experience, when most
people say CGI, they're simply using as a shorthand way of saying
server side programming in general.


e


Re: [flexcoders] Re: Inserting data from Flex: FDS vs. HTTPService vs. RemoteObject

2007-04-25 Thread Erik Price
On 4/25/07, Erik Price [EMAIL PROTECTED] wrote:

 script or a C binary, for example).  But in my experience, when most
 people say CGI, they're simply using as a shorthand way of saying
 server side programming in general.

I should add to that, server side programming in general, using HTTP,
without the use of a remoting framework or other abstraction of HTTP.
 In other words, they mean sending HTTP variables to the server
directly.  AMFPHP, for example, is more advanced than this and thus
doesn't really qualify as CGI (even if the remoting implementation
uses the CGI protocol on some level), since it abstracts the
programmer from the details of HTTP.  Opening a network socket
directly might not make use of HTTP at all, so that doesn't really
qualify as CGI either.

e


Re: [flexcoders] Re: Inserting data from Flex: FDS vs. HTTPService vs. RemoteObject

2007-04-25 Thread Erik Price
On 4/25/07, Scott Hoff [EMAIL PROTECTED] wrote:
 What makes AMFPHP much more advanced? Is that something I should
 just google?

Always google.

But in a nutshell, AMFPHP provides remoting facilities.  This means it
attempts to abstract some of the details of the transport of data
between your Flex application and your server-side code.

http://en.wikipedia.org/wiki/Remoting

e


Re: [flexcoders] A big newbie flex question.

2007-04-25 Thread Erik Price
On 4/25/07, Ian Skinner [EMAIL PROTECTED] wrote:

 So, one has managed to wade through all that exposition, what is a good
 way to do this?  Where do I put the data access logic.  I presume in my

You might want to read up on MVC:
http://en.wikipedia.org/wiki/Model_view_controller

 root application file.  But, if I do that, how do I access it from my
 various view pieces?  How do I connect all the dots?

Your view pieces (components) shouldn't call your data access logic.
 Instead, they should fire (possibly custom) events when the user
does something.  In your Main.mxml, or better yet in a controller
layer of ActionScript classes (see MVC, above), you will write code to
listen for these events and call the data access logic code, which
itself probably belongs in yet another separate layer of ActionScript
classes.

This process of factoring out your application into layers is called
architecture, and there's an infinite number of ways to do it.  When
people recognize a general pattern for doing this, they usually will
construct a framework to facilitate re-use and avoid repetition.  The
Cairngorm framework is an example of this.

e


Re: [flexcoders] How do you Scroll programmatically in a Panel

2007-04-25 Thread Erik Price
On 4/25/07, jensen.axel [EMAIL PROTECTED] wrote:

 but all of that i can eventually figure out... I just need some
 direction on how to scoll in the panel, programmatically...

Set the panel's 'verticalScrollPosition' property when you need to
change the scroll position.

e


Re: [flexcoders] Datagrid scrollbar lag

2007-04-24 Thread Erik Price
On 4/24/07, Austin Kottke [EMAIL PROTECTED] wrote:
 Hi. I've got a datagrid with about 60 rows and 30 columns. Each
 has a custom item renderer that extends a Canvas component.

 The scrollbar that appears is lagging majorly with this set. I've tried
 cacheasBitmap, Implementing
 different dataproviders such as XMLListCollection and other things to
 somewhat speed up the lag-also
 changing framerate. It seems that the scrollbar lag stays.

 Anyone have any ideas on this?

Alex Harui's blog suggests that extending Canvas in a DataGrid's
ItemRenderer is probably not a good idea if you have a lot of visible
cells, because of the overhead that comes with using a container (they
do a lot behind the scenes that you might not really need).  His
recommendation is to extend UIComponent directly and programatically
lay out your view of the item.

e


Re: [flexcoders] Root sprite not responding to MouseEvent ?

2007-04-19 Thread Erik Price
On 4/19/07, Ronnie Liew [EMAIL PROTECTED] wrote:

 the main app is a sprite, it should respond to mouse move right? and
 it does have a child and that is the visible pixel.

 How come it doesn't trace out?

Did you forget to add your Sprite to the Stage?

e


Re: [flexcoders] REPOST - Checkboxes in a DataGrid

2007-04-16 Thread Erik Price
On 4/16/07, zzberthod [EMAIL PROTECTED] wrote:

 I just need to insert graphical elements (ex: MXML checkbox) into the
 list.

 Example:
 - The first column is a checkbox (for selection of the line)
 - The second is the `name' column
 - Third is `date'

 --
 |Select | Name | Date
 --
 | X | Justin | 01/12/07
 | | Martin | 01/15/07
 | X | John | 01/17/07
 --

You can specify an ItemRenderer when you declare your DataGrid's
columns, which can customize the appearance of a column's content.

An example using ItemRenderers:
http://www.cflex.net/showFileDetails.cfm?ObjectID=443ChannelID=1

Once you've played with it, read this for caveats:
http://blogs.adobe.com/aharui/2007/03/thinking_about_item_renderers_1.html

e


Re: [flexcoders] passing variables to Timer handler routine

2007-04-10 Thread Erik Price
On 4/10/07, dougco2000 [EMAIL PROTECTED] wrote:

 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?

Excellent question.  It's answered here:
http://flexblog.faratasystems.com/?p=125

e


Re: [flexcoders] dynamic creation of class

2007-04-09 Thread Erik Price

On 4/8/07, Toby Tremayne [EMAIL PROTECTED] wrote:


Hi all,
I have a method which retrieves an actionscript object, and depending on
the value of one of the keys, converts it into an actionscript class.  The
issue I have is I don't know how to instantiate a class whose name
I can't hard code - can anyone help me with this?

Basically the idea is that if obj.classname = Page  then I need to write
oPage : Page = new Page();  dynamically.  Is there any way to do this in
actionscript?




You can use the getDefinitionByName function to retrieve a reference to a
Class, and then you can create an instance of that class using the new
operator on the Class reference.  The following is a very simplistic
demonstration of how to instantiate the instances, but in practice you will
probably want all of your dynamically-instantiated classes to implement a
common interface, and cast the instantiated objects to that interface, so
that you don't have to write a bunch of conditionals into your code every
time you add a new class:


?xml version=1.0 encoding=utf-8?
mx:Application xmlns:mx=http://www.adobe.com/2006/mxml;
 applicationComplete=appComplete( event );
 mx:Script
   ![CDATA[
 import defaultpckg.MyClass;

 private function appComplete( event : Event ) : void
 {
   var classRef : Class = getDefinitionByName( defaultpckg.MyClass )
as Class;
   var myInstance : MyClass = new classRef() as MyClass;
   myInstance.message = Done;
   myInstance.showMessage();
 }
   ]]
 /mx:Script
/mx:Application


In a separate file, ./defaultpckg/MyClass.as:

package defaultpckg
{

   import mx.controls.Alert;

   public class MyClass
   {
   private var _message : String;

   public function set message( msg : String ) : void
   {
 this._message = msg;
   }

   public function showMessage() : void
   {
 Alert.show( this._message );
   }
   }
}