Re: [flexcoders] reg expression for Password

2009-06-25 Thread Manish Jethani
On Thu, Jun 25, 2009 at 2:39 AM, vin.flexvin.f...@yahoo.com wrote:
 can anybody help me with regexp for password with following specifications

 1) It should contain atleast 8 characters
 2) It should atleast has one uppercase letter and one digit
 3) No special characters

if (s.search(/^[A-Za-z0-9]{8,}$/) == -1
|| s.search(/[A-Z]/) == -1
|| s.search(/[0-9]/) == -1)
throw new Error(Invalid password!);

Manish


Re: [flexcoders] Cross-domain data flow

2009-06-05 Thread Manish Jethani
That's right. The browser will contact YouTube and Flickr directly to
load content from those websites. Only the SWF will be loaded from
your site.

On 6/5/09, steve horvath flexcod...@stevehorvath.com wrote:
 I've got a SWF on my website that loads images and videos from another
 domain.  If a client loads my web page and accesses the images, will the
 traffic be routed through my ISP?

 For instance, myowndomain.com hosts my.swf which loads images from
 youtube and flickr.  Some person on their own ISP accesses my page and
 watches a bunch of videos and images.  I want to make sure that's not
 going to eat up my bandwidth on my ISP.

 My guess is since the SWF is loaded into the client's browser it
 shouldn't go through my domain.  Is this right?

 ascii




 

 --
 Flexcoders Mailing List
 FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
 Alternative FAQ location:
 https://share.acrobat.com/adc/document.do?docid=942dbdc8-e469-446f-b4cf-1e62079f6847
 Search Archives:
 http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo! Groups Links





-- 
Sent from my mobile device


Re: [flexcoders] Closures in ActionScript 3?

2009-06-05 Thread Manish Jethani
On Fri, Jun 5, 2009 at 7:58 PM, Keith Hughittkeith.hugh...@gmail.com wrote:

 Could someone please explain to me how closures work in ActionScript? I am
 attempting to create a set of Flex Form fields, and assign an event-handler
 to each of them, however, it seems that after creation, all of the fields
 have the same event handler.

[...]

Let's take a simple example.

var funcs:Array = [];
for (var i:int = 0; i  5; i++) {
funcs.push(function ():void {
trace(i);
});
}
for each (var f:Function in funcs) {
f();
}

First we push functions into an array. Then we iterate over the array
to call each function. What is the output?

5
5
5
5
5

The value of the variable i is 5. That's what gets printed when each
of the functions is called. It doesn't matter what the value was at
the time you set the function up. Ultimately when they are called, the
value of i is 5.

Now let's see how we can solve that. We want the functions to remember
state. Essentially we want a functor.

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

Since Function is a dynamic class in ActionScript, you can add state
to a Function object without having to extend it.

Here now we modify the above example.

var funcs:Array = [];
for (var i:int = 0; i  5; i++) {
var f0:Function = function ():void {
trace(arguments.callee.index);
};
f0[index] = i;

funcs.push(f0);
}
for each (var f:Function in funcs) {
f();
}

f0 is a Function object that stores the index in an index property.
Later on when the function is called, we pull the value out of the
Function object for processing.

Here's the output:

0
1
2
3
4

If you're a purist, you can also create a class to do this.

class Functor {
private var func:Function;
private var state:Object;
public function Functor(func:Function, state:Object) {
this.func = func;
this.state = state;
}
public function call(... args):* {
return func.apply(state, args);
}
}

And use it like this:

var funcs:Array = [];
for (var i:int = 0; i  5; i++) {
var functor:Functor = new Functor(function ():void {
trace(this.index);
}, {index: i});

funcs.push(functor.call);
}
for each (var f:Function in funcs) {
f();
}

Output:

0
1
2
3
4

Manish


Re: [flexcoders] Delaying Component Load

2009-06-04 Thread Manish Jethani
On Thu, Jun 4, 2009 at 7:21 PM, Jonathan Ackerman
jacker...@latenitelabs.com wrote:

 I have been running into a IUIComponent issue on a component that is
 loading and I have determined that I need to delay the loading of this
 component a second or so.

 The component sits on a canvas with a tab navigator and I want to delay
 the load of this component until the specific tab is clicked on. I was
 thinking that I need to set the show event of the tab to run a function
 that would launch the component but I don't the syntax for doing this.

Is this component inside the TabNavigator? If yes, you have to set the
TabNavigator's creationPolicy property to auto (default) and the
component will be initialized only when the tab is clicked.

If the component is outside the TabNavigator, then you can just add
the component in the change event of the TabNavigator.

  TabNavigator change=someContainer.addChild(new Component1()) /

You can also look at the states feature (AddChild).

Manish


Re: [flexcoders] Re: About how to implement UIComponent

2009-06-04 Thread Manish Jethani
On Wed, Jun 3, 2009 at 11:46 PM, Amy amyblankens...@bellsouth.net wrote:
 --- In flexcoders@yahoogroups.com, Manish Jethani manish.jeth...@... wrote:

 On Wed, Jun 3, 2009 at 10:26 PM, Manish Jethani
 manish.jeth...@... wrote:
  2009/6/3 j2me_soul j2me_s...@...:

    override protected function measure():void{
     this.explicitMinWidth = this.explicitMinHeight = 50;
    }
   }
 
  Here you should set the meauredWidth, measuredHeight, and optionally
  measuredMinWidth and measuredMinHeight (they can be set to the same as
  measuredWidth and measuredHeight respectively).

 I forgot to say how to do the measurement. Here's how I'd do it:

   function measure():void
   {
     measuredWidth = lal.getExplicitOrMeasuredWidth();
     measuredHeight = lal.getExplicitOrMeasuredHeight();
   }

 Do you need to use setActualSize on the label before you measure it?

No.

setActualSize() should be called in updateDisplayList(). That is
called after the measurement phase. The Label object will measure
itself based on the text assigned to it, so it doesn't care what size
you have set on it (for the purpose of measurement).

The Label object's getExplicitOrMeasuredWidth() and
getExplicitOrMeasuredHeight() methods will return the values computed
in its measure() implementation.

Manish


Re: [flexcoders] CuePointEvent missing optional parameters

2009-06-04 Thread Manish Jethani
On Thu, Jun 4, 2009 at 5:33 AM, kris range krisra...@gmail.com wrote:
 I'm using the VideoDisplay class and listening for cue points. I can
 recieve the cue points, check out the name, time, type but cuePoints
 also have an optional parameter value, which doesn't seem to be
 included in this event class. Why this is missing from this event? Do
 I need to access it a different way?

Have you looked at the metadata property and the metadataReceived event?

Manish


Re: [flexcoders] Slider dataTip- is it possibole to have this visibale all the time

2009-06-04 Thread Manish Jethani
On Wed, Jun 3, 2009 at 4:29 PM, jossminker jossmin...@yahoo.com wrote:
 I woudl like to have the datatip for my slider visible at all times, not just 
 when the user is holding down the thumb.

 if this is not possible, then I would at least like the datatip to appear if 
 the user moves the thumb using the arrow keys or by clicking on the track as 
 the way it is at present means it will never be visible to user who are not 
 using the mouse.

I don't think there's any official way of doing this. You can of
course set showDataTip to false and then go ahead and make your own
data tip (use ToolTipManager to display it), which you show and hide
in response to events from the slider.

Manish


Re: [flexcoders] How to addChild with StringValidator?

2009-06-04 Thread Manish Jethani
On Fri, Jun 5, 2009 at 2:12 AM, markflex2007 markflex2...@yahoo.com wrote:

 I try to build a validation class with AS. I extends UIComponent to build the 
 class,but I an not use this.addChild(stVar); because UIComponent only can 
 addChild with DisplayObject.

 which class I can use to take place UIComponent and I can use addChild with 
 validator object?


StringValidator is not a visual component. Why are you trying to add
it using addChild()? You can just store it in an internal array (as
you're doing) and that should be it.

Manish


Re: [flexcoders]Given this string how to keep my RegExp from being greedy

2009-06-04 Thread Manish Jethani
On Fri, Jun 5, 2009 at 4:25 AM, dorkie dork from
dorktowndorkiedorkfromdorkt...@gmail.com wrote:

 My RegExp is being greedy. There are two matches. The regexp is grabbing the
 first span all the way to the last span. How do I prevent it from being
 greedy?

 Given this string:

 Vestibulum span style=text-decoration: underline;aliquet/span
 emleo/em in benim/b span style=text-decoration:
 line-through;viverra/span id lacinia arcu eleifend.

[...]

Normally if you want to make .* non-greedy, you append a ? to it.

Here's something I did with your source string:

var s:String = 'Vestibulum span style=text-decoration:
underline; font:boldaliquet/span emleo/em in benim/b span
 style=text-decoration: line-through;viverra/span id
lacinia arcu eleifend.';

s = 
s.replace(/(span[^]+style=[^]*)text-decoration:\s*underline;?([^]*[^]*)(.*?)(\/span)/g,
$1$2u$3/u$4);

trace(s);

I've made it more strict in terms of how it matches stuff. But you
should be able to modify your original regexp just by appending a ?
to the .*.

Manish


Re: [flexcoders] About how to implement UIComponent

2009-06-03 Thread Manish Jethani
2009/6/3 j2me_soul j2me_s...@163.com:


 Why the label can't be displaied on the srceen?

  public class rectElement extends UIComponent
  {
   private var lal:Label;
   public function rectElement()
   {
    super();
   }

You don't have to write a constructor if all you're going to do it
call the superclass constructor. Just so you know. You can still do it
if you consider it a good practice.

   override protected function createChildren():void{
    if( lal == null ){
 lal = new Label;
 lal.text = Label;
 addChild(lal);
 this.explicitWidth = lal.width;
 this.explicitHeight = lal.height;
    }
   }

Normally a component should not set its own
explicitWidth/explicitHeight. These properties are to be set by the
Flex framework. A component should only calculate its measuredWidth
and measuredHeight, based on its contents. The right place to do that
is the measure() implementation.

   override protected function measure():void{
    this.explicitMinWidth = this.explicitMinHeight = 50;
   }
  }

Here you should set the meauredWidth, measuredHeight, and optionally
measuredMinWidth and measuredMinHeight (they can be set to the same as
measuredWidth and measuredHeight respectively).

 mx:Application xmlns:mx=http://www.adobe.com/2006/mxml; layout=absolute
 mlns:local=*

 local:rectElement 
  /* there is nothing on the screen. Where is the Label ? */
 /local:rectElement
 /mx:Application

Okay, you haven't implemented updateDisplayList(). That's where you
have do the layout. For example, in the following way:

  function updateDisplayList(unscaledWidth:Number,
  unscaledHeight:Number):void
  {
super.updateDisplayList(unscaledWidth, unscaledHeight);

lal.setActualSize(unscaledWidth, unscaledHeight);
  }

Basically your component object is first measured by the framework,
and then it is assigned a size. You have to lay out the contents of
the component based on the allocated size (unscaledWidth and
unscaledHeight).

It is also a good idea to always call the superclass's
createChildren() method at the end of your implementation.

http://manishjethani.com/blog/why-the-superclasss-createchildren-should-be-called-last/

Manish


Re: [flexcoders] About how to implement UIComponent

2009-06-03 Thread Manish Jethani
On Wed, Jun 3, 2009 at 10:26 PM, Manish Jethani
manish.jeth...@gmail.com wrote:
 2009/6/3 j2me_soul j2me_s...@163.com:

   override protected function measure():void{
    this.explicitMinWidth = this.explicitMinHeight = 50;
   }
  }

 Here you should set the meauredWidth, measuredHeight, and optionally
 measuredMinWidth and measuredMinHeight (they can be set to the same as
 measuredWidth and measuredHeight respectively).

I forgot to say how to do the measurement. Here's how I'd do it:

  function measure():void
  {
measuredWidth = lal.getExplicitOrMeasuredWidth();
measuredHeight = lal.getExplicitOrMeasuredHeight();
  }

Manish


Re: [flexcoders] Vertical scroll bar not reseting

2009-06-02 Thread Manish Jethani
On Tue, Jun 2, 2009 at 8:39 AM, al-al :D vin_ke...@yahoo.com wrote:

 I have an application with a ViewStack and binded LinkBar, which has 2 views, 
 a DataGrid on the first, and the Form on the second. Clicking an item in the 
 DataGrid transfers the user to the Form view.

 I have a problem regarding the scroll bar not reseting to its original 
 position, which is at the top most. The Form on the second view is too long 
 for the Canvas it sits on, so naturally it has a scroll bar. So when I click 
 a record from the DataGrid for the first time, the Form view appears just 
 fine, with the scroll bar on top. When I scroll down, navigate to the first 
 view via the LinkBar, and select another record, the Form view appears with 
 the scroll position right where I left it. How do I do this? I have tried 
 using scrollPosition set to 0 but to no effect.

You have to set the second container's verticalScrollPosition to 0 in
the change event of the ViewStack object.

Example:

?xml version=1.0?
mx:Application xmlns:mx=http://www.adobe.com/2006/mxml;
  xmlns=*
  mx:ViewStack width=400 height=400 id=vs
change=vb2.verticalScrollPosition = 0
mx:VBox
  mx:Button click=vs.selectedIndex = 1 label=1 /
/mx:VBox
mx:VBox id=vb2
  mx:Button click=vs.selectedIndex = 0 label=2 height=600 /
/mx:VBox
  /mx:ViewStack
/mx:Application

Manish


Re: [flexcoders] How does one implement IBitmapDrawable

2009-06-02 Thread Manish Jethani
On Tue, Jun 2, 2009 at 7:52 AM, Stephen More stephen.m...@gmail.com wrote:
 The docs do not say much about IBitmapDrawable:
 http://livedocs.adobe.com/flex/3/langref/flash/display/IBitmapDrawable.html

 In your example lets say I create:
    MyUIComponet extends UIComponet

 What method do I need to write in MyUIComponet such that I can respond
 back with an embeded image instead of  the rendering of the children
 of UIComponet when IBitmapDrawable is called ?

IBitmapDrawable is a marker interface. It doesn't actually have any
methods that you can implement.

Basically BitmapData.draw() will just capture the object as it would
appear on the screen. I don't believe that the IBitmapDrawable object
gets any sort of notification when it is being drawn. You can of
course notify it yourself so it can redraw itself a different way
before calling BitmapData.draw().

Manish


Re: [flexcoders] Re: Problem reading XML returned from Webservice

2009-06-02 Thread Manish Jethani
On Tue, Jun 2, 2009 at 12:15 PM, Claudio M. E. Bastos Iorio
selecter...@gmail.com wrote:

 trace(Name:   + myXML..Fund[0].Name); //A term is undefined and has no 
 properties

Okay, I'm no expert in E4X, but apparently you have to qualify with a
namespace if you're using the .. notation.

So this works:

  var ns:Namespace = xml.namespace();
  trace(xml..ns::Fund[0].ns::Name);

But this won't work:

  default xml namespace = xml.namespace();
  trace(xml..Fund[0].Name);

I don't know how to explain that.

Manish


Re: [flexcoders] Drawing the background Issue

2009-06-02 Thread Manish Jethani
2009/6/2 j2me_soul j2me_s...@163.com:

 The code is pretty simple. This is all I am trying to do:
  mx:Script
   ![CDATA[
    private function init():void{
 //var p:Point = new Point(btn1.x, btn1.y);
 //var pg:Point = localToGlobal(p);

var p:Point = new Point(btn1.x, btn1.y);
p = this.localToGlobal(p);
p = btn1.globalToLocal(p);

That works. First you convert from the Application's co-ordinate space
to the global co-ordinate space, and then you convert from there to to
button's local co-ordinate space.

It is of course pointless. You might as well use 0,0 as your x,y co-ordinates.

 with(btn1.graphics){
  clear();
  lineStyle(2, 0xff, 1);
  beginFill(0x123456, 1);
 // globel coordinates doesn't work too
 // drawRect(pg.x, pg.y, btn1.width + 20, btn1.height+ 20);
  drawRect(btn1.x, btn1.y, btn1.width + 20, btn1.height+ 20);
  endFill();
 }

Manish


Re: Re: [flexcoders] Drawing the background Issue

2009-06-02 Thread Manish Jethani
2009/6/2 j2me_soul j2me_s...@163.com:

 drawRect(0, 0, btn1.width + 20, btn1.height+ 20);

 Is the 0,0 point is the ContentPoint of the btn1 ?

No, it's the top-left.

Manish


Re: [flexcoders] How to make FTE text selectable and editable?

2009-06-01 Thread Manish Jethani
Thanks. I was wondering why the FTE components didn't have any option
for making the text selectable and editable, but now it makes sense.

I guess my issue with using TLF is that it adds min. 60-70K to my SWF
size. This is an ActionScript-only project with Flex 3.

I know TLF is part of Flex 4, so I get the benefit of framework
caching, but I just want to use TLF and not the rest of the Flex
framework. Is there an option to get a .swz for just TLF?

Manish

On Tue, Jun 2, 2009 at 12:51 AM, Gordon Smith gosm...@adobe.com wrote:


 That's correct. FTE simply creates TextLines that display text and contain
 information about glyph bounds, etc. All selection and editing must be
 handled in ActionScript. Use have to use TLF or a TLF-based component,
 unless you want to roll your own text editor.



 - Gordon



 From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On
 Behalf Of Alex Harui
 Sent: Monday, June 01, 2009 10:55 AM
 To: flexcoders@yahoogroups.com
 Subject: RE: [flexcoders] How to make FTE text selectable and editable?




 I think you’ll have to use TLF or write your own.  The whole point of FTE is
 to put text on the screen without each text instance needing to carry the
 capabilities of selection and interaction.



 Alex Harui

 Flex SDK Developer

 Adobe Systems Inc.

 Blog: http://blogs.adobe.com/aharui



 From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On
 Behalf Of Manish Jethani
 Sent: Sunday, May 31, 2009 5:18 PM
 To: Flexcoders
 Subject: [flexcoders] How to make FTE text selectable and editable?





 I have this program (Flash Player 10):

 var elementFormat:ElementFormat = new ElementFormat();
 elementFormat.fontSize = 48;
 var textElement:TextElement = new TextElement(Hello,
 world, elementFormat)
 var textBlock:TextBlock = new TextBlock(textElement);
 var textLine:TextLine = textBlock.createTextLine();
 textLine.y = textLine.ascent;
 addChild(textLine);

 How do I make the text selectable and editable?

 (Note: I'm not using the Text Layout Framework.)

 Manish

 




--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Alternative FAQ location: 
https://share.acrobat.com/adc/document.do?docid=942dbdc8-e469-446f-b4cf-1e62079f6847
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo! 
Groups Links

* To visit your group on the web, go to:
http://groups.yahoo.com/group/flexcoders/

* Your email settings:
Individual Email | Traditional

* To change settings online go to:
http://groups.yahoo.com/group/flexcoders/join
(Yahoo! ID required)

* To change settings via email:
mailto:flexcoders-dig...@yahoogroups.com 
mailto:flexcoders-fullfeatu...@yahoogroups.com

* To unsubscribe from this group, send an email to:
flexcoders-unsubscr...@yahoogroups.com

* Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/



Re: [flexcoders] Is this list declining?

2009-06-01 Thread Manish Jethani
Clearly the numbers are going down. This can't be good. We're entering
into a Flex recession.

I propose a stimulus plan. We need to boost the numbers by having a
long discussion about how the numbers are going down. This will make
Flex look good and ensure all our livelihoods (at the cost of employer
time -- but who cares!).

Manish

On Tue, Jun 2, 2009 at 3:17 AM, luvfotography
ygro...@all-digital-links.com wrote:
 Is this list declining?  According to the number of posts, May stats were the 
 lowest since Jan 2006.  It's been slowly declining since March 2008.  Is this 
 because of better resources available?  All the bugs are fixed?  All of us 
 now write better code?
 What's your opinion?
 Message history is shown: http://tech.groups.yahoo.com/group/flexcoders/
 thanks,
 steve





 

 --
 Flexcoders Mailing List
 FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
 Alternative FAQ location: 
 https://share.acrobat.com/adc/document.do?docid=942dbdc8-e469-446f-b4cf-1e62079f6847
 Search Archives: 
 http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo! Groups Links






Re: [flexcoders] Resource bundles and static vars

2009-06-01 Thread Manish Jethani
Try putting a breakpoint in SystemManager's
installCompiledResourceBundles() function. That's where the resource
bundles are set up.

It's possible that your class is being loaded before the resource
bundles are set up, and that's why you're getting null.

Manish

On Tue, Jun 2, 2009 at 5:08 AM, Tim Rowe tim.r...@carsales.com.au wrote:


 I'm trying to resolve an issue whereby we have a heap of structures defined
 in static arrays, and one of the params is a string of text.  Ideally this
 string would come from a resource bundle to allow localization on the
 string.

 The problem is that though I've tried a variety of methods, I cannot get any
 resouce bundle values into this variable.

 Effectively the code I have is
 public static const foo =
 ResourceManager.getInstance().getString('myBundle', 'myKey');
 Although it's a little more glammed up than that (but I've tried it in this
 basic form). In the attempts I've gone as far as to even try having a
 utility class which calls out to a singleton, but even within that singleton
 when accessed via a static all values and ResourceBundles from
 ResourceManager come back as null values.

 None of the other mxml elements seem to have issues reading the same
 resource bundle - when addressed via @Resource(bundle='foo', key='bar') and
 similar they all find the values in the .properties file just fine.
 Unfortunately the nature of these variables makes it highly preferable
 they're left as statics, though it is beginning to appear that might not be
 viable.

 Would anyone have any suggestions on this?  It's not the first time I've had
 this problem, but last time we just gave up trying from memory.  Is it just
 a case that the ResourceBundles aren't loaded and accessable at the time
 statics are initialised, or is there something more simple (or perhaps more
 sinister?) going on?

 Thanks,

 Tim Rowe
 Software Engineer
 carsales.com Ltd

 Level 1, 109 Burwood Road
 Locked Bag 
 Hawthorn VIC 3211

 t: 03 9093 8600 (Reception)
 t: 03 9093 8757 (Direct)
 f: 03 9093 8697


 


Re: [flexcoders] Mx:Http Service Refresh Issue

2009-06-01 Thread Manish Jethani
On Tue, Jun 2, 2009 at 6:12 AM, guess what myworld10...@yahoo.com wrote:

 I have a Flex Data grid Constructed from mx:HttpService

 mx:HTTpService url=somethin.do

 The result is an xml file . I am calling the HttpService on the mxmls 
 creationComplete .
 the First time I call the html file [ the actual flex html ] it works fine . 
 The next time I call it actually does not hit my Controller method. It just 
 populates the data grid from the cache or  shows the same Data .

 if I close the browser and open again it works fine .

You're hitting the browser cache.

How about this:

  mx:HTTpService url=somethin.do?

Manish


Re: [flexcoders] Problem reading XML returned from Webservice

2009-06-01 Thread Manish Jethani
On Tue, Jun 2, 2009 at 2:56 AM, Claudio M. E. Bastos Iorio
selecter...@gmail.com wrote:

 I get an XML like this one from my web service (simplified):

 ListFundsResponse xmlns='http://mydomainname.com/' 
 xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/' 
 xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' 
 xmlns:xsd='http://www.w3.org/2001/XMLSchema'
  ListFundsResult
    Fund
      id1/id
      NameSome Name here/Name
      DescriptionSome description here/Description
    /Fund
  /ListFundsResult
 /ListFundsResponse

 It's supposed that something like this should trace the Name value, right?:

 //code in result function for webservice component
 var lastXML:XML = XML(event.result)
 trace(Name in XML:  + lastXML..Fund[0].Name); //gives me an Error: A term 
 is undefined and has no properties.

You need to use a namespace.

  var ns:Namespace = new Namespace(http://mydomain.com/;);

  trace(lastXML.ns::ListFundsResult);

Or,

  default xml namespace = new Namespace(http://mydomain.com/;);

  trace(lastXML.ListFundsResult);

Manish


[flexcoders] How to make FTE text selectable and editable?

2009-05-31 Thread Manish Jethani
I have this program (Flash Player 10):

var elementFormat:ElementFormat = new ElementFormat();
elementFormat.fontSize = 48;
var textElement:TextElement = new TextElement(Hello,
world, elementFormat)
var textBlock:TextBlock = new TextBlock(textElement);
var textLine:TextLine = textBlock.createTextLine();
textLine.y = textLine.ascent;
addChild(textLine);

How do I make the text selectable and editable?

(Note: I'm not using the Text Layout Framework.)

Manish


Re: [flexcoders] Re: Successive Videos Display

2009-05-28 Thread Manish Jethani
On Thu, May 28, 2009 at 11:50 PM, bharat_1 bharat_00...@yahoo.com wrote:
 Thanks for the suggestion. I have a bit of confusion. What do you mean by 
 load the next one when while one is playing. ActionScript isn't 
 multiothreaded. How can it load the next and play the current at the same 
 time. Or did I not follow whatyou said correctly?

You can call load() on one instance (or many instances) while the
first one is playing.

ActionScript is a programming language, and it has no native support
for threads (it has no native support for events either).

The Flash Player is the runtime. It has support for events, obviously,
through the events API.

The player is able to perform a number of asynchronous tasks in the
background while the application continues to function normally.
Typically for such tasks you'll get progress and complete events.
You don't have to do any multi-threading for such tasks yourself: just
start the task (by calling the load() method on VideoDisplay for
instance) and wait for the events.

Internally the player may be using multiple threads or just a single
thread for these background tasks. It doesn't matter either way. If it
uses a single thread, it'll just loop through these tasks in what can
be called the event loop and perform them little by little on each
iteration, at the same time processing user events as well. So you
continue to get your mouse and keyboard events while the data is still
downloading.

Manish


Re: [flexcoders] keeping aspect ratios of containers

2009-05-28 Thread Manish Jethani
On Fri, May 29, 2009 at 12:42 AM, blc187 blc...@yahoo.com wrote:
 is there an easy way to keep a container at a specific aspect ratio?

 i have an hDividedBox but i want the vbox on the left side to always be twice 
 as high as it is wide.  how can i keep a container at this aspect ratio while 
 having the child on the right in the hDividedBox fill the rest of the space?

I don't know if this works:

 HDividedBox
   Child1 id=child1 width={child1.height / 2} /
   Child2 id=child2 width=100% /
 /

If that doesn't do the trick, you'll have to subclass HDividedBox and
implement updateDisplayList according to these rules.

Manish


Re: [flexcoders] Re: Need Alternative for enterFrame event (Causing Memory leak )

2009-05-28 Thread Manish Jethani
On Fri, May 29, 2009 at 12:40 AM, Dharmendra Chauhan
chauhan_i...@yahoo.com wrote:

 The issue is with callBack ,what is happening is as soon you hide Flex
 application by opening another application(any app)  and then again you
 come  back to  your flex  app , call back  does not work , they are broken.I
 found following related jira for this.

 http://bugs.adobe.com/jira/browse/FP-143

 To  solve this issue , I am re-registering all callBacks on  ENTER_FRAME
 event and issue appears to be solved but this  is leading to  memory leak.

 Neither Activate nor FocusEvent.FOCUS_IN does  serve my purpose , both
 required  a mouse Clk before they dispached.

I thought you'd get 'activate' when the player got focus. You could
try setting the focus back to Flash through JavaScript (I don't
remember how to do this now). You should be getting a focus event on
the HTML/JS side at least.

Manish


Re: [flexcoders] Re: Invoke RemoteObject synchronic

2009-05-28 Thread Manish Jethani
On Thu, May 28, 2009 at 11:28 PM, Laurence MacNeill
lmacne...@comcast.net wrote:

 I think he means he wants to work on the data from within the calling
 function, rather than having to go to a result-handler function to use the
 data?  I didn't know that was possible, but I'm pretty new to Flex, so
 perhaps it's just something I've not yet experienced.

That's not possible. Very annoying at times. The best you can do is to
set up an inline event handler:

  component.loadData();
  component.addEventListener(complete, function (e:*):void {
  // process data
  });

I try to avoid that though in all but the rarest cases. It makes the code messy.

Manish


Re: [flexcoders] popup systemManager not working

2009-05-28 Thread Manish Jethani
On Fri, May 29, 2009 at 12:08 AM, hoz h...@satx.rr.com wrote:

 I added bubbles to true in my custom event, and it worked! OK, so I'm a
 little puzzled b/c I have other custom events going without having to add
 that. I thought Bubbles default was true...

bubbles is false by default.

It's not the popups that's the problem, it's the fact that you're not
listening for the event on the popup object itself.

If you did this:

  popup.addEventListener(...)

... it would work, without bubbles set to true.

Manish


Re: [flexcoders] data binding in textinput ?

2009-05-28 Thread Manish Jethani
On Thu, May 28, 2009 at 11:15 PM, luvfotography
ygro...@all-digital-links.com wrote:
 How do I get databinding to work in textinput?
 In this example below, I have a TextInput defined with the text bound to 
 {userName}, when I run the app, and enter text into the TextInput field, I 
 would like the text entered assigned to the Bindable character string 
 userName, however it is not.  What's the proper way to do this?

  mx:String id=userName{myName.text}/mx:String

MXML rules.

Manish


Re: [flexcoders] String To Date Conversion

2009-05-27 Thread Manish Jethani
On Tue, May 26, 2009 at 6:17 PM, yogesh patel
mailtoyogeshpa...@yahoo.in wrote:

   I have a String like Tue May 26 18:12:55 IST 2009. How to
 convert this string into Date object ?

 var s:String = Tue May 26 18:12:55 IST 2009;
  s = s.replace(/IST/, UTC+0530);
  var d:Date = new Date(Date.parse(s));
  trace(d);

Manish


Re: [flexcoders] Is there a way to pass a parameter into my preloader?

2009-05-27 Thread Manish Jethani
On Tue, May 26, 2009 at 11:49 PM, luvfotography
ygro...@all-digital-links.com wrote:
 I've created a preloader class, and is there a way to pass a parameter into 
 my preloader?


 Here is my application tag:

 mx:Application xmlns:mx=http://www.adobe.com/2006/mxml;
                 applicationComplete=appInit()
                 layout=absolute
                 preloader=com.mysite.preloader.SSProgressBarNoWait

What kind of parameter is this?

I don't see a direct way to pass any parameters. The preloader object
(which is set in your IPreloaderDisplay's preloader property) is a
child of the SystemManager, so you could maybe work your way up to the
SystemManager get the URL parameters from there.

  preloader.parent.loaderInfo.parameters.myParameter.

Manish


Re: [flexcoders] URLLoader + Binary != URLStream

2009-05-27 Thread Manish Jethani
On Wed, May 27, 2009 at 2:14 AM, Stephen More stephen.m...@gmail.com wrote:
 I would think that I could load a swf using either URLLoader or
 URLStream. As it turns out only my URLStream is returning the correct
 data.
 Can anyone provide a fix to the following code that makes URLLoader
 work correctly ?

[...]

Why are you calling writeObject() in the case of the URLLoader? You
should call writeBytes() instead. writeObject() is for objects, not
raw bytes

Manish


Re: [flexcoders] Cause Label to resize after setting text

2009-05-27 Thread Manish Jethani
On Wed, May 27, 2009 at 9:17 AM, Tracy Spratt tr...@nts3rd.com wrote:

[...]


 When a setter function sets the Label’s text property, the label has not
 been resized to fit the new text yet, so I can’t test:

 if (myLabel.width  this.width)

 in the setter


 I have not yet found the right invalidation, or event or override to trigger
 my measure logic.  Any suggestions?

You should try calling validateNow() on the Label object.

Either that, or call your own invalidateDisplayList() and let
updateDisplayList() take care of triggering the effect.

  public function set marqueeText(value:String):void
  {
  if (label.text != value) {
  label.text = value;

  invalidateDisplayList();
  }
  }

  override protected function updateDisplayList(...):void
  {
// do the effect here if necessary
  }

Manish

-- 
www.manishjethani.com




--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Alternative FAQ location: 
https://share.acrobat.com/adc/document.do?docid=942dbdc8-e469-446f-b4cf-1e62079f6847
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo! 
Groups Links

* To visit your group on the web, go to:
http://groups.yahoo.com/group/flexcoders/

* Your email settings:
Individual Email | Traditional

* To change settings online go to:
http://groups.yahoo.com/group/flexcoders/join
(Yahoo! ID required)

* To change settings via email:
mailto:flexcoders-dig...@yahoogroups.com 
mailto:flexcoders-fullfeatu...@yahoogroups.com

* To unsubscribe from this group, send an email to:
flexcoders-unsubscr...@yahoogroups.com

* Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/



Re: [flexcoders] Flex unloading SFW- memory management

2009-05-27 Thread Manish Jethani
On Tue, May 26, 2009 at 6:36 PM, Patrice O p...@keepcore.com wrote:

 I m facing a problem with dynamic loading/unloading of swf. I'm using a
 class mycustomSWFLoader which extends SWFLoader and which use an instance
 of Loader class to load swf files (graphics data) from serialized SWF in
 bytearrays.

 All seem to be ok, I can display any of my swf, but the flash player does
 not free memory (the previous loaded swf) when I load a new swf.

Your SWF has to do a number of things before it can be unloaded:

 1.  Stop any running timers
 2.  Remove any 'enterFrame' event listeners
 3.  Close any open network connections
 4.  Remove any objects added to the stage
 5.  Remove any event listeners from the stage
 6.  Call dispose() on any BitmapData objects
 7.  Stop any sound that's playing and close the stream

Etc.

unloadAndStop() does some of this. But some of it you have to do on
your own. For instance, you'll have to remove any event listeners or
any other references to objects inside your SWF on your own.

I had made an API for this for my entire application.

http://tech.groups.yahoo.com/group/apollocoders/message/2766

Manish

-- 
www.manishjethani.com


Re: [flexcoders] Calling invalidateProperties during validateProperties

2009-05-27 Thread Manish Jethani
I think normally if changing property1 also calls for a change in
property2, that change should happen in the setter for property1. Then
both properties get committed in commitProperties()

If your situation is special and you can't follow that pattern, you
can try a callLater() on invalidateProperties()


On 5/27/09, reflexactions reflexacti...@yahoo.com wrote:
 It seems that if during the validateProperties call,l I change some random
 properties and one of them calls invalidateProperties() in order to complete
 processing during the next commmitProperties() phase, the commitProperties
 never runs.
 This is because at the end of processing the initial validateProperties the
 invalidation flag is cleared so blocking the next commitProperties from
 running.

 Is that right and how to work around it for general properties.


 tks




 

 --
 Flexcoders Mailing List
 FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
 Alternative FAQ location:
 https://share.acrobat.com/adc/document.do?docid=942dbdc8-e469-446f-b4cf-1e62079f6847
 Search Archives:
 http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo! Groups Links





-- 
Sent from my mobile device


Re: [flexcoders] Re: Calling invalidateProperties during validateProperties

2009-05-27 Thread Manish Jethani
On Wed, May 27, 2009 at 11:10 PM, reflexactions reflexacti...@yahoo.com wrote:
 Well an example would be where there say half a dozen related properties that 
 get set, these individualy call invalidateProperties and will then be 
 collectively processed in commitPorperties on the next frame.

 In that processing events are raised to notify changes, however the handlers 
 for those events could lead to other properties being set that in turn will 
 call invalidateProperties which of course fails.

I don't know if dispatching events from commitProperties(), measure(),
updateDisplayList(), etc., is supported. Maybe somebody from the Flex
team can throw some light on this.

I would use callLater() to dispatch that event.

My $0.02.

Manish


Re: [flexcoders] Successive Videos Display

2009-05-27 Thread Manish Jethani
On Wed, May 27, 2009 at 6:20 PM, bharat_1 bharat_00...@yahoo.com wrote:
 My app needs to play multiple videos in succession. Can anyone guide on a 
 good way to buffer the next video while current one is playing?

Perhaps a good way to do this would be to create multiple VideoDisplay
instances with the autoPlay property set to false. Then you call
load() on the next one in the queue while the current one is playing.
When the current one finishes, you swap the new one in place and call
play() on it (and load the next one).

Manish


Re: [flexcoders] Need Alternative for enterFrame event (Causing Memory leak )

2009-05-27 Thread Manish Jethani
On Thu, May 28, 2009 at 1:38 AM, Dharmendra Chauhan
chauhan_i...@yahoo.com wrote:

 Please , suggest some alternative for EnterFrame event which gets fired on 
 set focus event.

activate?

Manish


Re: [flexcoders] Flex Coding Standards

2009-05-24 Thread Manish Jethani
On Sun, May 24, 2009 at 9:41 PM, Sam Lai samuel@gmail.com wrote:
 The conventions/standards/guidelines for Flex SDK are here -
 http://opensource.adobe.com/wiki/display/flexsdk/Coding+Conventions

One of the things the document doesn't mention is the order of the
private, protected, and public definitions in a class.

Here's the order:

 1.  Private properties
 2.  Protected properties
 3.  Public properties
 4.  Public methods
 5.  Protected methods
 6.  Private methods

Manish


Re: [flexcoders] Multiple events dispatched, data lost

2009-05-24 Thread Manish Jethani
On Mon, May 25, 2009 at 12:59 AM, steve horvath
flexcod...@stevehorvath.com wrote:

 I have a function which loops and for each iteration dispatches an event.
 The event handler is inside a new class (AddSourceCommand).  Inside the
 event handler class I am dispatching another event which is being handled by
 a function inside the same class.  There's a variable that originates from
 the initial function, is passed to the first event handler via the event,
 and then passed to the second event handler via the second event.  The
 variable changes each time it is sent to the first event.

 The first event handler is receiving the variable correctly.  (It changes
 each time.)  But for some reason the second event handler always receives
 the last variable sent, every time.

What does flickr.photosets.getPhotos() do? Does it go to the Flickr
server to fetch the data asynchronously?

Obviously you have only one instance of AddSourceCommand in your
program, so you have only one copy of the albumForSource variable. It
retains the reference to the last object that is assigned to it and
that's what you get in configureSource()

Why not call execute() directly on a new instance of AddSourceCommand
each time, instead of have it called through an event?

Manish


Re: [flexcoders] absolute paths for mx:script source

2009-05-22 Thread Manish Jethani
On Fri, May 22, 2009 at 5:32 AM, coder3 rrhu...@hotmail.com wrote:

 I wonder if there is a way to add absolute path to mx:script

 for example, my file is under src/app1/app1.mxml. and the as file is
 src/common/asfile.as

[...]

 i tried to use
        mx:Script source=/common/asfile.as /

 but the error shows: no .../src/app1/common/asfile.as found.

That would be the absolute path on your disk.

For instance:

  mx:Script source=/Users/manish/Code/test/test_script.as /

Manish


Re: [flexcoders] Ctrl click in combobox

2009-05-22 Thread Manish Jethani
On Fri, May 22, 2009 at 5:47 AM, lampei lam...@gmail.com wrote:
 Until recently, I did not know that you could reset the combobox back to the 
 prompt value by ctrl-clicking the value in the combobox dropdown.  However, 
 as most people don't know that this is a possiblity with the combobox, I'm 
 trying to mimic this functionality by setting the selectedIndex to -1 if a 
 person clicks (without the ctrl key) the same value that is already selected.

 I have yet to find the selectedIndexChanged property change to anything 
 other than false when the change event fires, so I'm unable to use that 
 (same for selectedItemChanged).  I tried setting the item under the mouse 
 when itemRollOver fires to a property, then set it to null when 
 itemRollOut fires.  Then when the person clicks, I said if the selectedItem 
 == the value underneath the mouse during itemRollOver, set the selectedIndex 
 = -1, however, the itemRollOut seems to fire before the click event is fired. 
  I've also yet to find where the code is for the ctrl-left click, or what 
 causes that event to fire.


The code is in ListBase.as: the selectItem function (called from
mouseDownHandler).

// allow unselecting via ctrl-click
if (ctrlKey  selectedData[uid])
{
selectionChange = true;
clearSelected(transition);
}

Here's the solution.

 1.  Make a custom class, MyList.

public class MyList extends List
{
override protected function selectItem(item:IListItemRenderer,
shiftKey:Boolean, ctrlKey:Boolean,
transition:Boolean = true):Boolean
{
var index:int = itemRendererToIndex(item);

if (index == selectedIndex)
ctrlKey = true;

return super.selectItem(item, shiftKey, ctrlKey, transition);
}
}

 2.  Use this class as the dropdown in the ComboBox.

  mx:ComboBox id=cb prompt=-- select -- dataProvider={['1', '2', '3']}
dropdownFactory={new ClassFactory(MyList)} /

Tada!

Manish

-- 
www.manishjethani.com


Re: [flexcoders] localized parseFloat

2009-05-22 Thread Manish Jethani
On Fri, May 22, 2009 at 2:14 PM, thomas parquier
mailingli...@web-attitude.fr wrote:

 Couldn't parseFloat() use the SharedResources properties to parse localized
 strings ?

If you intend to parse a string like 1.234,56, I think you'll have
to run it through a NumberFormatter first (1234.56) before you send
it to the parse function.

Manish


Re: [flexcoders] Re: Waiting for Flash Player to connect to the debugger

2009-05-22 Thread Manish Jethani
On Sat, May 23, 2009 at 2:16 AM, a.scavarelli a.scavare...@yahoo.com wrote:
 Hmm, I often get problems like this when, for some reason, another instance 
 of the debugger/player is running. Try making sure you are always closing 
 each instance properly after running your program. Also check out your task 
 manager to see if there are any running in the background.

The command-line debugger (fdb) listens for the player to connect on
port 7935. So on OS X you could run this command to see if another
instance is already listening:

lsof -i | grep 7935

Output:

java  5408 manish6u  IPv6 0x395ba24  0t0  TCP *:7935 (LISTEN)

That most likely is fdb. You can kill it using its PID:

kill -9 5408

I don't know if this'll work for Flex Builder though.

Manish

-- 
www.manishjethani.com


Re: [flexcoders] localized parseFloat

2009-05-22 Thread Manish Jethani
On Sat, May 23, 2009 at 2:52 AM, thomas parquier
mailingli...@web-attitude.fr wrote:

 NumberFormatter input is a number, whereas parsing should occur on strings
 already localized (1 234,56=1234.56).

That's not true. You can pass a string to NumberFormatter.

See this example:

 var nf:NumberFormatter = new NumberFormatter();

  nf.decimalSeparatorFrom = ,;
  nf.thousandsSeparatorFrom = .;
  nf.decimalSeparatorTo = .;
  nf.thousandsSeparatorTo = ;

  var s:String = nf.format(1.234,56);

  trace(s);

  var f:Number = parseFloat(s);

  trace(f);

Manish


Re: [flexcoders] absolute paths for mx:script source

2009-05-22 Thread Manish Jethani
On Sat, May 23, 2009 at 3:45 AM, coder3 rrhu...@hotmail.com wrote:

 is there a way or a key to go to the project root directory relatively?

The Flex compiler (mxmlc) doesn't know about projects. If Flex
Builder has any special variables like ${PROJECT_ROOT} or such
settings, I'm not aware of that.

Manish


Re: [flexcoders] Loading Modules in Separate Application Domains

2009-05-14 Thread Manish Jethani
On Fri, May 15, 2009 at 2:04 AM, colin.shreffler cshreff...@gmail.com wrote:

 ModuleManager.getModule(_url).load(new ApplicationDomain(), 
 SecurityDomain.currentDomain)

 As soon as I do this however, I am getting the following error:

 SWF is not a loadable module

 If I use ModuleManager.getModule(_url).load() it works fine but then I have 
 the issue of each module running in a shared ApplicationDomain which isn't 
 what I want.

It doesn't look like this is supported: you can't load the module in a
separate application domain (which makes me wonder why the option
exists at all).

http://www.mail-archive.com/flexcoders@yahoogroups.com/msg80560.html

Manish


Re: [flexcoders] Dictionary class?

2009-05-11 Thread Manish Jethani
On Mon, May 11, 2009 at 9:41 PM, luvfotography
ygro...@all-digital-links.com wrote:

 What are some good uses for the dictionary class?

 I haven't used it yet, but I'm sure if I knew more, I might. . . .


One of the things I use Dictionary for is for storing weak references
to objects.

http://manishjethani.com/blog/2008/07/31/using-weak-references-in-actionscript-3/

You can see for instance the EffectManager class in the Flex 3
framework uses a Dictionary object to store references to effects.

Manish


Re: [flexcoders] Loader coming back with incorrect dimensions

2009-05-11 Thread Manish Jethani
On Mon, May 11, 2009 at 9:27 PM, Jonathon Stierman
jonat...@wolfmotell.com wrote:

 Has anyone run across a Loader instance incorrectly reporting the
 width/height of the SWF file it is loading?

I think the original width/height of the loaded content is always
available through the LoaderInfo object. If you resize the content,
you might get the new values from the Loader, but the original values
will be available in the LoaderInfo.

Manish


Re: [flexcoders] Embedding for DataGrid

2009-03-14 Thread Manish Jethani
On Sat, Mar 14, 2009 at 12:42 PM, wubac1 wub...@gmail.com wrote:
 Many websites embed Flash/Flex applications for charts, but I don't see 
 embedding for DataGrid.  Given that DataGrid has many usability advantages 
 over HTML-based pagination (my assumption), why is it not used for tables in 
 javascript-based websites?  If I am overlooking any major examples, please 
 provide a link.

There are many Ajax-based data grid components out there, and they
tend to be the natural choice (same environment). Some of the new
websites are also using HTML Canvas for charting -- Wikirank, for
example -- so you'll see fewer and fewer sites using Flash just for
charts as time goes by.

Manish

-- 
Manish Jethani
www.manishjethani.com


Re: [flexcoders] Re: Embedding for DataGrid

2009-03-14 Thread Manish Jethani
You can certainly have a scrollbar in a JavaScript-based data grid.
What's more, the scrollbar actually matches in behavior with the one
you use to scroll the page -- it's the same component. So that
provides a more consistent experience.

Some of the reasons I know that people avoid using Flash:

 1.  It tends to eat focus. (i.e. you can never tab out of a Flash object)
 2.  It doesn't obey the user's preferences with respect to font size and color
 3.  It's too large -- a Flex application just for a DataGrid would be 200+ KB
 4.  Some users don't have Flash Player, for whatever reasons
 5.  They don't have Flash/Flex development skills on the team

Of course, there will be cases where it's desirable to use a Flex
application embedded in the web page just to show a bunch of tabular
data. I'm sure they're out there. Last I remember, the Flex Developer
Center on the Adobe site used to have that.

Manish

On Sun, Mar 15, 2009 at 2:15 AM, wubac1 wub...@gmail.com wrote:
 Manish,

 The javascript-based data grid components don't compare from a usability 
 standpoint (i.e. pagination by button vs. scroll bar).  The Google Reader 
 makes an interesting attempt at a scrollable data grid, but it's still not 
 even close (it lets you scroll a small amount and then hangs for additional 
 loading).  So, while I understand the options exist in javascript, why choose 
 them when Flex provides better usability?  Is it simply a religious issue 
 with regard to web design?

 --- In flexcoders@yahoogroups.com, Manish Jethani manish.jeth...@... wrote:

 On Sat, Mar 14, 2009 at 12:42 PM, wubac1 wub...@... wrote:
  Many websites embed Flash/Flex applications for charts, but I don't see 
  embedding for DataGrid.  Given that DataGrid has many usability advantages 
  over HTML-based pagination (my assumption), why is it not used for tables 
  in javascript-based websites?  If I am overlooking any major examples, 
  please provide a link.

 There are many Ajax-based data grid components out there, and they
 tend to be the natural choice (same environment). Some of the new
 websites are also using HTML Canvas for charting -- Wikirank, for
 example -- so you'll see fewer and fewer sites using Flash just for
 charts as time goes by.

 Manish

 --
 Manish Jethani
 www.manishjethani.com





 

 --
 Flexcoders Mailing List
 FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
 Alternative FAQ location: 
 https://share.acrobat.com/adc/document.do?docid=942dbdc8-e469-446f-b4cf-1e62079f6847
 Search Archives: 
 http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo! Groups Links






Re: [flexcoders] Question from a C developper

2009-03-14 Thread Manish Jethani
You should check out the int, uint, and Number types. The sizes are
predefined in ActionScript 3 and not system dependent (e.g. int is
always 32-bit signed).

Operator overloading is not available. You can create an 'equals'
method and use it like so:

  if (obj1.equals(obj2))
...

You can create a simple class for a structure:

  public class Contact {
public var name:String;
public var address:String;
public var phone:String;
  }

And afterward you can use it like so:

  var contact:Contact = new Contact();

  contact.name = Joe;
  contact.address = Los Angeles;

  addToAddressBook(contact); /* function call */

ActionScript 3 is a pass-by-value language. Everything is passed by
value. When you pass an object reference to a function, the reference
is passed by value -- i.e. the function receives its own copy of the
reference.

If you're thinking of C++ references, this is not it. Think pointers instead.

Just to be clear:

  function foo(ref:Object) {
ref.prop1 = new value;
  }

  var obj:Object = new Object();
  obj.prop1 = old value;

  foo(obj); // modified

  trace(obj.prop1); // prints new value

Lastly, you can convert an int to a Number by simply assigning it.

  var i:int = 10;
  var n:Number = i;

If you're coming straight from a C/C++ background, there's a lot
you'll need to unlearn before you start to get a hang of ActionScript
3. But it's basically in the same family of languages, so you should
have no trouble.

Manish

On Thu, Mar 12, 2009 at 7:57 PM, christophe_jacquelin
christophe_jacque...@yahoo.fr wrote:
 Hello,

 I am a C developper and now I am developing in Action Script. I have 
 questions about ActionScript

 - Is it possible to define a variable as a long ?

 - How to program the overloading of an operator like the equal between 2 
 objects of a same class.

 - What is the equivalent of a structure ?

 - When I call a function with a parameter, did this parameter is modified 
 when I return from this function ?

 - How to convert an int to a Number ?

 Thank you,
 Christophe,



 

 --
 Flexcoders Mailing List
 FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
 Alternative FAQ location: 
 https://share.acrobat.com/adc/document.do?docid=942dbdc8-e469-446f-b4cf-1e62079f6847
 Search Archives: 
 http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo! Groups Links






Re: [flexcoders] Re: opposite of parentDocument

2009-02-08 Thread Manish Jethani
On Sun, Feb 8, 2009 at 3:23 PM, johndoematrix johndoemat...@yahoo.com wrote:
 am a little confused. can you please clarify on that. maybe make it
 clearer. thanks

The way you access objects in an MXML document is by using their IDs.
That's the opposite of 'parentDocument'.

Maybe I misunderstood your question? In that case, it'll be nice if
you could explain with some sample code what you're trying to achieve.

Manish

-- 
Manish Jethani
http://manishjethani.com


Re: [flexcoders] opposite of parentDocument

2009-02-07 Thread Manish Jethani
On Sat, Feb 7, 2009 at 7:26 PM, johndoematrix johndoemat...@yahoo.com wrote:
 hi this is a funny question but am gonna ask it anyway. when i want to
 access anything from a child doc that is in a parent doc in flex i use
 parentDocument, what do i use when i want to say access and array in a
 child doc from a parent doc of that child. in essence i would like to
 know the opposite of parentDocument. thanks

You can access the child directly using its ID (MXML) or whatever
reference you have to the child.

 ParentDoc
   ChildDoc id=childDoc /
 /ParentDoc

Then you can say

 childDoc.someArray

to access the internal array.

You can also get a reference to the child using the getChildAt method.

  this.getChildAt(0).someArray

Manish


Re: [flexcoders] How to instantiate a weak reference

2009-02-03 Thread Manish Jethani
On Tue, Feb 3, 2009 at 11:11 PM, Greg Hess flexeff...@gmail.com wrote:

Objects are all passed by reference, I want to pass a weak reference
 back to callers who request items from the cache, much like the
 internal implementation must do in some way when
 addEventListener(...true) as a weak reference.

 For example:

 public function getItem( id:String ):Item
 {
var item:Item = getItemFromCache(id);
return new WeakReference( item );
 }

 So that anyone who has obtained an item from cache will not prevent
 the object from being garbage collected.



http://manishjethani.com/blog/2008/07/31/using-weak-references-in-actionscript-3/

Manish


Re: [flexcoders] आचार्य अत्रे

2009-01-17 Thread Manish Jethani
2009/1/17 Sefi Ninio sefi.ni...@gmail.com:
 It is better to write messages in english, if you want them answered...

FYI: That is spam, or at least of no relevance to flexcoders.

Manish

 2009/1/17 p...@vin Uttarwar pravinuttar...@gmail.com

 एकदा अत्रे नदिवर नहात होते .
 तेथे कपडे धुनार्या बाई ला त्यांची गम्मत करावी वाटली
 तिने अत्रांच्या मोठ्या पोटा कडे पाहून विचारले
  हा माठ कसा दिला ?
 त्या वर अत्रे म्हणाले .
 माठ नुसता पाहिजे का नळ सकट पाहिजे ?

[...]

-- 
Manish Jethani
mx:Blog source=/dev/random ...
manishjethani.com


Re: [flexcoders] Data Grid with dynamic columns ignoring % width or right style.

2009-01-14 Thread Manish Jethani
On Wed, Jan 14, 2009 at 3:40 PM, Wesley Acheson
wesley.ache...@gmail.com wrote:

 Okay sorry If I wasn't clear enough about it basically the data grid 
 stretches, but not enough to accomidate all columns. Nor even enough to fill 
 the container.  Setting a width of 0 makes the datagrid remember its 
 constraint layout.  Some other intresting factors in my test case if I leave 
 on column not dynamically created specified in the mxml, and replace it with 
 the dynamic columns then it works correctly.

[...]

I've told you what your basic problem is: The DatarGrid's minWidth is
greater than the Panel's width. You could come up with any number of
scenarios in which this happens -- it doesn't matter. If you add a 100
columns to the DataGrid, it will compute its minWidth based on how
much space it thinks it needs. The way to override that is to set the
minWidth explicitly. If you try this with the sample you posted,
you'll see that you get the desired behavior.

  DataGrid minWidth=1 ... /

Manish


Re: [flexcoders] Re: regex

2009-01-14 Thread Manish Jethani
On Wed, Jan 14, 2009 at 2:16 AM, flexaustin flexaus...@yahoo.com wrote:
 Ok, this i killing me. I have down to this:

 \\\name:something\\soemthing\\


 How do I replace \\\ with \\ and all \\ with \.

I'm not sure how you ended up with those backslashes, but here's how
to replace two of those with a single one:

trace(.replace(//g, \\));

Note: You have to escape them in string and regexp literals.

Manish

-- 
Visit me at manishjethani.com


Re: [flexcoders] Httpservice proxy?

2009-01-14 Thread Manish Jethani
On Wed, Jan 14, 2009 at 10:37 PM, Nate Pearson napearso...@yahoo.com wrote:
 I built a small stock widget that accesses
 http://quote.yahoo.com/d/quotes.csv to get the stock information.

 The app works fine on my desktop but when I upload it to our domain it
 doesn't work.

Yes, it looks like they have a crossdomain.xml that won't allow your app.

http://quote.yahoo.com/crossdomain.xml

Manish

-- 
Manish Jethani
mx:Blog source=/dev/random ...
manishjethani.com


Re: [flexcoders] Re: Httpservice proxy?

2009-01-14 Thread Manish Jethani
On Wed, Jan 14, 2009 at 10:53 PM, Nate Pearson napearso...@yahoo.com wrote:
 Ahhh! No way to get around that?

Proxy the calls through your own web service (hosted on your own domain).

Manish

-- 
Manish Jethani
mx:Blog source=/dev/random ...
manishjethani.com


Re: [flexcoders] Custom mouse cursors including the system cursor?

2009-01-14 Thread Manish Jethani
On Tue, Jan 13, 2009 at 12:46 PM, Josh McDonald dzn...@gmail.com wrote:

 I'm wondering how I create a custom mouse cursor that will include the
 system cursor, the way DragManager does with the halo mouse cursors?

Why not just draw the custom cursor next to the system cursor?
CursorManager does Mouse.hide. If you skipped that, you would end up
with a composite cursor.

Maybe CursorManager should have an option for this.

Manish

-- 
Manish Jethani
mx:Blog source=/dev/random ...
manishjethani.com


Re: [flexcoders] regex

2009-01-13 Thread Manish Jethani
On Tue, Jan 13, 2009 at 9:56 AM, flexaustin flexaus...@yahoo.com wrote:
 Does anyone know how to write a regular expression that says find a
 pattern in a String that contains 0 or more letters, numbers, or
 spaces, but not a , (one double quote and a comma).

  [a-z0-9 ]*

That will match 0 or more letters, numbers, or spaces (any combination
of those). Since a double-quote or a comma do not fall in any of these
categories (letters, numbers, or spaces), they won't be matched.

Is that what you're looking for?

Manish

-- 
http://manishjethani.com


Re: [flexcoders] Re: regex

2009-01-13 Thread Manish Jethani
On Tue, Jan 13, 2009 at 8:16 PM, flexaustin flexaus...@yahoo.com wrote:

 So if I have this string (quotes are included in the string):
 name:Big Brown Cow b'(--Foot)'/b,title:hello

 I want to include everything after name: and before ,

var s:String = \name\:\Big Brown Cow
b'(--Foot)'/b\,\title\:\hello\;

var a:Array = s.match(/[^]*:([^,]*)/g);

trace(a[0]);
trace(a[1]);

var s1:String = s.replace(/[^]*:([^,]*),?/g, $1\n);

trace(s1);

Manish

-- 
http://manishjethani.com


Re: [flexcoders] Re: How to create universal event handler?

2009-01-13 Thread Manish Jethani
On Tue, Jan 13, 2009 at 8:09 PM, Dan danijel.arsenov...@gmail.com wrote:

 I think you are right. Since Event is represented by object, I thought
 you could create event handlers in polymorphic manner, just like when
 handling errors, when you write catch(e:MyErrorClass). Such catch
 would also handle MyChildErrorClass error. It seems that this does not
 work with events….

Well, you can use the same event type but with a different class. So
let's say your base event class is MyEvent. The event type is
myEvent. You listen to the event like so:

  someObj.addEventListener(MyEvent.MY_EVENT, myEventHandler);

Your myEventHandler looks like this:

  function myEventHandler(event:MyEvent):void
  {
...
  }

Now, so long as the type of the event object is MyEvent, your
myEventHandler should be able to execute without any problems. So the
author of someObj could write their own event class, say
SomeOtherEvent, like so:

  public class SomeOtherEvent extends MyEvent {
public function SomeOtherEvent(...) {
  super(...);

  // custom properties, etc.
}

// custom properties
  }

And they could dispatch the event:

  someObj.dispatchEvent(new SomeOtherEvent(MyEvent.MY_EVENT, ...));

And your handler, myEventHandler, will be able to handle it perfectly
well. Isn't that what you're looking for?

Manish

-- 
http://manishjethani.com



--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Alternative FAQ location: 
https://share.acrobat.com/adc/document.do?docid=942dbdc8-e469-446f-b4cf-1e62079f6847
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo! 
Groups Links

* To visit your group on the web, go to:
http://groups.yahoo.com/group/flexcoders/

* Your email settings:
Individual Email | Traditional

* To change settings online go to:
http://groups.yahoo.com/group/flexcoders/join
(Yahoo! ID required)

* To change settings via email:
mailto:flexcoders-dig...@yahoogroups.com 
mailto:flexcoders-fullfeatu...@yahoogroups.com

* To unsubscribe from this group, send an email to:
flexcoders-unsubscr...@yahoogroups.com

* Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/



Re: [flexcoders] When to use the include directive?

2009-01-13 Thread Manish Jethani
On Tue, Jan 13, 2009 at 10:19 PM, Nate Beck n...@tldstudio.com wrote:

 I just wanted to ping everyone and get their opinion on something.  Why
 would anyone ever want to use the include directive?  I've recently been
 working on poorly designed project where at the top of every module there is
 an include Header.as statement that has 30 include statements within it.
  To give a datagrid additional functionality, you give it an
 id=myDataGrid, and the include statement takes care of the rest.  It's
 really bad.
 I just don't see a good use for the include statement anymore. In my
 opinion, it just promotes bad programming practices.
 I mean, can't everything be taken care of using OOP methodologies?

The include statement is basically for static includes (compile time).
I agree that using include in AS3 is like using C-style macros in C++
(instead of inline functions, class inheritance, and such). But
sometimes that's just what you need. The Flex framework, for instance,
uses include statements to include common style metadata into various
components.

Manish


Re: [flexcoders] Multiple selection in dataGrid by dragging Mouse with left mouse key

2009-01-12 Thread Manish Jethani
On Sat, Jan 10, 2009 at 11:55 PM, Dharmendra Chauhan
chauhan_i...@yahoo.com wrote:
  Is it possible to select multiple rows in data grid by just
 dragging mouse over It. I know this can we achieved with combination
 of sift key and mouse.

[...]

 Please let me know whether it is possible  in flex or not  and if it
 is possible then please provide me some pointers.

I think you (or someone else) asked this one before and didn't get an
answer. This is possible but non-trivial. You can extend the DataGrid
to override the mouse handling and update the selection accordingly.
The pointer I can give you is the DataGrid source code itself -- look
into that.

Manish

-- 
http://manishjethani.com


Re: [flexcoders] Using dispatchEvent ?

2009-01-12 Thread Manish Jethani
On Mon, Jan 12, 2009 at 11:42 AM, biosmonkey biosmon...@yahoo.com wrote:

 In my main app, I instantiate an instance of this class.  I also
 create an event listener at the application level.

 Here's the problem:

 * If I use dispatchEvent(...) inside MyClass, the event listener in
 the main app never fires (the custom event *is* set to bubble)

To add to Josh's response, I would say the best way to do this is to
listen on the object itself.

obj = new MyClass();
obj.addEventListener(...);

The events don't have to be bubbling then.

Manish


Re: [flexcoders] Tweening VBox or List IndexChangedEvent

2009-01-12 Thread Manish Jethani
On Mon, Jan 12, 2009 at 10:03 PM, kylewburke monk...@monkeyden.com wrote:
 I've implemented a ButtonSkin for CheckBox.  I have several of them in
 a VBox.  I'm trying to tween during the IndexChangedEvent via the
 childIndexChange event, to move the selected CheckBox up to the top.

Well, actually, you can just set moveEffect on the individual children.

e.g.

?xml version=1.0?
mx:Application xmlns:mx=http://www.adobe.com/2006/mxml;
  xmlns=* 
  mx:Script
function doThing() {
vb.setChildIndex(vb.getChildAt(0), 3);
}
  /mx:Script

  mx:Button click=doThing() /

  mx:VBox id=vb
mx:Button label=b1 moveEffect=Move /
mx:Button label=b2 moveEffect=Move /
mx:Button label=b3 moveEffect=Move /
mx:Button label=b4 moveEffect=Move /
  /mx:VBox
/mx:Application

Manish

-- 
http://manishjethani.com


Re: [flexcoders] Re: Using dispatchEvent ?

2009-01-12 Thread Manish Jethani
On Mon, Jan 12, 2009 at 8:59 PM, biosmonkey biosmon...@yahoo.com wrote:

 The dispatched event needs to be heard by any component, anywhere, by
 setting an event listener for it at the application level.  So
 bubbling up to the app is critical.

Since your component has nothing to do with UI, strictly speaking,
making it a UI component (extending DisplayObject) seems like the
wrong thing to do. Event bubbling is typically for UI events; your
event is not a UI event, it's just that you need it to be broadcast
application-wide.

So I would consider making the event dispatcher object available
application-wide, by making it a singleton, for instance, or by making
it a property of the main application. It seems you're already doing
something to that effect -- dispatching off the main application
object.

Manish


Re: [flexcoders] Data Grid with dynamic columns ignoring % width or right style.

2009-01-12 Thread Manish Jethani
On Sun, Jan 11, 2009 at 3:51 AM, wesley.acheson
wesley.ache...@gmail.com wrote:

 I've a problem with the DataGrid ignoring the % width, while using
 Canvas as the parent.  When I dynamically create columns it stretches
 to beyond the origional area.  This behaviour has been reported as a
 bug. http://bugs.adobe.com/jira/browse/SDK-14390.  The workarround
 described in the bug setting the width to 0 works for me in a simple
 test case but doesn't appear to work within my main application.

[...]

 I would like to extend datagrid with a version that doesn't have this
 issue if I can figure out why a fixed width doesn't work.

I've left a reply on the bug:

http://bugs.adobe.com/jira/browse/SDK-14390

Basically your DataGrid's minWidth is too large for the Panel. You can
set the minWidth property to reduce it. By default the measured value
for minWidth is always going to be large enough to accommodate all the
columns.

Manish

-- 
http://manishjethani.com


Re: [flexcoders] How to create universal event handler?

2009-01-12 Thread Manish Jethani
On Mon, Jan 12, 2009 at 11:54 PM, Dan danijel.arsenov...@gmail.com wrote:

 If I do addEventListener(MyEvent.Evt1, handleEvt), I will handle only
 that specific  MyEvent.Evt1 event. I need to be able to handle
 MyEvent.Evt2 and MyChildEvent.Evt1 and my FutureChildEvent.EvtX.
 How can this be achieved?

You have to add a listener for each event type separately.

  obj.addEventListener(foo, commonHandler);
  obj.addEventListener(bar, commonHandler);
  obj.addEventListener(baz, commonHandler);
  ...

There's no shortcut way to listen for all events from an object.

Manish


Re: [flexcoders] Timer Solution

2009-01-12 Thread Manish Jethani
On Mon, Jan 12, 2009 at 11:09 AM, vinod kumar coolvinu1...@ymail.com wrote:
 I want an urgent help. From metadata information i got the frame rate as 15.
 So between every second i want to display the values 1 to 15 using timer.

You can listen for the enterFrame event and do it there.

Manish


Re: [flexcoders] Loading Images Using CSS

2009-01-12 Thread Manish Jethani
On Mon, Jan 12, 2009 at 1:31 AM, Dan Vega danv...@gmail.com wrote:

 main.mxml
 mx:Image id=logo initialize=logo.source =
 StyleManager.getStyleDeclaration('logo').getStyle('source')/

 stylesheet
 .logo {
 source: assets/images/robp/rocketfm_logosmall.png;
 }

 TypeError: Error #1009: Cannot access a property or method of a null object
 reference.

You have to use .logo (as opposed to logo) in your call to
getStyleDeclaration.

Manish

-- 
http://manishjethani.com


Re: [flexcoders]How do I know if a class is on the Application?

2009-01-11 Thread Manish Jethani
On 1/10/09, dorkie dork from dorktown dorkiedorkfromdorkt...@gmail.com wrote:

 I have a class on the application like this:

 managers:MyClass /

 How do I find out inside that class in the constructor if that class is on 
 the Application?

By Application I assume the Flex application (instance of
mx.core.Application). The only way to do this is to walk the parent
chain (parent.parent.parent) until you come across an Application
instance, or null.

  inApplication = false;
  p = this.parent;

  while (p != null) {
if (p is Application) {
  inApplication = true;
  break;
}

p = p.parent;
  }

Your loop will never run, however, since parent will always be null in
the constructor.

Note that checking for Application is different from checking for
stage. The Application may not have been added to the stage when
you're doing this check (even if not in the constructor). So if you
want to check if you're on the stage yet, just check for the stage
property.

onStage = (stage != null);

Manish

-- 
http://manishjethani.com


Re: [flexcoders] Re: Properly remove children

2009-01-07 Thread Manish Jethani
On Wed, Jan 7, 2009 at 4:48 AM, markgoldin_2000
markgoldin_2...@yahoo.com wrote:
 Ok, here what I am getting.
 I have a container that I am adding different forms to at the run
 time. These forms are all based on the same class though.
 So, before I add a new form I am removing current form using:
 container.removeAllChildren();
 each form when created is adding a custom event listener to a parent -
 the container. When a custom event is triggered every form that was
 created (regardless that it was removed after) gets this custom event
 to handle.

When you listen for an event on one of your ancestors, you usually
want to use a weak reference (the last parameter to addEventListener).
That's because your parent doesn't know you're listening on it, so
when you've been removed and discarded, you'll still be around
because of the event listener.

Manish


Re: [flexcoders] Re: Properly remove children

2009-01-07 Thread Manish Jethani
On Wed, Jan 7, 2009 at 8:05 PM, Marco Catunda marco.catu...@gmail.com wrote:
 I have some doubt about weak references at eventListener.

 When I add a eventListener with  weak reference true, the object don't
 get a point/reference to it but what happens with eventListener array after
 removing this object. This array don't has the reference for garbage collect,
 so the garbage collect could collect it, but this object was never removed
 from this eventListner array, wasn't it? That's my question. Is this object
 removed from eventlistener array when weak reference is true?
 Is it feasible to implement it in pure action script or It is a voodoo feature
 for compiler?

It is not a voodoo feature, if I understand what you mean. You can
create your own weak references in ActionScript to understand how it
works. Check out the WeakReference class:

http://manishjethani.com/using-weak-references-in-actionscript-3/

You're right -- when the last reference to the object has been
released, it is no longer in the dictionary, so there is indeed no way
to reach it. This means that the event listener is no longer listed as
listening for the event, so the event dispatcher no longer finds it,
it no longer notifies it of the event.

Manish


Re: [flexcoders] Tree is not correctly updated when dragging and dropping item twice when using XML data provider

2009-01-06 Thread Manish Jethani
On Tue, Dec 30, 2008 at 7:52 PM, Sergey Kovalyov
skovalyov.flexcod...@gmail.com wrote:

[comments inline]

 Steps to reproduce:

 Create an application with the Tree component instance and XMLListCollection
 dataProvider binded to it that contains 5 items:

 private var itemsXML : XML =
  items
   item name=Item 1 isBranch=true /
   item name=Item 2 isBranch=true /
   item name=Item 3 isBranch=true /
   item name=Item 4 isBranch=true /
   item name=Item 5 isBranch=true /
  /items;

 Expand Item 4.
 Drag and drop Item 5 from the root to the Item 4.
 Drag and drop Item 5 from the Item 4 to the root.


 Expected result: Item 5 is deleted from the Item 4 and appears on the root
 in the drop position.

 Actual result: Item 5 actually appears on the root in the drop position, but
 it is not removed from the Item 4, so there are 2 same elements in the
 hierarchy intead of one.

That's a good catch. You're right, it's because of parentMap not
getting updated on the first drag-drop. You'll see that the
HierarchicalCollectionView:collecitonChangeHandler has a call to
updateLength when the event kind is update, but it has been
commented. I suspect that may be the reason for this bug. Anyhow, for
now, here's a workaround:

 Tree ... dragDrop=callLater(doWorkaround) ... /

 function doWorkaround() {
   var e = new CollectionEvent(collectionChange);
   e.kind = update;
   myXMLListCollection.dispatchEvent(e);
 }

See if that works.

This ought to be logged in the Flex bugbase.

Manish


Re: [flexcoders] Tree is not correctly updated when dragging and dropping item twice when using XML data provider

2009-01-06 Thread Manish Jethani
On Tue, Jan 6, 2009 at 10:27 PM, Manish Jethani
manish.jeth...@gmail.com wrote:

  function doWorkaround() {
   var e = new CollectionEvent(collectionChange);
   e.kind = update;

Hey, I meant:

 e.kind = reset;

That'll refresh everything.

   myXMLListCollection.dispatchEvent(e);
  }

Manish


Re: [flexcoders] Spurious truncateToFit behavior when scaling TabNavigator

2009-01-06 Thread Manish Jethani
On Tue, Jan 6, 2009 at 3:30 PM, x77686d
wh...@mitchellsoftwareengineering.com wrote:
 On one of our Flex applications we use scaleX and scaleY at the
 application level to zoom in/out on the whole thing.  That works
 pretty well except for one problem: there's a TabNavigator and we see
 spurious truncateToFit behavior on the tab labels, turning Some Tab
 into Some T..., for example.  I say it's spurious because scaling at
 1.2 and 1.3 works fine, but at 1.25 we get the ellipses.  I haven't
 investigated the root cause but I speculate it's a rounding issue of
 some sort.

 Does anybody know of a good way to get rid of the ellipses?  I see
 that the IUITextField in Button does have truncateToFit but I'm not
 aware of a good way to get at it.  (Could reflection be used?)

It's in mx.core.UITextField.

I don't think you can get rid of it easily or at all.

Manish


Re: [flexcoders] Generating Random key

2009-01-06 Thread Manish Jethani
On Tue, Jan 6, 2009 at 7:42 AM, Josh McDonald dzn...@gmail.com wrote:
 A quick take on it:

Trying to improve on some already neat code...

 function randomLetter() : String
 {
 const noVowels : String = BCDFGHJKLMNPQRSTVWXYZ;
 return noVowels.charAt(Math.round(Math.random() *
 (noVowels.length - 1)));
 }

  return noVowels.charAt(Math.floor(Math.random() * (noVowels.length)));

This gives a fair chance to all letters. With Math.round, B and Z were
being slightly discriminated against.

Manish


Re: [flexcoders] components in modules

2009-01-06 Thread Manish Jethani
On Tue, Jan 6, 2009 at 2:24 AM, rockorgames eguilhe...@gmail.com wrote:

 i have a zip search component.. but only a few modules uses it..
 should i copy the code from the zip component to those modules ? the
 problem is that i would have to change the code in all modules if i
 needed to change something in the zip process

You could consider putting the zip component into an RSL. Before a
module that needs the component is loaded, you load the RSL for the
component in the main application (so it's available for the module
later).

An RSL is basically a SWF that contains a bunch of classes. You can
load the SWF when you need one of the classes. So a component that is
shared between multiple modules could be part of an RSL. (For what
it's worth, the Flex framework is also available as an RSL.)

Manish


Re: [flexcoders] File Size is not same when compiled through mxmlc and flex builder

2009-01-06 Thread Manish Jethani
On Tue, Jan 6, 2009 at 1:01 AM, ilikeflex ilikef...@yahoo.com wrote:

 I think that the file Size is not same when compiled through mxmlc
 and flex builder.
[snip]

 The file size is not same in the above two methods.The ant script
 file compiles with more file size. I know flex builder also uses
 mxmlc to compile the files but how can i see the parameters passed to
 mxmlc through flex builder.

I'm not a big Flex Builder user, but I'm guessing it picks up its
settings from one of them flex-config.xml files.

Manish


Re: [flexcoders] useHandCursor doesn't work when using custom cursors

2009-01-06 Thread Manish Jethani
On Wed, Jan 7, 2009 at 1:47 AM, Aaron Miller
amil...@openbaseinteractive.com wrote:

 I am using custom cursors with CursorManager, but I would like the hand
 cursor to override the default (custom) for some controls similar to the way
 editable text overrides the default cursor with the text indicator. Normally
 I would just set buttonMode=true useHandCursor=true but it doesn't work
 with custom cursors. Is there a built in way to force this behavior, or will
 I have to build a mechanism into my on cursor system with rollOver/rollOut
 events on each of the controls I want a hand cursor on?

There are 2 types of cursors in Flex: system cursors -- the arrow, the
hand, the I-beam, etc. -- and custom cursors. Custom cursors are
really graphics you display in place of the system cursor (which is
hidden) at the current mouse position. There are a number of problems
with this: you don't know when the system cursor has changed from an
arrow to an I-beam, for instance, and it's often hard to keep up with
the current mouse position, so sometimes the custom cursor might lag.
I avoid using custom cursors in my applications for these reasons.

All that said, I think if you want to show the hand cursor
conditionally you'll have to do what you're thinking: switch cursors
on roll over and roll out.

Manish


Re: [flexcoders] Properly remove children

2009-01-06 Thread Manish Jethani
On Wed, Jan 7, 2009 at 12:22 AM, markgoldin_2000
markgoldin_2...@yahoo.com wrote:
 How do I remove children from a container in order to completely
 destroy them? Will removeAllChildren do the job?

To remove an object visually, you'll have to remove it from the
display list by calling removeChild or removeChildAt on its parent.

Your code might still have references to the object. To really make
sure that the object is no longer accessible and therefore eligible
for garbage collection, you'll have to release all references to it.
For example, if a variable myButton which is a private member of your
Applciation points to a Button instance you create somewhere, you'll
have to null out that reference.

  someContainer.removeChild(myButton);
  myButton = null;

Manish


Re: [flexcoders] Re: Properly remove children

2009-01-06 Thread Manish Jethani
On Wed, Jan 7, 2009 at 3:39 AM, markgoldin_2000
markgoldin_2...@yahoo.com wrote:
 I dont really have a name (myButton). Objects are added to a
 container at run-time.

  while (container.numChildren  1)
container.removeChildAt(0);

Or you can use removeAllChildren

Manish


Re: [flexcoders] Re: Properly remove children

2009-01-06 Thread Manish Jethani
On Wed, Jan 7, 2009 at 4:23 AM, markgoldin_2000
markgoldin_2...@yahoo.com wrote:
removeAllChildren
 Yes, that's what I use but I dont see objects being completely
 destroyed.

Define destroyed.

Surely you see them go away?

Manish


Re: [flexcoders] enterState for tabNavigator?

2009-01-05 Thread Manish Jethani
On Mon, Jan 5, 2009 at 10:01 PM, endrone endrone endr...@gmail.com wrote:
 currentStateChange and enterState don't work with a TabNavigator
 They are indeed in the docs, but they don't seem to work.

Are you using the states feature at all? A TabNavigator by itself
won't dispatch these events, unless you're assigning different states
to it.

 creationComplete and initialize only happen once.

Only once per container here. Each tab in the TabNavigator will
dispatch its own initialize event, where you can initialize it.

 With states you can easily init a state with the enterState event.
 I want something similar for the TabNavigator.
 Now I listen for the Change event of the TabNavigator and keep the prevIndex
 in a variable.
 And depending on the index I initialize the TabView.
 Is that a best practice?

It's either the TabNavigator's 'change' (your current method) or its
children's 'initialize'. It's hard to say without knowing more about
the sort of initialization you're doing here.

Manish


Re: [flexcoders] Start

2009-01-05 Thread Manish Jethani
On Sat, Jan 3, 2009 at 5:00 AM, Luis Francisco Hernández Sánchez
luispac...@hotmail.com wrote:
 Hi, I want to start sending messages to others. Thanks.

You have succeeded.

Manish


Re: [flexcoders] Cannot assign arraycollection[i] value to VO variable due to ObjectProxy

2009-01-05 Thread Manish Jethani
On Sat, Jan 3, 2009 at 4:24 AM, jeremysavoy jeremysa...@yahoo.com wrote:

 I have an array collection that is a collection of ContactVO items.
 When I debug and look at the ArrayCollection, each item, [0], [1], etc
 is of type ObjectProxy, and inside each of these there is an object
 that then contains the ContactVO fields. I'm assuming they are
 ObjectProxy because I implemented the fix outlined at the bottom of
 this page:

 http://livedocs.adobe.com/flex/2/langref/flash/events/IEventDispatcher.html

 The problem, is that when I try to assign an item in the
 ArrayCollection directly to a ContactVO object as here:
[snip]

 I then get the following error on the assignment line number (last
 line of code above).

 TypeError: Error #1034: Type Coercion failed: cannot convert
 mx.utils::objectpr...@10eee479 to com.myproject.vo.ContactVO

I don't think I fully understand your problem, but normally in a
situation like this I would use an interface. You would end up with a
ContactProxy that wraps the ContactVO, and both implement the
IContactVO interface.

And if that's overkill, maybe just refer to the ContactVO directly:

 __model.contact = __model.myAC[i].object;

Manish


Re: [flexcoders] enterState for tabNavigator?

2009-01-05 Thread Manish Jethani
On Mon, Jan 5, 2009 at 2:22 PM, endrone endrone endr...@gmail.com wrote:

 when you change a state, there's a enterState dispatched when a new state is
 shown.
 This is very handy for initializing the state.

 But does something similar exist for the tabNavigator? (enterState exists
 for a TabNavigator but doesn't work)
 What if you have several tabs and you want to initialize your tab view when
 changing?
 What are best practices?

There are some state-related events: currentStateChanging,
currentStateChange, enterState. Check the docs. There's also a change
event dispatched by the TabNavigator, and then there's the initialize
and creationComplete events dispatched by the individual child
containers.

Manish

-- 
http://manishjethani.com/


Re: [flexcoders] Java HashMap to ComboBox

2009-01-05 Thread Manish Jethani
On Sun, Jan 4, 2009 at 3:19 AM, Vijay vijay_...@yahoo.com wrote:
 Can someone help me on binding the HashMap data returned by a Remote
 call to the Flex ComboBox? I'm successful in iterating the HashMap
 data inside the ActionScript but I didnt know how to bind the
 key=value pair to a ComboBox

 Code Snippet

[snip]

Do you want to display each key as an item? You'll have to convert the
hash map object into an array.

Manish


Re: [flexcoders] Setting NumericStepper's label?

2009-01-05 Thread Manish Jethani
On Mon, Jan 5, 2009 at 7:08 PM, grimmwerks gr...@grimmwerks.com wrote:

 Both have the fontSize at 12, but for some reason the text in the
 numericStepper isn't bottom aligned:
[snip]

What's throwing it off is the border settings. How about if you moved
the styleName setting from the Text and NumericStepper objects up to
the HBox?

Manish


Re: [flexcoders] enterState for tabNavigator?

2009-01-05 Thread Manish Jethani
On Mon, Jan 5, 2009 at 10:45 PM, endrone endrone endr...@gmail.com wrote:

 It's either the TabNavigator's 'change' (your current method) or its
 children's 'initialize'. It's hard to say without knowing more about the
 sort of initialization you're doing here.

 I'm not using states.
 Assume you have 2 categories who have more or less the same settings.
 When you click a category, you get a dynamic generated settings page.
 You remember the chosen category so you can add dynamically the correct
 components.
 (assume I have different tabs, eg Settings, Content, About)
 If I choose another category, I need to reinitialize that settings page.

 Now it's done with catching the change event.
 Are there other ways?

Okay, I think I understand it better now. So you have different views
for each category. Unless the views really need to be dynamically
generated, you don't have to do it. You could create different views
like CategoryASettings, CategoryBSettings, CategoryAContent,
CategoryBContent, CategoryAAbout, ... and use them in the following
manner:

  TabNavigator
ViewStack label=Settings
  CategoryASettings /
  CategoryBSettings /
  CategoryCSettings /
/ViewStack
ViewStack label=Content
  CategoryAContent /
  CategoryBContent /
  CategoryCContent /
/ViewStack
...
  /TabNavigator

You can combine this with states so that the relevant views are
automatically selected when you switch category. That, I would say, is
the Flex way. But you might have performance concerns here depending
on how many different categories you have ... so think about that.

If you must generate the views dynamically every time a tab is
selected, then I think the change event is the way to go.

Manish


Re: [flexcoders] Re: why I can not dispatchEvent with creationComplete?

2009-01-05 Thread Manish Jethani
On Tue, Jan 6, 2009 at 1:34 AM, markflex2007 markflex2...@yahoo.com wrote:

[snip]
 I have addEventListener in Mediator page, it works for CASE two but
 not work  for CASE one.

 it seems dispatchEvent can not work with creationComplete. why? How to
 fix it.

It works, but your event listener isn't set up at the time the event
is dispatched. If you try listening to your own event, you'll see that
it works:

  mx:Canvas xmlns:mx=http://www.adobe.com/2006/mxml;
  creationComplete=justLogin() loginEvent=trace('login event')
  mx:Metadata
 [Event(name=loginEvent, type=flash.events.Event)]
  /mx:Metadata
  ...

Manish


Re: [flexcoders] Re: ModuleLoader with full url

2009-01-04 Thread Manish Jethani
On Mon, Jan 5, 2009 at 1:30 AM, Don Kerr fusionp...@yahoo.com wrote:

 I'm only using mx:ModuleLoader, so I cannot set a breakpoint on this tag. How 
 do I
 inspect the contents of contentLoader when I'm not using pure 
 actionscript/breakpoint?

You can just open the ModuleManager.as file and set a breakpoint on
line 717 (as reported by the stack trace) in Flex Builder. If you're
using the command line debugger:

  br ModuleManager.as:717

 Strange thing is that I get the error once on first time page load, then on 
 page refresh, it
 works ok and continues to work on all subsequent refreshes. This suggests a 
 client-side
 issue.  May be an issue with my Mac.

I wouldn't rule out the possibility of a Flash Player bug in your
specific environment, although that's not very likely. Still, it seems
strange that contentLoaderInfo is null -- that should never happen.

You could try loading the module in AS3 with a simple Loader and see
if you still get the problem.

  loader = new Loader();
  loader.contentLoaderInfo.addEventListener(complete, completeHandler);
  loader.load(...);

In the completeHandler function, check that loader.contentLoaderInfo
is not null.

Manish

-- 
http://manishjethani.com


Re: [flexcoders] itemRenderer ComboBox

2009-01-03 Thread Manish Jethani
On Sat, Jan 3, 2009 at 1:15 AM, Mike Oliver moli...@corenttech.com wrote:

 Perhaps its because it is an itemEditor, but just tried it and value in the
 editorDataField saves the label string to the Grid, not the 'data' element.

Well, the value property is a little strange indeed. Not to mention
it's also deprecated. Here's what I suggest:

  /* in your item editor */
  public function get myCustomProperty():Object
  {
var item:Object = selectedItem;
if (item == null)
  return null;

return item.data;
  }

  DataGridColumn editorDataField=myCustomProperty ... /

Manish

-- 
http://manishjethani.com


Re: [flexcoders] hideing a tab in a TabNavigator

2009-01-03 Thread Manish Jethani
On Sat, Jan 3, 2009 at 12:15 PM, Tracy Spratt tspr...@lariatinc.com wrote:
 I would use a TabBar whose dataProvider content was dynamically driven, to
 show or hide tabs as desired.  I would have that TabBar drive a Viewstack.

That's another option, but let's not forget that a TabNavigator is
more than just a TabBar + ViewStack. There's the focus
management/handling which you get for free.

Manish


Re: [flexcoders] Creating Asynchronous Classes

2009-01-03 Thread Manish Jethani
On Sat, Jan 3, 2009 at 3:33 AM, nathanpdaniel ndan...@bsi-scs.com wrote:
 Is there a primer on creating asynchronous classes?  I've been
 building an app that runs a CRC32 check on each file (which requires
 looking at every byte of every file).  It doesn't cause issues when the
 files are small text files, but when they're 40mb video files, the app
 hangs till complete.  I want the app to be able to update other things
 while waiting on the CRC32 functionality completes.  Actually, all I
 need is some visual progress indicator (some way to update the
 display).

I once peeked into the source code of this library and thought it
looked promising:

http://blog.generalrelativity.org/?p=29

You should be able to split your CRC32 computation into chunks quite
easily, either with this library, or with something more basic using
just a simple Timer.

Manish

-- 
http://manishjethani.com


Re: [flexcoders] Using Flash Symbols in Flex.

2009-01-03 Thread Manish Jethani
On Sat, Jan 3, 2009 at 10:51 PM, paulgrantgain paulgrantg...@yahoo.com wrote:

 I'm trying to use a Movie Clip that I created in Flash CS4 in Flex. I
 am using Flex builder 3 as my IDE.

 I have read the following blog:

 http://www.gskinner.com/blog/archives/2007/03/using_flash_sym.html

 I can get the first frame of the Movie Clip to display in the Flex
 test application but there is no animation. From what I've read on
 other sites it seems that Flex strips out the time line (correct me if
 i'm wrong).

You should be able to load the animation either by embedding or
loading dynamically (both the methods you're trying). I suspect it's
something to do with the loaded SWF itself. What happens if you call
gotoAndPlay() on the MovieClip object (mc)?

Manish


Re: [flexcoders] ModuleLoader with full url

2009-01-03 Thread Manish Jethani
On Sat, Jan 3, 2009 at 7:17 PM, Don Kerr fusionp...@yahoo.com wrote:
 The very first time my Flex app is opened in the browser, I get this error

 TypeError: Error #1009: Cannot access a property or method of a null object 
 reference. at
 ModuleInfo/completeHandler()[C:\autobuild\3.2.0\frameworks\projects\framework\src\m
 x\modules\ModuleManager.as:717]

So it looks like contentLoaderInfo is null ... which is, like,
impossible. What does event.target point to? You can check that with a
breakpoint. It should be pointing to the contentLoaderInfo itself.

Manish


Re: [flexcoders] ToggleButtonBar with one or more ComboBoxes instead of buttons: How to build it?

2009-01-02 Thread Manish Jethani
On Fri, Jan 2, 2009 at 11:06 PM, Alan Shaw noden...@gmail.com wrote:

 The dataProvider would be like a Tree's, so for example an array where some
 of the elements are leaves (- buttons in the bar) and some are arrays (-
 dropdown lists in the bar) (no deeper arrays, and no folder names).  I want
 the user to be able to choose a single leaf item from the set, either by
 clicking one of the buttons or by choosing an item in one of the dropdown
 lists.

All I can say is that you'll have to extend the NavBar class and
implement something like a ToggleButtonBar that uses ComboBox as a
nav item in a sophisticated way. It's doable. Essentially what
you're looking for is a cross between a MenuBar and a ToggleButtonBar,
so I would draw inspiration from those two components.

Manish

-- 
http://manishjethani.com/


  1   2   3   4   5   6   7   8   9   10   >