Re: [Flashcoders] constructor interpreted?

2011-04-05 Thread Juan Pablo Califano
I think Kevin is referring to JIT (Just In Time) compilation. While it's
true that actionscript source code is always compiled to
platform-independent bytecode, this bytecode still has to be converted into
native code before being run. That's what JIT (basically a compiler embedded
into the virtual machine) does, at runtime.

In some environments, such as .NET if I recall correctly, this happends
upfront. The VM compiles the bytecode to native code, caches it and always
runs the native code. In Java, this happens on demand, I think, but the VM
detects code that is run often, so it caches a native version of it. Last I
heard, the AVM JIT compiles and caches all the native code, except for code
in the constructors (I don't know whether this is up to date, or why are
constructors exceptions to what seems to be the general rule).

Cheers
Juan Pablo Califano

2011/4/5 Kerry Thompson 

> Kevin Newman wrote:
>
> > A long while ago I read that the constructor is interpreted, unlike the
> rest
> > of the class methods, which are compiled. Is that still true?
>
> It depends on what you mean by compiled. All your ActionScript
> compiles down to bytecode, or tokens, that are interpreted at run
> time. The native classes and all their methods (e.g. MovieClip) are
> actually compiled to machine code, which can run many times faster
> than bytecode.
>
> I don't think anything, including a constructor, is actually
> interpreted a character at a time like old-time interpreters (e.g.
> Applesoft Basic in the late '70s). I'm not sure if a constructor is
> handled any differently than the rest of the code, but I don't know
> everything that happens under the hood. Somebody will correct me if
> I'm wrong.
>
> Cordially,
>
> Kerry Thompson
>  ___
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Unique array AS3

2011-01-13 Thread Juan Pablo Califano
No problem!


2011/1/13 natalia Vikhtinskaya 

> THANK YOU AGAIN!!!
>
> 2011/1/13 Juan Pablo Califano :
>  > PS:
> >
> > I mentioned that a random sort was not the best approach.
> >
> > Here's a better way to randomize an array:
> >
> > public static function shuffle(array:Array):void {
> >var tmp:*;
> >var cur:int;
> >var top:int;
> >
> >cur = top = array.length;
> >if(top) {
> >while(--top) {
> >cur = Math.floor(Math.random() * (top + 1));
> >tmp = array[cur];
> >    array[cur] = array[top];
> >array[top] = tmp;
> >}
> >}
> > }
> >
> >
> > 2011/1/13 Juan Pablo Califano 
> >
> >> Try this:
> >>
> >>  function uniqueRandomInt(min:Number, max:Number, n:Number) {
> >>  var a:Array = [];
> >>  var i:Number = min;
> >>  while (a.push(i++) >>  a.sort(function (a:Number, b:Number) {
> >>   return Math.floor(Math.random()*3)-1;
> >>
> >>  });
> >>  return a.slice(0,n);
> >> }
> >>
> >> Although a random sort is not the best means to randomize an array, it
> >> should work reasonably.
> >>
> >> The problem with your code was this line:
> >>
> >> Math.random()*2-1;
> >>
> >> Your sort function should return 3 diferent values (n < 1, n = 0 and; n
> >
> >> 0) as evenly distributed as possible. Math.random gives you a number
> that
> >> is great or equal to 0 and *less* than 1. It will not give you 1 back
> >> (0.9, but not 1).
> >>
> >> So if you do:
> >>
> >> Math.random() * 2
> >>
> >> You'll either get 0 or 1 (with decimals); it's not posibble to get 2.
> You
> >> should instead use 3 as the multiplier and floor it; the result should
> be 0,
> >> 1 or 2 (this will have as much randomness as Math.random provides). Now
> >> substract 1 and you'll get -1, 0 or 1, which is what you want for your
> sort
> >> function.
> >>
> >>
> >> Cheers
> >> Juan Pablo Califano
> >> 2011/1/13 natalia Vikhtinskaya 
> >>
> >> Hi
> >>> I use function that creates unique array
> >>>
> >>> function uniqueRandomInt(min:Number, max:Number, n:Number) {
> >>>var a:Array = [];
> >>>var i:Number = min;
> >>>while (a.push(i++) >>>;
> >>>}
> >>>a.sort(function (a:Number, b:Number) { return
> >>> Math.random()*2-1;});
> >>>return a.slice(0, n);
> >>>}
> >>>
> >>> It works fine for AS2. But for AS3 it gives always the same result
> >>> if I ask
> >>> uniqueRandomInt(1, 6, 6); I always get 4,2,3,1,5,6
> >>>
> >>> What is wrong in this code for AS3?
> >>>
> >>> Thank you in andvance.
> >>> ___
> >>> Flashcoders mailing list
> >>> Flashcoders@chattyfig.figleaf.com
> >>> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
> >>>
> >>
> >>
> > ___
> > Flashcoders mailing list
> > Flashcoders@chattyfig.figleaf.com
> > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
> >
>
> ___
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Unique array AS3

2011-01-13 Thread Juan Pablo Califano
PS:

I mentioned that a random sort was not the best approach.

Here's a better way to randomize an array:

public static function shuffle(array:Array):void {
var tmp:*;
var cur:int;
var top:int;

cur = top = array.length;
if(top) {
while(--top) {
cur = Math.floor(Math.random() * (top + 1));
tmp = array[cur];
array[cur] = array[top];
array[top] = tmp;
}
}
}


2011/1/13 Juan Pablo Califano 

> Try this:
>
>  function uniqueRandomInt(min:Number, max:Number, n:Number) {
>  var a:Array = [];
>  var i:Number = min;
>  while (a.push(i++)  a.sort(function (a:Number, b:Number) {
>   return Math.floor(Math.random()*3)-1;
>
>  });
>  return a.slice(0,n);
> }
>
> Although a random sort is not the best means to randomize an array, it
> should work reasonably.
>
> The problem with your code was this line:
>
> Math.random()*2-1;
>
> Your sort function should return 3 diferent values (n < 1, n = 0 and; n >
> 0) as evenly distributed as possible. Math.random gives you a number that
> is great or equal to 0 and *less* than 1. It will not give you 1 back
> (0.9, but not 1).
>
> So if you do:
>
> Math.random() * 2
>
> You'll either get 0 or 1 (with decimals); it's not posibble to get 2. You
> should instead use 3 as the multiplier and floor it; the result should be 0,
> 1 or 2 (this will have as much randomness as Math.random provides). Now
> substract 1 and you'll get -1, 0 or 1, which is what you want for your sort
> function.
>
>
> Cheers
> Juan Pablo Califano
> 2011/1/13 natalia Vikhtinskaya 
>
> Hi
>> I use function that creates unique array
>>
>> function uniqueRandomInt(min:Number, max:Number, n:Number) {
>>var a:Array = [];
>>var i:Number = min;
>>while (a.push(i++)>;
>>}
>>a.sort(function (a:Number, b:Number) { return
>> Math.random()*2-1;});
>>return a.slice(0, n);
>>}
>>
>> It works fine for AS2. But for AS3 it gives always the same result
>> if I ask
>> uniqueRandomInt(1, 6, 6); I always get 4,2,3,1,5,6
>>
>> What is wrong in this code for AS3?
>>
>> Thank you in andvance.
>> ___
>> Flashcoders mailing list
>> Flashcoders@chattyfig.figleaf.com
>> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>>
>
>
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Unique array AS3

2011-01-13 Thread Juan Pablo Califano
Try this:

function uniqueRandomInt(min:Number, max:Number, n:Number) {
 var a:Array = [];
 var i:Number = min;
 while (a.push(i++) 0)
as evenly distributed as possible. Math.random gives you a number that
is great or equal to 0 and *less* than 1. It will not give you 1 back
(0.9, but not 1).

So if you do:

Math.random() * 2

You'll either get 0 or 1 (with decimals); it's not posibble to get 2. You
should instead use 3 as the multiplier and floor it; the result should be 0,
1 or 2 (this will have as much randomness as Math.random provides). Now
substract 1 and you'll get -1, 0 or 1, which is what you want for your sort
function.


Cheers
Juan Pablo Califano
2011/1/13 natalia Vikhtinskaya 

> Hi
> I use function that creates unique array
>
> function uniqueRandomInt(min:Number, max:Number, n:Number) {
>var a:Array = [];
>var i:Number = min;
>while (a.push(i++);
>}
>a.sort(function (a:Number, b:Number) { return
> Math.random()*2-1;});
>return a.slice(0, n);
>}
>
> It works fine for AS2. But for AS3 it gives always the same result
> if I ask
> uniqueRandomInt(1, 6, 6); I always get 4,2,3,1,5,6
>
> What is wrong in this code for AS3?
>
> Thank you in andvance.
> ___
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Automagically create an interface from a given AS3 class?

2010-12-20 Thread Juan Pablo Califano
This is usually called "extract interface". In some languages like Java,
there are a number of tools that let you do this; Eclipse comes with this
refactor, for instance.

http://www.javalobby.org/java/forums/t19062.html

I know this isn't the answer to your question because you obviously need it
for Actiosncript code, but maybe knowing the common name can help
you narrowing you search (for what is worth, I'm not aware of any tool that
offers this feature for AS).


Cheers
Juan Pablo Califano

2010/12/20 Matt Perkins 

> So this is me being extremely lazy - is there a tool or a feature of a tool
> that'll automatically create an interface from a class file?
>
> I'm learning DI and implementing it in a framework that I have and to
> "properly" follow DI principals, I need to make heavy use of interfaces as
> types rather than the classes. I have a good list of interfaces to create.
>
> Thanks!
>
> Matt Perkins
> -
> http://www.nudoru.com
> http://udon.nudoru.com
> ___
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] RE: swf not compiling

2010-12-12 Thread Juan Pablo Califano
You've got a point. I read (but I don't know this first hand) that CS4 uses
the SDK compiler. Maybe it's a modified version to accomodate the IDE needs
(compiling graphics and other assets that the SDK doesn't have to deal with:
think moviclips with their timelines, animations, shapes, etc). Probably it
uses mxmlc as a backend to compile Actionscript to bytecode or something
like that. At the same time, I think it's fair to reckon that the IDE
generally has more stuff to compile than FB in the typical project (again,
graphical assets, encoding audio, etc). Too bad what you mention about the
IDE team; I'm tempted to say that it shows, though.

Cheers
Juan Pablo Califano



2010/12/12 Merrill, Jason 

> >> However, CS4 uses the Flex SDK Java compiler and I'm sure CS5 does too,
> so I guess it's probably not a compiler issue
>
> I would disagree. The Flashbuilder (Flex) compiler and the Flash
> Professional compiler are not one and the same. I also don't see how it's
> NOT a compiler issue when compiling with Flash Pro takes 10x longer than it
> does with the same exact project using the Flex or mxmlc compiler.
>
> I spent some time talking to some of the Adobe Flash Professional engineers
> at Adobe Max, and I was asking them about the code editor. When I started
> talking about other Actionscript editors out there, they looked at me like I
> was from the moon. They had never heard of FlashDevelop and some of the
> other tools out there for Actionscript. Their manager - the guy who manages
> Flash Pro development, seemed rather smug and uninterested.  Over the past
> several years, it seems the best and the brightest at Adobe might have
> migrated to Flashbuilder, the Flash player platform team, Catalyst,
> whatever.  I dunno, that was just my impression - and only from talking to a
> few of them. It's a great tool overall, I just wish the compiler had kept up
> with it.  Needs a major overhaul.
>
>  Jason Merrill
>  Instructional Technology Architect
>  Bank of America  Global Learning
>
>
>
>
>
> ___
>
>
> -Original Message-
> From: flashcoders-boun...@chattyfig.figleaf.com [mailto:
> flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Juan Pablo
> Califano
> Sent: Friday, December 10, 2010 5:11 PM
> To: Flash Coders List
> Subject: Re: [Flashcoders] RE: swf not compiling
>
> I know this doesn't add any value to the problem discussed here, but if you
> don't mind this little rant, I'd like to point out that the Flash IDE has
> gotten worse with every major release (to me at least).
>
> And I haven't tried CS5 yet. Seriously, the last usable one was probably
> Flash 8. Thank godness, I use the IDE very sparingly and somehow got used to
> the asinine way CS3 handles panels; CS4 impressed me as even worse in this
> and other UI aspects, and much slower (it kind of makes Eclipse look slick,
> which is quite an accomplishment) so I try to avoid it as much as I can.
>
> I know my opinion is a bit biased since I don't take advantage of the new
> features they've added for designers (I only do some minor tweaks to fla's,
> just enough to make it possible to control assets from code). Nevertheless,
> it's horrendously clunky and slow (just opening the code panel to put a
> stop() or something takes seconds the first time).
>
> However, CS4 uses the Flex SDK Java compiler and I'm sure CS5 does too, so
> I guess it's probably not a compiler issue, just that the IDE is buggy and
> unstable. Given its evolution and the quality of the last few major
> versions, I'm not surprised, sadly.
>
> Cheers
> Juan Pablo Califano
>
>
>
> 2010/12/10 Merrill, Jason 
>
> > >> I've written 36 classes for this project, totaling 430kb, with a
> > >> few
> > more still to go.
> > >>Additionally, I'm importing some third party classes.
> > >> I'm wondering if I'm running into some undocumented as3 code limit.
> >
> > Oh, thinking about this more, I should have mentioned. Flash CS5 is
> > HORRIBLE with a lot of code. They've taken a step back there.  I don't
> > know why I forgot this when you asked, but I recently had to switch
> > one project over to a pure AS3 project in Flashbuilder. The old
> > project (which had a similar amount of code and third party libraries)
> > would crash often and take for-ev-ah to compile.  When I switched to
> > Flashbuilder, it compiled in seconds and had no issues.
> >
> > In short, the Flash Pro compiler sucks.  If you've kept all your code
> > in classes and can switch over to a pure AS3 project in Flashbuil

Re: [Flashcoders] RE: swf not compiling

2010-12-10 Thread Juan Pablo Califano
I know this doesn't add any value to the problem discussed here, but if you
don't mind this little rant, I'd like to point out that the Flash IDE has
gotten worse with every major release (to me at least).

And I haven't tried CS5 yet. Seriously, the last usable one was probably
Flash 8. Thank godness, I use the IDE very sparingly and somehow got used to
the asinine way CS3 handles panels; CS4 impressed me as even worse in this
and other UI aspects, and much slower (it kind of makes Eclipse look slick,
which is quite an accomplishment) so I try to avoid it as much as I can.

I know my opinion is a bit biased since I don't take advantage of the new
features they've added for designers (I only do some minor tweaks to fla's,
just enough to make it possible to control assets from code). Nevertheless,
it's horrendously clunky and slow (just opening the code panel to put a
stop() or something takes seconds the first time).

However, CS4 uses the Flex SDK Java compiler and I'm sure CS5 does too, so I
guess it's probably not a compiler issue, just that the IDE is buggy and
unstable. Given its evolution and the quality of the last few major
versions, I'm not surprised, sadly.

Cheers
Juan Pablo Califano



2010/12/10 Merrill, Jason 

> >> I've written 36 classes for this project, totaling 430kb, with a few
> more still to go.
> >>Additionally, I'm importing some third party classes.
> >> I'm wondering if I'm running into some undocumented as3 code limit.
>
> Oh, thinking about this more, I should have mentioned. Flash CS5 is
> HORRIBLE with a lot of code. They've taken a step back there.  I don't know
> why I forgot this when you asked, but I recently had to switch one project
> over to a pure AS3 project in Flashbuilder. The old project (which had a
> similar amount of code and third party libraries) would crash often and take
> for-ev-ah to compile.  When I switched to Flashbuilder, it compiled in
> seconds and had no issues.
>
> In short, the Flash Pro compiler sucks.  If you've kept all your code in
> classes and can switch over to a pure AS3 project in Flashbuilder, I would.
>  Might mean re-doing how you handle your library assets, but could be worth
> it.
>
>  Jason Merrill
>  Instructional Technology Architect
>  Bank of America  Global Learning
>
>
>
>
>
> ___
>
>
> -Original Message-
> From: flashcoders-boun...@chattyfig.figleaf.com [mailto:
> flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Mendelsohn,
> Michael
> Sent: Friday, December 10, 2010 10:40 AM
> To: Flash Coders List
>  Subject: [Flashcoders] RE: swf not compiling
>
> > Have you tried putting everything in a fresh new .fla?  Sometimes .flas
> get corrupt. And are you using a document class?
>
> Hi Jason, thanks for responding.
>
> Yes, I'm using a document class.  I haven't rebuilt the swf.  I will try
> that.  What's strange is that as of 10 minutes ago, it's compiling.  But
> that has been no guarantee, as it has been periodically not compiling for
> about two days now.  I thought it might have been a corrupted component or
> graphic, but that doesn't seem to be the case as meticulously deleting
> individual library members didn't make a difference in trying to publish.
>
> If I rebuild the fla, I want to make it as lightweight as possible.  I've
> written 36 classes for this project, totaling 430kb, with a few more still
> to go.  Additionally, I'm importing some third party classes.  I'm wondering
> if I'm running into some undocumented as3 code limit.
>
> One thing I was wondering about but can't find documentation is in the
> Advanced ActionScript 3.0 Settings panel in publish settings.  I have no
> idea about the source path/library path/config constants tabs, but maybe
> it's sucking in too much to handle?  When it "decides" it wants to compile,
> it takes a very long time to do so.
>
> - MM
>
>
>
>
>
> ___
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
> --
> This message w/attachments (message) is intended solely for the use of the
> intended recipient(s) and may contain information that is privileged,
> confidential or proprietary. If you are not an intended recipient, please
> notify the sender, and then please delete and destroy all copies and
> attachments, and be advised that any review or dissemination of, or the
> taking of any action in reliance on, the information contained in or
> attached to

Re: [Flashcoders] stop caching

2010-12-09 Thread Juan Pablo Califano
If you are loading the swf directly from the file system (that is, localy)
appending parameters to the querystring won't work because they'll be
considered part of the file name. So those parameters will not be
interpreted as such. In a http environment (i.e. a server, local or remote),
on the other hand, the querystring will not be considered part of the file
name.

So yes, it's a local / server issue.

Cheers
Juan Pablo Califano

2010/12/9 Lehr, Theodore 

> I am trying to prevent caching via:
>
> function startLoad(dfile:String)
> {
>var ran:int = Math.round(Math.random()*10);
>var dfileb:String = new String();
>dfileb = dfile+"?ran="+ran;
>var mRequest:URLRequest=new URLRequest(dfileb);
> }
>
> startLoad("moive.swf");
>
> but I get an error 2044: Unhandled IOErrorEvent:text=Error #2035: URL Not
> Found
>
> What am I doing wrong?
>
> ___
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Normalising Numbers

2010-11-29 Thread Juan Pablo Califano
I think you're complicating the problem by introducing Math.abs which, I was
once told by a mathematically inclined colleague, is an arithmetic atrocity
(I've taken note of that since then and the nice thing is that almost
always, signs just work they way out without any extra help).

The formula is simpler than you probably think. You just need to find the
"size" of the range, that is the difference between the max and the min
values. Forget about signs, just take the max value and substract the min.
Easy as that.

If you have, say 10 and -4, the range "size" will be 14:

10 - (-4)
-->
10 + 4 = 14

The signs don't matter, as long as you always substract the smaller value
from the bigger one.

Now, once you have this value, you just have to find how far the ranged
value is from min and then "scale" it.

Let's say your value is 3. I picked 3 because it's easy to see it's in the
middle and that the result should be 0.5.

So:

"rangeSize" is 14 (max - min).
"min" is -4
"rangedValue" is 3:

How far is rangedValue from min?

rangedValue - min

That is:

3 - (-4)

or

3 + 4 = 7

Now, the last step, "scaling" it:

(rangedValue -  min) / rangeSize

Replacing the values:

(3 - (-4) ) / 14

(3 + 4) / 14

7 / 14 = 0.5

And there you have it.

So a function to normalize a ranged value could look like this:

function rangedToNormal(ranged:Number,min:Number,max:Number):Number {
var rangeSize:Number = max - min;
return (ranged - min) / rangeSize;
}

Going the other way is simple too:

function normalToRanged(normal:Number,min:Number,max:Number):Number {
var rangeSize:Number = max - min;
return min + normal * rangeSize;
}

(Though above you might want to validate that the normal value is actually
normalized before converting it to the passed range)

Also, I'm not sure how you are calculating the min and max values of your
list, but if there aren't other specific requirements, you could just use
Math.max and Math.min. They accept a variable number of arguments, not just
two, so Function::apply comes handy here:

var min:Number = Math.min.apply(null,list);

This will give you the min value of the list with just one line, no loops,
etc.

So, to wrap it up, you could write your function in just a few lines, like
this:

function normalizeNumbers(list:Array):Array {
var min:Number = Math.min.apply(null,list);
var max:Number = Math.max.apply(null,list);
var len:int = list.length;
var result:Array = [];
for(var i:int = 0; i < len; i++) {
result[i] = rangedToNormal(list[i],min,max);
}
 return result;
}

Cheers
Juan Pablo Califano





2010/11/29 Karim Beyrouti 

> Hello FlashCoder...
>
> maybe it's because it's late but it's getting a little confusing, and
> google is not being friendly right now.
> seems to works fine with positive numbers, however - i am trying to
> normalise a range of positive and negative numbers... ( code simplified not
> to find min and max values ).
>
> I am currently am coming up a little short... hope this code does not give
> anyone a headache; if you fancy a stab, or if you can point me in the right
> direction
> ... otherwise ...  will post results when i get there...
>
> Code:
>
> public function test() {
>
>trace('')
>trace( testNormalizeNumbers( [  1 , 1.5 , 2 ] , 2 , 1 ).toString()
> );
>
>trace('')
>trace( testNormalizeNumbers( [  1 , 1.5 , 5 , 1 , 6.4 , 6, 3, -2.6,
> -1 , 3.5 ] , 6.4 , -2.6 ).toString() );
>trace('')
>trace( testNormalizeNumbers( [  -1 , -1.5 , -5 , -1 , -6.4 , -6, -3,
> -2.6, -1 , -3.5 ] ,-1 , -6.4 ).toString() );
>
> }
>
> public function testNormalizeNumbers( a : Array , max : Number , min :
> Number ) : Array {
>
>var result  : Array = new Array();
>var nMax: Number= ( min > 0 ) ? max - min : max +
> Math.abs( min );
>
>for ( var c : int = 0 ; c < a.length ; c++ ){
>
>var pRangedValue: Number = ( min > 0 ) ?
> a[c] - min : a[c] + Math.abs( min );
>var normalizedValue : Number = pRangedValue / nMax;
>
>result.push( normalizedValue );
>
>}
>
>return result;
>
> }
>
>
>
> Thanks
>
>
> Karim ___
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Advice on calling subscriber script on another server

2010-11-26 Thread Juan Pablo Califano
No problem, Paul.

I'm glad you sorted it out!


Cheers
Juan Pablo Califano

2010/11/26 Paul Steven 

> Awesome! Thank you Juan - that worked perfectly! I did get caught out for a
> while by not adding
>
> require_once "HttpClient.class.php"
>
> But once I realised I had omitted this, it worked a treat.
>
> Many thanks!
>
> Paul
>
>
>
> On 26 Nov 2010, at 02:25, Juan Pablo Califano <
> califa010.flashcod...@gmail.com> wrote:
>
> > I think the easiest option would be creating some sort of proxy in php,
> if
> > that's what's available to you on your server.
> >
> > The only potential problem is (your) server configuration. Sometimes,
> > external connections are not allowed, so calling functions like
> > file_get_contents() with an external url won't work.
> >
> > Also, it seems you need to POST your data, so it's a bit more complex but
> > not too much.
> >
> > A week ago or so I had a similar scenario. Though there was a crossdomain
> > allowing connections from the production server, there was no crossdomain
> > policy for the staging and dev environments. I also had to receive and
> send
> > cookies, so I googled a bit and found this class, which was easy to use
> and
> > worked nicely for me
> >
> > http://scripts.incutio.com/httpclient/
> >
> > Some sample code for a POST request (taken from the project I worked on,
> > just slightly modified) :
> >
> >$client = new HttpClient("theotherserver.com");
> >//  this will print out useful info, enable it when debugging!
> >// $client->setDebug(true);
> >
> >$client->post("/theservice.ashx", array(
> > 'first_var'=> 'foo',
> > 'second_var'=> 'bar',
> >'etc'   => 'blah',
> > ));
> >
> >//  check status code here...
> > if($client->getStatus() == 200) {
> >//  a string with the server's response
> > $response_raw_data = $client->getContent();
> > }
> >
> > Maybe you can give this a try, it's very simple to install and use (just
> > download and include the php file; you can find more code examples in the
> > site).
> >
> > Again, in some configurations this code could not work; if any external
> > connection in your server is rejected, then there's not much you can do.
> But
> > even in the worst case, maybe you could find a third server that you have
> > control over and that allows you to open external connections, so you
> could
> > add a crossdomain there and run the php http client over there. Then,
> > instead of talking directly to the ad server or a local php script, you'd
> > call a third server that you control, which will proxy the communication
> > between flash and the ad server.
> >
> > Hope it makes sense!
> >
> > Cheers
> > Juan Pablo Califano
> >
> > 2010/11/25 Paul Steven 
> >
> >> Thanks for all your help Henrik
> >>
> >> I will ask the site in question in the morning. I was under the
> impression
> >> it would be like every person who used Microsoft Office asking Microsoft
> to
> >> add a cross domain file for their particular scenario. To be honest I
> just
> >> panicked when the client reported tonight that this functionality didn't
> >> work and after trying to create a php file that would call the ashx file
> >> for
> >> me without success and doing a good bit of searching on google, I
> thought
> >> perhaps if there was a simple solution to this that someone on Flash
> Coders
> >> may know and be able to help me in my hour of need.
> >>
> >> Anyway I will email the site now though as it is UK based assume that I
> >> will
> >> not get any reply until tomorrow (which is too late!)
> >>
> >> Thanks for the advice
> >>
> >>
> >>
> >> -Original Message-
> >> From: flashcoders-boun...@chattyfig.figleaf.com
> >> [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Henrik
> >> Andersson
> >> Sent: 25 November 2010 20:34
> >> To: Flash Coders List
> >> Subject: Re: [Flashcoders] Advice on calling subscriber script on
> another
> >> server
> >>
> >> Paul Steven skriver:
> >>> Thought I could get some help here not labelled lazy!
> >>>
> >>
> &

Re: [Flashcoders] Advice on calling subscriber script on another server

2010-11-25 Thread Juan Pablo Califano
I think the easiest option would be creating some sort of proxy in php, if
that's what's available to you on your server.

The only potential problem is (your) server configuration. Sometimes,
external connections are not allowed, so calling functions like
file_get_contents() with an external url won't work.

Also, it seems you need to POST your data, so it's a bit more complex but
not too much.

A week ago or so I had a similar scenario. Though there was a crossdomain
allowing connections from the production server, there was no crossdomain
policy for the staging and dev environments. I also had to receive and send
cookies, so I googled a bit and found this class, which was easy to use and
worked nicely for me

http://scripts.incutio.com/httpclient/

Some sample code for a POST request (taken from the project I worked on,
just slightly modified) :

$client = new HttpClient("theotherserver.com");
//  this will print out useful info, enable it when debugging!
// $client->setDebug(true);

$client->post("/theservice.ashx", array(
'first_var'=> 'foo',
'second_var'=> 'bar',
'etc'   => 'blah',
));

//  check status code here...
if($client->getStatus() == 200) {
//  a string with the server's response
$response_raw_data = $client->getContent();
}

Maybe you can give this a try, it's very simple to install and use (just
download and include the php file; you can find more code examples in the
site).

Again, in some configurations this code could not work; if any external
connection in your server is rejected, then there's not much you can do. But
even in the worst case, maybe you could find a third server that you have
control over and that allows you to open external connections, so you could
add a crossdomain there and run the php http client over there. Then,
instead of talking directly to the ad server or a local php script, you'd
call a third server that you control, which will proxy the communication
between flash and the ad server.

Hope it makes sense!

Cheers
Juan Pablo Califano

2010/11/25 Paul Steven 

> Thanks for all your help Henrik
>
> I will ask the site in question in the morning. I was under the impression
> it would be like every person who used Microsoft Office asking Microsoft to
> add a cross domain file for their particular scenario. To be honest I just
> panicked when the client reported tonight that this functionality didn't
> work and after trying to create a php file that would call the ashx file
> for
> me without success and doing a good bit of searching on google, I thought
> perhaps if there was a simple solution to this that someone on Flash Coders
> may know and be able to help me in my hour of need.
>
> Anyway I will email the site now though as it is UK based assume that I
> will
> not get any reply until tomorrow (which is too late!)
>
> Thanks for the advice
>
>
>
> -Original Message-
> From: flashcoders-boun...@chattyfig.figleaf.com
> [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Henrik
> Andersson
> Sent: 25 November 2010 20:34
> To: Flash Coders List
> Subject: Re: [Flashcoders] Advice on calling subscriber script on another
> server
>
> Paul Steven skriver:
> > Thought I could get some help here not labelled lazy!
> >
>
> You do realize that it takes just as long to simply ask the site in
> question right?
> ___
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
> ___
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Set HTTP cookies with navigateToURL()

2010-11-13 Thread Juan Pablo Califano
If you have access to Javascript, you can set the cookies like this.

ExternalInterface.call("function() { document.cookie = 'foo=bar;
expires=Mon, 15 Nov 2010 23:59:59 UTC; path=/'; }()");

navigateToURL(new URLRequest("somepage.php"));

Then in somepage, your data will be available in $_COOKIE;


Cheers
Juan Pablo Califano

2010/11/13 Alexander Farber 

> Hello,
>
> I have a small multiplayer Flash game in which you can
> display a player profile by clicking at his or her avatar:
>
> const PROFILE_URL:String = 'http://myserver/user.php?id=';
> try {
>  navigateToURL(new URLRequest(PROFILE_URL+id), '_blank');
> } catch(e:Error) {
> }
>
> This works well, but now I'd like to extend the user.php,
> so that players can add comments about each other.
> For authorization I'd like to use HTTP cookies,
> passed from the game.swf to the user.php.
>
> (I don't want use GET or POST here, because GET
> will have the auth. variables in the URL and players might
> occasionaly send that URL around or post it in my forum.
> And POST will ask to re-post the request when you reload).
>
> My problem is, that I can't find the way to set HTTP cookies
> through the navigateToURL() method. Please advise me
>
> Regards
> Alex
> ___
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Calling a Static Function

2010-11-10 Thread Juan Pablo Califano
I see a couple of weird things in your code.

First, I think your code, as is, should give you a compile error. At least,
I get an error, with this code (which looks equivalent):

var mathClass:Class = Math;
//mathClass.random(); --> compile error
It works if I workaround the compiler check, though:

var mathClass:Class = Math;
mathClass["random"]();
So, it's weird that you don't get an error. Which leads me to believe that
perhaps, you have a valid reference to the AssetLibrary class in your
project. Have you double checked that?

Anyway, I'd change the name of the variable since it could be ambiguous (if
you happen to have a reference to the class). I mean something like this:

var AssetLibraryDef:Class;
AssetLibraryDef=
pEvent.target.applicationDomain.getDefinition("AssetLibrary") as Class;
try
{
AssetLibraryDef.initAssets(); //<--the error is here
}

Also, could it be possible that the compiled class in the loaded swf defines
the method initAssets as taking one parameter? Maybe there's some versioning
problem going on...

At any rate, you could use describeType on the Class object to inspect it.
This will list static methods and will tell you how many parameters they
define (and also the types).

In my example, it's simply:

trace(describeType(mathClass));

So, you could probably see this info doing:

trace(describeType(AssetLibraryDef));

Not sure where the problem could be, really, but perhaps this gives you some
idea.


Cheers
Juan Pablo Califano

2010/11/10 Kerry Thompson 

> Deepanjan Das wrote:
>
> Hi Kerry,
> > The problem is in these lines:
> > var AssetLibrary:Class;
> >
> >
> AssetLibrary=pEvent.target.applicationDomain.getDefinition("AssetLibrary")
> > as Class;
> > You are calling a stattic function; so this is correct
> > AssetLibrary.initAssets();
> > But why are you defining the same class variable ahead, thats wrong.
> > Static methods mean you can directly call those APIs without creating an
> > instance.
> >
> > So just call AssetLibrary.initAssets() provided you have a
> AssetLibrary.as
> > imported.
> >
>
> That makes sense, except I may not have the .as file. I need to be able to
> download an asset swf written by another developer. That's why I'm getting
> the class from the downloaded swf.
>
> I tried adding an import statement, pointing to the location of the swf,
> and
> got an error that it couldn't be found.
>
> Maybe I need to have the other developer make it an RSL, because I need to
> share it among different swf's. I don't understand why I can't call the
> function, though. There are a number of public static vars in the
> downloaded
> swf, and I can see them in the debugger. I can't see the public static
> function, though, and the assets are not being initialized.
>
> Cordially,
>
> Kerry Thompson
> ___
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Inheritance and abstract classes

2010-09-24 Thread Juan Pablo Califano
Jason, I'm glad you liked it.

Yes, that's precisely the idea. Passing (or actually accepting) an interface
instead of a concrete class.

Following this principle, you could for example use some third party library
for collision detection instead of writting your own if you find one that
fulfills your requirements. This is a good example of when interfaces make
most sense (3rd party libraries). Suppose the author of this engine typed
the input param as some concrete class. It could be then complicated to
integrate with your game objects, because you'd have a hard requirement of
extending a given class, but your object probably already extends something
else. However, if it's an interface, it could be relativeley simple to
integrate, as long as you implement the methods that the interface declares.
And you are free to model your objects hierarchy as you see fit.

Cheers
Juan Pablo Califano



2010/9/24 Merrill, Jason 

> >> You can have an engine that checks collisions and accepts IHitable
> objects;
> >>another engine would be in charge of moving the objects around and so it
> takes IMoveable object
>
> Juan, excellent, excellent post.  So in a case like that, sounds like you
> would often just typecast method arguments as an interface and not a
> concrete class, right?
>
> i.e. instead of:
>
>  public function moveIt(moveObject:MoveObject):void{}
>
> do this:
>
>  public function moveIt(moveObject:IMoveable):void{}
>
>
>
>  Jason Merrill
>  Instructional Technology Architect
>  Bank of America  Global Learning
>
>  tweets @ jmerrill_2001
>  Join the Bank of America Flash Platform Community  and visit our
> Instructional Technology Design Blog
>  (Note: these resources are only available to Bank of America associates).
>
>
>
>
> -Original Message-
> From: flashcoders-boun...@chattyfig.figleaf.com [mailto:
> flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Juan Pablo
> Califano
> Sent: Friday, September 24, 2010 1:15 AM
> To: Flash Coders List
> Subject: Re: [Flashcoders] Inheritance and abstract classes
>
> >>>
> Despite what the naming conventions are, since the only thing, IMHO, that
> interfaces are useful for, is determining if the object being passed to a
> method complies and has methods/properties that can be used, without having
> to write code to check if the object being passed actually has all the
> desired methods/properties.
> >>>
>
> You can already do that with a class. As long the language is static typed
> (or is dynamically typed but types contranis are enforced at compile-time,
> as in AS 2.0 and in some cases AS 3.0), the compiler checks that without the
> need of an interface.
>
> I'd say that, conceptually, an interface is every method and property (and
> event, arguably) that a type exposes. So, you know x, y, height, widht, etc,
> are part of DisplayObject's interface (even though DisplayObject is a class;
> one you cannot instantiate or derive from without crashing at runtime,
> though; but that's more a hack hardcoded in the player for the lack of
> support of abstract classes in the language; and if you ask me,
> DisplayObject should have been an interface or there should be an
> IDisplayObject interface, but I digress).
>
> Now, knowing an object has certain capabilities is very useful, especially
> when writting libraries, frameworks and that sort of code. Your code could
> declare that it accepts objects that comply with certain "interface" (and
> here I don't mean necessarily the interface keyword / construct, but rather
> what I said in the previous paragraph). This is what you pointed out. But
> the difference is that you can have an object implement an interface without
> coupling it with some concrete class. So it's more flexible and it's
> possible for some object to implement more than one interface (and possibly
> unrelated interfaces).
>
> In a game, for instance, you can have "entities" (or whatever you like to
> call it). Following you IMoveable example, you could have other interfaces
> such as IShooter, IHitable, etc. You can have an engine that checks
> collisions and accepts IHitable objects; another engine would be in charge
> of moving the objects around and so it takes IMoveable object; another could
> be in charge of common tasks that need to be performed on shooters, so I'd
> act on IShooter's; and so on.
>
> Now, the advantage of using interfaces is that you can combine these sets
> of functionalities (as declared by the interfaces) in one object indepently,
> without having to force inheritance relations that might not make sense and
> could add nasty side-effects. I.e. an object could

Re: [Flashcoders] Inheritance and abstract classes

2010-09-23 Thread Juan Pablo Califano
>>>
Despite what the naming conventions are, since the only thing, IMHO, that
interfaces are useful for, is determining if the object being passed to a
method complies and has methods/properties that can be used, without having
to write code to check if the object being passed actually has all the
desired methods/properties.
>>>

You can already do that with a class. As long the language is static typed
(or is dynamically typed but types contranis are enforced at compile-time,
as in AS 2.0 and in some cases AS 3.0), the compiler checks that without the
need of an interface.

I'd say that, conceptually, an interface is every method and property (and
event, arguably) that a type exposes. So, you know x, y, height, widht, etc,
are part of DisplayObject's interface (even though DisplayObject is a class;
one you cannot instantiate or derive from without crashing at runtime,
though; but that's more a hack hardcoded in the player for the lack of
support of abstract classes in the language; and if you ask me,
DisplayObject should have been an interface or there should be an
IDisplayObject interface, but I digress).

Now, knowing an object has certain capabilities is very useful, especially
when writting libraries, frameworks and that sort of code. Your code could
declare that it accepts objects that comply with certain "interface" (and
here I don't mean necessarily the interface keyword / construct, but rather
what I said in the previous paragraph). This is what you pointed out. But
the difference is that you can have an object implement an interface without
coupling it with some concrete class. So it's more flexible and it's
possible for some object to implement more than one interface (and possibly
unrelated interfaces).

In a game, for instance, you can have "entities" (or whatever you like to
call it). Following you IMoveable example, you could have other interfaces
such as IShooter, IHitable, etc. You can have an engine that checks
collisions and accepts IHitable objects; another engine would be in charge
of moving the objects around and so it takes IMoveable object; another could
be in charge of common tasks that need to be performed on shooters, so I'd
act on IShooter's; and so on.

Now, the advantage of using interfaces is that you can combine these sets of
functionalities (as declared by the interfaces) in one object indepently,
without having to force inheritance relations that might not make sense and
could add nasty side-effects. I.e. an object could be hitable but not
moveable, a shooter could be either moveable / not moveable, etc. So you
could have a turret (IHitable, IShooter, but not IMoveable), and wall /
obstacle (IHitable but not IMovable nor IShooter), and enemy ship (IHitable,
IShooter and IMoveable), a bullet (IMoveable and IHitable but not IShooter
since it doesn't shoot by itself). Without interfaces and only realying on
inheritance this could turn into a mess rather quickly.

This is important in languages such as Actionscript (which took the idea
from Java), because multiple inheritance is not allowed. In other languages
such as C++, you can have a class inherit from (and hence "being-a") any
number of classes so the interface construct / syntax is not necessary
(although multiple inheritance has other drawbacks and is more complex, and
that's why it was left out of Java and other languages followed it this
idea).

That said, you don't need to have interfaces or even abstract classes for
everything, in my opinion. This adds flexibility and some space for future
expansion but it comes at the cost of making things more complex. If you're
writing a library and want to allow different "clients" to use it, having
your methods accept interfaces instead of concrete / abstract classes is a
good idea. You can even provide some default / minimal implementation but
leave it open to your "clients" to implement their own and still be able to
use your library, without having to extend some class (which is not always
possible / practical). In lots of application code, though, I think you
don't really need this extra flexibility and many times it adds more work
for little benefit.

Cheers
Juan Pablo Califano

2010/9/23 Anthony Pace 

>  On 9/23/2010 3:51 PM, Henrik Andersson wrote:
>
>> you say Picture IS-A IDrawable.
>>
> Despite what the naming conventions are, since the only thing, IMHO, that
> interfaces are useful for, is determining if the object being passed to a
> method complies and has methods/properties that can be used, without having
> to write code to check if the object being passed actually has all the
> desired methods/properties.
>
> e.g.  According to my understanding:
> human, cat, dog  are different objects, but they all have an IMoveAround
> interface
> So I know If I pass one of the objects to a meth

Re: [Flashcoders] Using an embedded font

2010-09-22 Thread Juan Pablo Califano
PS:

If nothing else works and you're in a hurry, maybe this is worth a try.

Make a new fla. Place a textfield on the stage and embed the fonts manually
in the Flash IDE. Put this text field inside a MovieClip and export it.
Publish this fla as a swc, add it to your FB project and somewhere do this
to force the compiler to include this mc in your FB swf.

var dummy:MyMovieClip;

This should force the compiler to include the mc and indirectly the glyphs
you have embbeded in your on stage text field.

This is rather gross and unelegant and I'm not sure if it'll play nice with
text fields created with code, but I generally work with fla's that have
text fields with embedded fonts in the Flase IDE and having a dummy
textfield is sometimes the easier way to make sure font are embbeded for the
whole swf and that all text fields display the fonts correctly.


2010/9/22 Juan Pablo Califano 

> I hear you. The way flash handles fonts is a royal mess.
>
> Have you tried this method?
>
>
> http://www.adobe.com/livedocs/flash/9.0/ActionScriptLangRefV3/flash/text/Font.html#enumerateFonts()
>
> It should give you a list of the fonts that are being embbeded in the SWF
> and their names. It'll not fix the problem per se, but maybe it shows you
> the name of the font as it's registered.
>
>
> Cheers
> Juan Pablo Califano
>
> 2010/9/22 Kerry Thompson 
>
>> Juan Pablo Califano wrote:
>>
>>
>> > var font:Font = new Garamond3Embedded() as Font;
>> > textFormat.font = font.fontName;
>>
>> Well, I tried that too, and still no luck. Just in case it was a path
>> problem, I moved the font into the same folder as my .as file,
>> adjusted the source accordingly, and still no luck.
>>
>> Dang, this shouldn't be this hard. I've used embedded fonts in the
>> past, and they've worked. I've just never tried to do it all in one
>> demo file.
>>
>> Cordially,
>>
>> Kerry Thompson
>> ___
>> Flashcoders mailing list
>> Flashcoders@chattyfig.figleaf.com
>> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>>
>
>
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Using an embedded font

2010-09-22 Thread Juan Pablo Califano
I hear you. The way flash handles fonts is a royal mess.

Have you tried this method?

http://www.adobe.com/livedocs/flash/9.0/ActionScriptLangRefV3/flash/text/Font.html#enumerateFonts()

It should give you a list of the fonts that are being embbeded in the SWF
and their names. It'll not fix the problem per se, but maybe it shows you
the name of the font as it's registered.


Cheers
Juan Pablo Califano

2010/9/22 Kerry Thompson 

> Juan Pablo Califano wrote:
>
> > var font:Font = new Garamond3Embedded() as Font;
> > textFormat.font = font.fontName;
>
> Well, I tried that too, and still no luck. Just in case it was a path
> problem, I moved the font into the same folder as my .as file,
> adjusted the source accordingly, and still no luck.
>
> Dang, this shouldn't be this hard. I've used embedded fonts in the
> past, and they've worked. I've just never tried to do it all in one
> demo file.
>
> Cordially,
>
> Kerry Thompson
> ___
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Using an embedded font

2010-09-22 Thread Juan Pablo Califano
PS:

I meant this:

var font:Font = new Garamond3Embedded() as Font;
textFormat.font = font.fontName;

2010/9/22 Juan Pablo Califano 

> Have you tried not setting the font name in the text format object? I think
> it defaults to Times or something like that.
>
> Then, if the text shows up, maybe the problem is in the font identifier.
>
> You could then / also try this, which should give you the right name for
> the font.
>
> var font:Garamond3Embedded = new Garamond3Embedded();
> textFormat.font = font.fontName;
>
> Cheers
> Juan Pablo Califano
>
> 2010/9/22 Kerry Thompson 
>
> I've been banging my head up against this for 4 hours, and the client
>> has to ship tonight.
>>
>> FlashBuilder 4, Windows 7.
>>
>> I am just trying to make a little demo of how to embed a font, but
>> when I pull together code that has worked before into one simple
>> class, it doesn't show the text. It draws the outline of the text
>> field, but there is no text. When I comment out one line,
>> textField.embedFonts = true, it works, but not with the embedded font.
>>
>> I've tried different fonts, and can't get any of them to work. Can
>> somebody spot what I'm doing wrong?
>>
>> Cordially,
>> Kerry Thompson
>>
>>public class FontEmbedding extends Sprite
>>{
>>public function FontEmbedding()
>>{
>>showText();
>>}
>>
>>/**
>> * Embeds the  Garamond 3 font
>> */
>>[Embed(
>>source='../fonts/GaramThrSC.ttf',
>>fontName='Garamond3'
>>)]
>>
>>private static var Garamond3Embedded: Class;
>>
>>private function showText():void
>>{
>>var textFormat:TextFormat;
>>var textField:TextField;
>>registerFonts();
>>
>>textFormat = new TextFormat();
>>textFormat.color = 0x00;
>>textFormat.font = "Garamond3Embedded";
>>textFormat.align = "left";
>>
>>textField = new TextField();
>>textField.defaultTextFormat = textFormat;
>>textField.border = (true);
>>
>>textField.embedFonts = true;
>>
>>textField.text = "Hello Autovod!";
>>textField.width = 100;
>>textField.height = 30;
>>
>>addChild(textField);
>>textField.x = 100;
>>textField.y = 60;
>>}
>>
>>public static function registerFonts(): void
>>{
>>Font.registerFont(Garamond3Embedded);
>>}
>>}
>> }
>> ___
>> Flashcoders mailing list
>> Flashcoders@chattyfig.figleaf.com
>> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>>
>
>
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Using an embedded font

2010-09-22 Thread Juan Pablo Califano
Have you tried not setting the font name in the text format object? I think
it defaults to Times or something like that.

Then, if the text shows up, maybe the problem is in the font identifier.

You could then / also try this, which should give you the right name for the
font.

var font:Garamond3Embedded = new Garamond3Embedded();
textFormat.font = font.fontName;

Cheers
Juan Pablo Califano

2010/9/22 Kerry Thompson 

> I've been banging my head up against this for 4 hours, and the client
> has to ship tonight.
>
> FlashBuilder 4, Windows 7.
>
> I am just trying to make a little demo of how to embed a font, but
> when I pull together code that has worked before into one simple
> class, it doesn't show the text. It draws the outline of the text
> field, but there is no text. When I comment out one line,
> textField.embedFonts = true, it works, but not with the embedded font.
>
> I've tried different fonts, and can't get any of them to work. Can
> somebody spot what I'm doing wrong?
>
> Cordially,
> Kerry Thompson
>
>public class FontEmbedding extends Sprite
>{
>public function FontEmbedding()
>{
>showText();
>}
>
>/**
> * Embeds the  Garamond 3 font
> */
>[Embed(
>source='../fonts/GaramThrSC.ttf',
>fontName='Garamond3'
>)]
>
>private static var Garamond3Embedded: Class;
>
>private function showText():void
>{
>var textFormat:TextFormat;
>var textField:TextField;
>registerFonts();
>
>textFormat = new TextFormat();
>textFormat.color = 0x00;
>textFormat.font = "Garamond3Embedded";
>textFormat.align = "left";
>
>textField = new TextField();
>textField.defaultTextFormat = textFormat;
>textField.border = (true);
>
>textField.embedFonts = true;
>
>textField.text = "Hello Autovod!";
>textField.width = 100;
>textField.height = 30;
>
>addChild(textField);
>textField.x = 100;
>textField.y = 60;
>}
>
>public static function registerFonts(): void
>{
>Font.registerFont(Garamond3Embedded);
>}
>}
> }
> ___
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] flv on fb servers not loading in ie only

2010-09-21 Thread Juan Pablo Califano
Very weird.

As you have noticed, it seems facebook is not serving the file under some
circumstances (it returns a 404 http error code)

I could make it fail consistently if:

1) The referer is set and is in a "non facebook" domain

AND

2) The user agent is IE.

I got the request to work if I set the referer to
http://www.facebook.com/and leaving the user-agent as IE, for
instance.

It also worked, if I kept the original referer but used the same user-agent
as Chrome:

User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US)
AppleWebKit/534.3 (KHTML, like Gecko) Chrome/6.0.472.62 Safari/534.3

I'm not sure if there's any work around from Actionscript, I'm afraid, as
you have very limited control over the request headers sent to the server.
I'm pretty sure you just can't change the user-agent or the referer.

The only alternative I can think of is proxying your request through some
server you control. But that of course negates the benefits of using
facebook's CDN infrastructure and for your server traffic and load it would
be worse that just hosting the video yourself in the first place.

I'm sorry this isn't of much help, but I can think of any other work around.

Let us know if you find something else.

Cheers
Juan Pablo Califano

2010/9/21 jared stanley 

> thanks.
>
> I think the problem has been isolated,
>
> on the URLRequest, the response is as follows:
>
> http://pastebin.com/AmwCtAcD
>
> in there, the 'referer' param is causing the file to 404 - if we remove it
> then the video loads correctly.
>
> anyone have any idea on how to either set that param(not possible i think)
> or else modify it once it's loaded before it's processed?
>
> thanks!
>
>
>
>
>
>
> On Mon, Sep 20, 2010 at 6:49 PM, Juan Pablo Califano <
> califa010.flashcod...@gmail.com> wrote:
>
> > I've had experienced problems with Facebook Connect on IE only. In my
> case,
> > the user wouldn't even be able to log in, so I'm not sure this is the
> same
> > problem you're experiencing. But anyway, maybe it's worth checking this:
> >
> > http://wiki.github.com/facebook/connect-js/custom-channel-url
> >
> > <http://wiki.github.com/facebook/connect-js/custom-channel-url
> >Basically,
> > I
> > set explicitly the channelUrl on initialization, like in the example and
> > put
> > the channel.html file at the same level that the xd_receiver.html file
> that
> > is used for working around JS cross-domain issues. And it solved the
> > problem.
> >
> > If I recall correctly, this custom channel url workaround is necessary
> only
> > if your app isn't loaded within FB, as opposed to an external site that
> > just
> > uses Facebook Connect. (Or was it the other way around?)
> >
> > Hope this helps.
> >
> > Cheers
> > Juan Pablo Califano
> >
> >
> >
> >
> > 2010/9/20 jared stanley 
> >
> > > hey - experiencing a weird bug here:
> > >
> > > we have a video uploaded onto facebook's servers - we then load it into
> > > flash.
> > > it's working fine on all browsers except for ie.
> > > it works fine when the video is local or on any other server.
> > >
> > > anyone have any insights?
> > >
> > > Thanks!
> > > ___
> > > Flashcoders mailing list
> > > Flashcoders@chattyfig.figleaf.com
> > > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
> > >
> > ___
> > Flashcoders mailing list
> > Flashcoders@chattyfig.figleaf.com
> > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
> >
> ___
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] flv on fb servers not loading in ie only

2010-09-20 Thread Juan Pablo Califano
I've had experienced problems with Facebook Connect on IE only. In my case,
the user wouldn't even be able to log in, so I'm not sure this is the same
problem you're experiencing. But anyway, maybe it's worth checking this:

http://wiki.github.com/facebook/connect-js/custom-channel-url

<http://wiki.github.com/facebook/connect-js/custom-channel-url>Basically, I
set explicitly the channelUrl on initialization, like in the example and put
the channel.html file at the same level that the xd_receiver.html file that
is used for working around JS cross-domain issues. And it solved the
problem.

If I recall correctly, this custom channel url workaround is necessary only
if your app isn't loaded within FB, as opposed to an external site that just
uses Facebook Connect. (Or was it the other way around?)

Hope this helps.

Cheers
Juan Pablo Califano




2010/9/20 jared stanley 

> hey - experiencing a weird bug here:
>
> we have a video uploaded onto facebook's servers - we then load it into
> flash.
> it's working fine on all browsers except for ie.
> it works fine when the video is local or on any other server.
>
> anyone have any insights?
>
> Thanks!
> ___
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] parsing multi-dimensional array

2010-09-04 Thread Juan Pablo Califano
It seems like you want to group your data by color and each of your items
consists of a string and two numbers.

Let's assume this items are points (holding an x and y value) that have a
label. (By the way, defining the data makes finding a good structure for it
easier; when you ask a question like this, some background on what your data
represents and what you are trying to do it is helpful).

Assuming this, I'd have an object or dictionary that groups lists of points
by color. So this object or dict would have one entry for each color. This
entry would be an array, that will hold points of a given color.

You could use a class or VO (as Jason suggested) to store each point. You
could also use an Object for this. Using an array  is a bad choice if I
understood your problem correctly. Because you're saying "the label is the
first element, x the second and y the third; but it's much easier to give
each of this properties names, so it's more readable and less error prone)

In code, you could try something like this:

public class LabeledPoint {
public var x:int;
public var y:int;
public var label:String;

public function LabeledPoint(label:String = "", x:int = 0, y:int = 0) {
this.label = label;
this.x = x;
this.y = y;
}

override public function toString():String {
return "[LabeledPoint " + label + ", " + x + ", " + y;
}
}

public class PointsDictionary {

private var _dict:Object;

public function PoinstDictionary() {
_dict = {};
}

public function getGroup(label:String):Array {
if(!_dict[label]) {
_dict[label] = [];
}
return _dict[label];
}

public function addPoint(p:LabeledPoint):void {
var group:Array = getGroup(p.label);
group.push(p);
}
}

// use
var points:PointsDictionary = new PointsDictionary();
points.addPoint(new LabeledPoint("red",0,0));
points.addPoint(new LabeledPoint("red",1,0));
points.addPoint(new LabeledPoint("red",2,0));

points.addPoint(new LabeledPoint("blue",0,0));
points.addPoint(new LabeledPoint("blue",1,0));
points.addPoint(new LabeledPoint("blue",2,0));

//  get the red points:
var redPoints:Array = points.getGroup("red");
//  get the first red point:
var firstRed:LabeledPoint = redPoints[0];

Of course there are many other ways to do this, depending on your
requirements. The above is rather "raw" in that it gives you direct access
to the underlying storage (the arrays) and it's up to you to manipulate them
externally (I just added an addPoint method as a convenience to make the
code less verbose). You might want to prevent duplicates, be able to add an
item at a certain position, remove them, etc, etc. In that case, you could
consider adding other methods or (better) using some more specific data
structures, such as these:
http://sibirjak.com/blog/index.php/collections/as3commons-collections/

Cheers
Juan Pablo Califano

2010/9/3 Lehr, Theodore 

> so if I have a multi-dimensional array - how could I break them into their
> own array? So if I have:
>
> arr[0] = ["red",0,0];
> arr[1] = ["red",1,0];
> arr[2] = ["red",2,0];
> arr[3] = ["blue",0,0];
> arr[4] = ["blue",1,0];
> arr[5] = ["blue",2,0];
>
> What I need to do is break red into it's own array and blue into it's own
> array - and there could be any number of colors
>
> ___
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Error #2032

2010-09-04 Thread Juan Pablo Califano
PS:

Also, some RESTful services are rather strict about what HTTP command they
accept. Some will only allow POST for some operations and GET for others.
This might be the case here...

As a side note, if you set your code to use POST but you don't send any data
in the request body, flash will switch to GET silently (this is documented
in "fine print" in the docs but I had missed). A simple solution for this is
sending some dummy data to force flash to use POST.



2010/9/4 Juan Pablo Califano 

> It's hard to know what the problem is with such limited info.
>
> The first step to troubleshoot this would be inspecting the http traffic. I
> guess.
>
> The best tool for this that I know of is wireshark (
> http://www.wireshark.org/). It's not the most friendly though and could be
> a bit daunting at first.
>
> Other option is Charles (http://www.charlesproxy.com/). Less powerful, but
> good enough for inspecting communication between your app and the rest of
> the world. Also, it's much more friendlier and intuitive.
>
> Install any of the above and run your app. Then check the server response
> to see if it rejected your request for some reason.
>
> Probably not the case here, but I once had a similiar problem (using POST
> or GET made no difference, though). Whenever I connected from the IDE, the
> server responded with some fault code (can't remember if it was 500, 403 or
> something like that). However, if I run the code from a browser, it worked
> (I was running from localhost and already had sorted out crossdomain
> issues). Now, the curious thing was that if I had charles running, it worked
> both from the IDE and the browser. So I suspected and confirmed later that
> the server app I was connecting to was inspecting the user-agent in the
> request header and explicitly rejecting flash for some dumb "security
> reasons" (when charles is running it proxies your http traffic and changes
> the user agent). Anyway, this was rare; most server side scripts / apps
> won't check the user agent (because this piece of data is sent by the client
> anyway, and no real security could be enforced just by inspecting it).
>
> Cheers
> Juan Pablo Califano
>
> 2010/9/4 Paul Andrews 
>
>  I have an pap that access a remote server (well it won't be remote once
>> deployed) via http and the server returns some XML.
>>
>> Testing via the IDE..
>>
>> using GET I have no problem
>> using POST I get Error #2032.
>>
>> What's the best way forward to know why the server is upset?
>>
>> Paul
>> ___
>> Flashcoders mailing list
>> Flashcoders@chattyfig.figleaf.com
>> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>>
>
>
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Error #2032

2010-09-04 Thread Juan Pablo Califano
It's hard to know what the problem is with such limited info.

The first step to troubleshoot this would be inspecting the http traffic. I
guess.

The best tool for this that I know of is wireshark (
http://www.wireshark.org/). It's not the most friendly though and could be a
bit daunting at first.

Other option is Charles (http://www.charlesproxy.com/). Less powerful, but
good enough for inspecting communication between your app and the rest of
the world. Also, it's much more friendlier and intuitive.

Install any of the above and run your app. Then check the server response to
see if it rejected your request for some reason.

Probably not the case here, but I once had a similiar problem (using POST or
GET made no difference, though). Whenever I connected from the IDE, the
server responded with some fault code (can't remember if it was 500, 403 or
something like that). However, if I run the code from a browser, it worked
(I was running from localhost and already had sorted out crossdomain
issues). Now, the curious thing was that if I had charles running, it worked
both from the IDE and the browser. So I suspected and confirmed later that
the server app I was connecting to was inspecting the user-agent in the
request header and explicitly rejecting flash for some dumb "security
reasons" (when charles is running it proxies your http traffic and changes
the user agent). Anyway, this was rare; most server side scripts / apps
won't check the user agent (because this piece of data is sent by the client
anyway, and no real security could be enforced just by inspecting it).

Cheers
Juan Pablo Califano

2010/9/4 Paul Andrews 

>  I have an pap that access a remote server (well it won't be remote once
> deployed) via http and the server returns some XML.
>
> Testing via the IDE..
>
> using GET I have no problem
> using POST I get Error #2032.
>
> What's the best way forward to know why the server is upset?
>
> Paul
> ___
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Detect player version that was published

2010-08-24 Thread Juan Pablo Califano
>>>
Right, not looking for the Flash Player plugin version a user has installed,
but rather which runtime the SWF was published to (9 or 10).
>>>

Then I think you should go with Zeh's suggestion:

http://www.adobe.com/livedocs/flash/9.0/ActionScriptLangRefV3/flash/display/LoaderInfo.html#swfVersion

<http://www.adobe.com/livedocs/flash/9.0/ActionScriptLangRefV3/flash/display/LoaderInfo.html#swfVersion>Checking
if Loader has an unloadAndStop method defined will let you know if the
player version is >= 10, but not what version the swf was published for.

Cheers
Juan Pablo Califano

2010/8/24 Todd Dominey 

> Right, not looking for the Flash Player plugin version a user has
> installed, but rather which runtime the SWF was published to (9 or 10).
>
> The root of my dilemma is that Flash's behavior when applying an alpha
> tween to a Sprite containing a text field using system typefaces isn't
> consistent when publishing to FP9 and FP10. When FP9 is the runtime, the
> text fields aren't tweened as part of the parent. When FP10 is the runtime,
> they are.
>
> Note that this is independent of the Flash Player plugin a user has
> installed. If you compile the SWF with FP9 as the runtime and load it in
> FP10 in the browser, the text fields aren't tweened. Compile to FP10 and
> load in FP10, they are.
>
> So...I'm trying to find something that an AS3 SWF could "look for" to know
> whether FP10 was selected as its runtime when published. If I knew that, I
> could code around it to control how that tween behavior is handled.
>
> Todd
>
> On Aug 24, 2010, at 10:25 AM, Glen Pike wrote:
>
> > On 24/08/2010 15:04, Todd Dominey wrote:
> >> Hi everyone -
> >>
> >> I have an AS3 component that publishes to either Flash Player 9 or Flash
> Player 10, and I'm trying to figure out a way to detect (within the
> component's ActionScript) whether the user published the SWF to 9 or 10 as
> their target. I realize the SWF is agnostic to the IDE and won't be able to
> see that directly, but is there a way for the SWF itself to know which
> player it was published for? Or a way for a Flash Player 9 SWF to try and
> access a Flash Player 10 property of some kind that won't return a compile
> error in the IDE?
> >> ___
> >> Flashcoders mailing list
> >> Flashcoders@chattyfig.figleaf.com
> >> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
> >>
> >>
> > Sorry, was a bit fast off the mark there, but you could leverage the FP
> version to decide whether to implement certain features regardless of
> whether the publisher published to Flash 9 or 10 - if the runtime is FP10,
> then I guess it's up-to-you to do stuff and also whether to expose certain
> API's to the publisher?
> >
> > ___
> > Flashcoders mailing list
> > Flashcoders@chattyfig.figleaf.com
> > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
>
> ___
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Getting the url where my Flash movie was embeded

2010-08-13 Thread Juan Pablo Califano
No problem.

I'm glad you sorted it out.

Cheers
Juan Pablo Califano

2010/8/13 Pedder 

> Yeah, that worked.
> The embed code the user can copy from my page now directs to a server
> script "widget.swf" with some parameters. With a htaccess rewrite rule the
> call is redirected to a php script which stores the HTTP_REFERER and returns
> the "real" swf. In my first testings this worked fine. And now i can even
> track how often a swf file is requested.
>
> Thank you Juan ;-)
> Cheers
> Pedder
>
>
> Am 12.08.2010 um 20:04 schrieb Juan Pablo Califano:
>
>
> Maybe you could try a different approach.
>>
>> Although it's not 100% authoritative, the http referrer of the http
>> request
>> made to get your swf could help here. This is data sent by the client (the
>> browser in this case), and might not even be sent to the server, but in
>> almost every case, it is.
>>
>> So, you can check your server's log and filter out requests for your swf.
>> In
>> Apache, at least, the referrer will be logged by default.
>>
>> A little twist to the former could be serving your swf from a server side
>> script. If you are using php, this is quite easy. Instead of giving your
>> users a link to your swf, tell them to link to
>> yourserver.com/your_widget.php. This php file will read and store the
>> referrer and then just return the swf (a simple redirect to your swf will
>> do
>> it).
>>
>> Cheers
>> Juan Pablo Califano
>> 2010/8/12 Pedder 
>>
>> Shit, you're right!
>>>
>>> I realized that i was testing with the debug flash player. I forgot that.
>>> And now all i got is an error number and no error message again.
>>>
>>> Do you have any idea to get the url where my widget was embeded?
>>>
>>>
>>> Am 12.08.2010 um 17:57 schrieb Henrik Andersson:
>>>
>>>
>>> Pedder wrote:
>>>
>>>>
>>>> var search:RegExp = /.+cannot\saccess\s(.+)\./i ;
>>>>>
>>>>>
>>>> That will not work for localized error messages in the localized
>>>> versions
>>>> of the player.
>>>>
>>>> I also have my doubts about it working in non debug players, I think the
>>>> error message is the empty string in those. But I am not sure about
>>>> that.
>>>>
>>>> There is also the point of the message simply changing in the English
>>>> version at some point.
>>>>
>>>> You really shouldn't try to parse stuff that is meant for display.
>>>> ___
>>>> Flashcoders mailing list
>>>> Flashcoders@chattyfig.figleaf.com
>>>> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>>>>
>>>>
>>> ___
>>> Flashcoders mailing list
>>> Flashcoders@chattyfig.figleaf.com
>>> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>>>
>>> ___
>> Flashcoders mailing list
>> Flashcoders@chattyfig.figleaf.com
>> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>>
>
> ___
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Getting the url where my Flash movie was embeded

2010-08-12 Thread Juan Pablo Califano
Maybe you could try a different approach.

Although it's not 100% authoritative, the http referrer of the http request
made to get your swf could help here. This is data sent by the client (the
browser in this case), and might not even be sent to the server, but in
almost every case, it is.

So, you can check your server's log and filter out requests for your swf. In
Apache, at least, the referrer will be logged by default.

A little twist to the former could be serving your swf from a server side
script. If you are using php, this is quite easy. Instead of giving your
users a link to your swf, tell them to link to
yourserver.com/your_widget.php. This php file will read and store the
referrer and then just return the swf (a simple redirect to your swf will do
it).

Cheers
Juan Pablo Califano
2010/8/12 Pedder 

> Shit, you're right!
>
> I realized that i was testing with the debug flash player. I forgot that.
> And now all i got is an error number and no error message again.
>
> Do you have any idea to get the url where my widget was embeded?
>
>
> Am 12.08.2010 um 17:57 schrieb Henrik Andersson:
>
>
> Pedder wrote:
>>
>>> var search:RegExp = /.+cannot\saccess\s(.+)\./i ;
>>>
>>
>> That will not work for localized error messages in the localized versions
>> of the player.
>>
>> I also have my doubts about it working in non debug players, I think the
>> error message is the empty string in those. But I am not sure about that.
>>
>> There is also the point of the message simply changing in the English
>> version at some point.
>>
>> You really shouldn't try to parse stuff that is meant for display.
>> ___
>> Flashcoders mailing list
>> Flashcoders@chattyfig.figleaf.com
>> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>>
>
> ___
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Facebook API GetPhotos not working

2010-08-10 Thread Juan Pablo Califano
It's most likely a permissions problem. Even if your pics are public, you
(as a user) have to grant the app access to your data (except for the most
basic stuff such as name, etc). This wasn't necessary before, if I recall
correctly, but alas, FB API is rather unstable. They seem to change their
minds about how things work all the time (and are not afraid of breaking the
code of the suckers that use their services; you can get away with it if
you're facebook, I guess).

Check this out:

http://code.google.com/p/facebook-actionscript-api/issues/detail?id=146

How do you ask the user for permssions? This doesn't have an easy answer,
I'm afraid. It depends on how your app connects to FB. I've used the
"official" AS library above in one project and I know it's actually a
wrapper around a JS library. Don't remember the specifics, but I do remember
that in all of the client libraries I used (the old JS client, the new JS
client that uses the new Graph API and the PHP client), you can request a
check for permissions when you call the login function; and if said
permissions were not granted, the user will be presented a popup to accept
or deny your app these permissions.

So you have to look up what's the name of the permission (whatever they
decided it to call it this week) and how you can pass that to the JS code
that actually connects to FB (I think there was something for that already
in the AS library, but I'm not positive).

This should solve the problem in most scenarios, I think there are some
cases not covered here, such as if the user is already logged in when they
get to your app; the login method won't be called, so the user won't be
asker for the necessary extended permissions; if they already grant your app
these, no problem; if they don't or they revoked them, you'll have to work
around this somehow. I remember I had to do this a while time ago (using the
new JS client for the Graph API), but it was a mess, and involved using FQL
from JS and whatnot... (all this because there's a very useful method in the
FB API that returns the user status, but they forgot to include the current
permissions granted by the user in the response; so you have to find other
way to get that data, which in my case was using an ad hoc SQLish language
called FQL. -- Sorry, this last paragraph was mostly a rant; developing
against the FB API is a bit frustrating at times...)

An alternative approach I used (but only because I had to use the new Graph
API) was doing something similar to what this guy did:

http://wellconsidered.posterous.com/fbflashbridge-v01

It's not as nice as the "official" library. It's kind of bare bones: some JS
glue code around FB's JS client and a bit of Actionscript to  communicates
with it. You don't have all the typed objects and stuff. I must say,
compared to adobe's lib, it was way easier to debug / troubleshoot, though
(since there's way less code and it's kind of easy to follow it; anyway, I
used this approach because I had to use the graph API, but if I had to do
any other FB app, I think I'd go this way, but that's just me, I guess).

Hope this helps somehow or at least gives you some pointers.

Cheers
Juan Pablo Califano



2010/8/10 David Hunter 

>
> Hi List, . Anyone have any experience with the Facebook API? I have been on
> it all day and got a simple application (based on the tutorial on adobe's
> site) to work which fetches the users information such as name and
> mini-photo, and other calls like listing their friends. But when it comes to
> getting their photos, GetPhotos() it always returns an array of zero length.
> Does anyone have any knowledge on this? . I have seen lots of complaints
> about this issue on the forums, but much of the advice suggests changing
> parameters that don't exist in the application settings anymore. I'm not
> sure if the problem is a permissions thing set in the app, a permissions
> thing set by the user (i have made my photos completely public and still no
> change), if i am lacking a session key, or something else. I imagine/hope
> its something simple. I've tried running as a desktop app and on an external
> webpage but it still won't return any photos. I'm using Flash CS5 and the
> latest version of the Facebook library (v3.4). Unfortunately most of the
> examples are in Flex, which I don't have, and I haven't found a tutorial or
> snippet for straight Actionscript that uses GetPhotos() .. I've been tearing
> my hair out all evening and not got very far. Any help is greatly
> appreciated. . Thanks,David
> ___
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] fileReference failing silently

2010-08-09 Thread Juan Pablo Califano
The issue here is quite likely the garbage collector doing its job...

You FileRefence object is referenced only in a local variable in
the deskClickHandler method. After the method returns, since there's no
other reference to it, it's eligible for collection. So it might stick
around or not. In your case, it seems it doesn't. Try storing the fileref in
an instance variable instead. It should fix it, I think.

Cheers
Juan Pablo Califano

2010/8/9 Matt S. 

> I'm trying to use fileReference to allow users to download images, but
> it keeps failing, without errors, and without even seeming to start
> the download. What makes it weird is that it does open the finder
> window and prompts me to save the select a download location etc, but
> then when I click save...nothing. No errors, no files, just nothing.
> Here is the code I'm currently using (with puppy photo substituted for
> actual content). This is failing both locally and when uploaded to the
> server. Any suggestions much appreciated, I've been googling but
> havent found a solution.
>
> tia,
>
> Matt
>
>
> //CODE
>
>
> private function deskClickHandler(e:MouseEvent):void{
>
>var downloadURL:URLRequest;
>   var fileName:String = "SomeFile.pdf";
>var file:FileReference;
>
>downloadURL = new URLRequest();
>downloadURL.url =
> "http://mystuffspace.com/graphic/adorable-puppies.jpg";;
>file = new FileReference();
>file.addEventListener(ProgressEvent.PROGRESS, progressHandler);
>file.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
>file.addEventListener(Event.COMPLETE, completeHandler);
>file.download(downloadURL, fileName);
> }
>
> private function progressHandler(event:ProgressEvent):void {
>var file:FileReference = FileReference(event.target);
>trace("progressHandler: name=" + file.name + " bytesLoaded=" +
> event.bytesLoaded + " bytesTotal=" + event.bytesTotal);
> }
>
> private function ioErrorHandler(event:IOErrorEvent):void {
>trace("ioErrorHandler: " + event);
> }
>
> private function completeHandler(event:Event):void {
>trace("completeHandler: " + event);
> }
> ___
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] const inside function

2010-08-05 Thread Juan Pablo Califano
The difference is that the reference is constant, meaning you cannot change
it.

You can't do this:

const my_var:String = "my_var";

my_var = "other text";

You could do this if it were declared as a var.

Cheers
Juan Pablo Califano

2010/8/5 Jiri 

> I have a simple question. I came across some code in a project that defines
> a const in a function.
>
> function doSomething():void{
>const my_var:String = "my_var"
>
>var buffer:String = '';
>
>for(var i:int = 0 ; ibuffer += list[i] + my_var
>}
> }
>
> What is the difference compared to this:
>
> function doSomething():void{
>var my_var:String = "my_var"
>var buffer:String = '';
>
>for(var i:int = 0 ; ibuffer += list[i] + my_var
>}
> }
>
> Regards,
>
> Jiri
> ___
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Question on variable init in a for loop

2010-08-04 Thread Juan Pablo Califano
 Agreed, that was over simplified.

I probably should have said clearly I was using "global" in a rather loose
way -- as opposed to function local; that's why I put the quotes. I just
wanted to point out what the problem was in the original question, in a
simple way, without getting into activation objects and other stuff.

Thanks for your clarifications.

Cheers
Juan Pablo Califano

2010/8/4 Kevin Newman 

>  That's an over simplification of the scope chain properties of AS3, and
> "global" isn't the right word there (though I know what you meant).
>
> To clarify the scope chain issue, keep in mind that you can nest function
> scopes to create a hierarchy of scopes with a closure (usually this is
> difficult for new devs in ECMAScript languages like AS3 and Javascript to
> grasp). So "global" really just refers to the top of the scope chain.
>
> Additionally, there are also as file level scopes. For example, in a file
> named getURL.as:
>
> package {
>function getURL() {
>trace(topScopeVar);
>}
> }
> var topScopeVar:String = "Hello world!";
>
>
> That "topScopeVar" is only accessible from within that as file, because it
> is at the top of that file's individual scope chain. A function or class in
> a different as file would not have access to that variable, and this class
> has no access to other seemingly "global" scopes either, like the timeline,
> or other as files.
>
> functions and classes defined in root packages, and available in the class
> path, those are global, and you can define a property on those (static var
> on a class for example) - that's about as close as you get to a global in
> AS3.
>
> Kevin N.
>
>
>
>
> On 8/4/10 9:21 AM, Juan Pablo Califano wrote:
>
>> In actionscript you have only local and "global" scope. Meaning a variable
>> can be declared as local to the function or in the class that contains it.
>> Other languages allow for creating further scopes.
>>
>
>  ___
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Question on variable init in a for loop

2010-08-04 Thread Juan Pablo Califano
In actionscript you have only local and "global" scope. Meaning a variable
can be declared as local to the function or in the class that contains it.
Other languages allow for creating further scopes. In Java, C, C++, C#, for
instance, you can do something like this:

int i = 0;
{// this creates a new scope
int i = 8;
}

And you will get 2 different variables. Obviously, naming both the same is
not the smartest move, but it's legal (at least in C#, if I recall
correctly).

Also when you write a loop, the counter var will be local if declared in the
loop. I mean this:

for(int i = 0; i < 10; i++) {
// do something with i
}

//this is invalid, i doesn not exist here...
i = 20;

Now, in Actionscript this is not possible. You can declare a variable
wherever you like. The compiler ends up moving the variable to the top of
the scope when generating the bytecode (I think this is called hoisting).

So this:

var l:Array = [{},{}]
function test():void{
   for each(var i:Object in l){
   var id:String;// = null;
   trace("1" ,id);
   id = "test" + Math.random().toString();
   trace("2" ,id);
   }
}

Is equivalent to writting this:

var l:Array = [{},{}]
function test():void{
var id:String;// = null;
for each(var i:Object in l){
   trace("1" ,id);
   id = "test" + Math.random().toString();
   trace("2" ,id);
   }
}

"id" will be declared (and initialized to null) only once, before you access
it in your code. So you only have one variable, really and that's the reason
for the behavior you observed.

Cheers
Juan Pablo Califano

2010/8/4 Jiri 

> I have the following case:
>
> var l:Array = [{},{}]
> function test():void{
>for each(var i:Object in l){
>var id:String;// = null;
>trace("1" ,id);
>id = "test" + Math.random().toString();
>trace("2" ,id);
>}
> }
>
> I seems that 'id' is not resetted to null on every iteration as I would
> expect. I have to explicitly set the id to null myself! Does some know why
> this is, or are my expectations just wrong.
>
>
> Jiri
> ___
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] using fscommand or externalInterface - no luck

2010-07-29 Thread Juan Pablo Califano
Check the allowscriptaccess property in your embed code. By default it's
"samedomain", I think, so if your swf and your html are in the same domain,
it should work without changing anythig, but it's worth checking

For instance, if you are using SWFObject and want to allow access from other
domains, you could do something like this:

so.addParam("allowscriptaccess","always");
Cheers
Juan Pablo Califano


2010/7/29 Boyd Speer 

> I am attempting to use either fscommand or external interface to tell the
> browser to load another .html file but can't seem to get it to work .. am I
> missing something regarding permissions or some other setting in the publish
> settings? (using Flash CS5, publishing  html with fscommand) tried to test
> the fscommand by using:  alert(command); but nothing happens- same with
> location = command (where command is the URL string). When I try
> navigateToURL(locationstring) within flash I get the same results. It must
> be something simple but too many late nights recently...  :)
>
> Thanks for any insights.
> -Boyd
>
> ___
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] SCORM Q - Strategies for saving large suspend data strings

2010-07-28 Thread Juan Pablo Califano
PS: Just made a quick test with a rather big xml and this is what I got
(sizes are in bytes):

xml:   49725
compressed bytearray: 9488
compressed bytearray + base 64: 12652

The figures may vary as the compression depends on the data, but at least
here I got about a 1/4 of the original size after encoding to base 64, which
is not bad, I'd say.

Cheers
Juan Pablo Califano

2010/7/28 Juan Pablo Califano 

> I'm not sure you are really going to gain that much by using JSON instead
> of XML.
>
> ByteArrays have built-in compression as you mention (I think the
> compression algorithm zlib). Since XMLs generally have a fair amount of
> redundancy, it will probably reduce the size of your data (in bytes)
> considerably. To be safe, encode the bytearray to base 64 and store that.
> Base 64 means 1/3 overhead (for every 3 bytes in, you get 4 bytes out).
> Still, it'll probably be smaller than the equivalent JSON (though you might
> want to test it and see if this is true).
>
> Cheers
> Juan Pablo Califano
>
> 2010/7/28 Matt Perkins 
>
> Wondering if someone has had this problem and found a good solution ...
>>
>> I've developed a social simulation that has a lot of data that i need to
>> save between user sessions in the suspend_data SCORM variable to our LMS.
>> I'm formatting this data as XML since 1, has a good structure and 2, i know
>> it. Suspend_data only has 4k of space and my XML (as a string) is pretty big
>> - doubly so since the LMS encodes it and all of the single char <, > and /'s
>> get turned into 4 chars. But i've used attributes and 1-2 char tag names
>> where i can.
>>
>> I'm going to try to compress the string with ByteArray and see if that
>> helps, but I'm not sure if the "special characters" will mess with the LMS
>> communication - I've had that happen many times before with just HTML page
>> text.
>>
>> Other option is to learn JSON and do it that way.
>>
>> Have anyone else faced something like this and solved it?
>>
>> --
>> Matt Perkins
>> 
>> http://www.nudoru.com
>>
>> ___
>> Flashcoders mailing list
>> Flashcoders@chattyfig.figleaf.com
>> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>>
>
>
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] SCORM Q - Strategies for saving large suspend data strings

2010-07-28 Thread Juan Pablo Califano
I'm not sure you are really going to gain that much by using JSON instead of
XML.

ByteArrays have built-in compression as you mention (I think the compression
algorithm zlib). Since XMLs generally have a fair amount of redundancy, it
will probably reduce the size of your data (in bytes) considerably. To be
safe, encode the bytearray to base 64 and store that. Base 64 means 1/3
overhead (for every 3 bytes in, you get 4 bytes out). Still, it'll probably
be smaller than the equivalent JSON (though you might want to test it and
see if this is true).

Cheers
Juan Pablo Califano

2010/7/28 Matt Perkins 

> Wondering if someone has had this problem and found a good solution ...
>
> I've developed a social simulation that has a lot of data that i need to
> save between user sessions in the suspend_data SCORM variable to our LMS.
> I'm formatting this data as XML since 1, has a good structure and 2, i know
> it. Suspend_data only has 4k of space and my XML (as a string) is pretty big
> - doubly so since the LMS encodes it and all of the single char <, > and /'s
> get turned into 4 chars. But i've used attributes and 1-2 char tag names
> where i can.
>
> I'm going to try to compress the string with ByteArray and see if that
> helps, but I'm not sure if the "special characters" will mess with the LMS
> communication - I've had that happen many times before with just HTML page
> text.
>
> Other option is to learn JSON and do it that way.
>
> Have anyone else faced something like this and solved it?
>
> --
> Matt Perkins
> 
> http://www.nudoru.com
>
> ___
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Listeners (was no subject)

2010-07-28 Thread Juan Pablo Califano
Sigh... Did you actually bother to read what I wrote?

>>>
But note I made a distinction between the dispatcher - the object that
performs the callback, directly or through dispatchEvent - and the code
(let's refer to it as the "first caller") that calls the method that
contains the dispatcher.
>>>



2010/7/28 Henrik Andersson 

> The dispatcher is not in your code here. The method does not dispatch the
> event. It causes it to be dispatched later.
>
>
> ___
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Listeners (was no subject)

2010-07-28 Thread Juan Pablo Califano
Maybe you didn't read what I worte carefully or maybe I didn't explain it
clearly enough. But note I made a distinction between the dispatcher - the
object that performs the callback, directly or through dispatchEvent - and
the code (let's refer to it as the "first caller") that calls the method
that contains the dispatcher.

Now, what I mean, and I repeat it now, is that if the dispatch is
synchronous or asynchronous changes the stack call: in the first case the
"first caller" will be on the stack; in the second, it won't.

Perhaps this code makes this easier to see (modified from the previously
posted code):

package {
import flash.display.Sprite;
import flash.events.Event;

public class Main extends Sprite {

public function Main():void {
runTest();
}

private function runTest():void {
var callbackTest:Tester = new Tester();
callbackTest.run(callback);
var eventTester:Tester = new Tester();
eventTester.addEventListener(Event.COMPLETE,handleComplete);
eventTester.run(null);
}

private function handleComplete(evt:Event):void {
trace("entering handler");
var stacktrace:String = new Error().getStackTrace();
trace(stacktrace);
trace("returning from handler");
}

private function callback(evt:Event):void {
trace("entering callback");
var stacktrace:String = new Error().getStackTrace();
trace(stacktrace);
trace("returning from callback");
}
}
}

import flash.events.Event;
import flash.events.EventDispatcher;
import flash.utils.setTimeout;


class Tester extends EventDispatcher {

public function Tester() {

}

public function run(callback:Function):void {
setTimeout(function():void {
trace("entering run");
if(callback != null) {
callback(new Event(Event.COMPLETE));
} else {
dispatchEvent(new Event(Event.COMPLETE));
}
trace("returning from run");
trace("");
},1);
}
}

Just added a setTimeout to ensure it's asynchronous, but the same will
happen if you load external content, for instance.

As you can see, runTest() (the "first caller") is not in the call stack in
this case (while it was where the dispatch was synchronous):

entering run
entering callback
Error
 at Main/callback()[Main.as:28]
 at ()[Main.as:51]
 at Function/http://adobe.com/AS3/2006/builtin::apply()
 at SetIntervalTimer/onTimer()
 at flash.utils::Timer/_timerDispatch()
 at flash.utils::Timer/tick()
returning from callback
returning from run


Cheers
Juan Pablo Califano



2010/7/28 Henrik Andersson 

> Juan Pablo Califano wrote:
>
>> Yes, the dispatcher and the listener are both in the same call stack
>> always,
>> but I think what we were discussing is whether the caller (the original
>> caller, the one that calls the method that will eventually dispatch the
>> event) is in the same callstack as the listener / event handler. That's
>> not
>> always the case, as it depends on whether the event is dispatched
>> synchronously or not.
>>
>
> If you call a method, you will be guaranteed that you will not resume
> execution while the method is executing. If that method dispatches any
> events, you will be in the callstack. There is no other scenarios where the
> method does dispatch the event.
>
> ___
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Listeners (was no subject)

2010-07-28 Thread Juan Pablo Califano
Yes, the dispatcher and the listener are both in the same call stack always,
but I think what we were discussing is whether the caller (the original
caller, the one that calls the method that will eventually dispatch the
event) is in the same callstack as the listener / event handler. That's not
always the case, as it depends on whether the event is dispatched
synchronously or not.

Cheers
Juan Pablo Califano


2010/7/28 Henrik Andersson 

> Kerry Thompson wrote:
>
>> I agree with everything you say, up to that point. There is a
>> fundamental difference in the way callbacks and messages work. A
>> callback puts the caller on the call stack, and control will
>> eventually return to that calling method. A message does not put the
>> sender on the call stack.
>>
>>
> Have you ever glanced at the callstack in the debugger while in a listener?
> It is very clearly the same callstack both for the dispatcher and the
> listener.
>
> ___
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Listeners (was no subject)

2010-07-27 Thread Juan Pablo Califano
>>>
I agree with everything you say, up to that point. There is a
fundamental difference in the way callbacks and messages work. A
callback puts the caller on the call stack, and control will
eventually return to that calling method. A message does not put the
sender on the call stack.
>>>

Well, that's what happens in most cases, but as I said before, it's not
because of how event dispatching works, but rather because most events are
dispatched asynchronously (or most events dispatched by the player itself
anyway, such as those fired by loaders, mouse interaction, etc).

But, my point was that the event dispatching mechanism is not inherently
asynchronous. So an event handler could be called just like any other
callback.

To make my point more clear, consider this code and look the stacktraces it
prints out:


package {
import flash.display.Sprite;
import flash.events.Event;
 public class Main extends Sprite {
 public function Main():void {
runTest();
}
 private function runTest():void {
var callbackTest:Tester = new Tester();
callbackTest.run(callback);
 var eventTester:Tester = new Tester();
eventTester.addEventListener(Event.COMPLETE,handleComplete);
eventTester.run(null);
}
 private function handleComplete(evt:Event):void {
trace("entering handler");
var stacktrace:String = new Error().getStackTrace();
trace(stacktrace);
trace("returning from handler");
}
 private function callback(evt:Event):void {
trace("entering callback");
var stacktrace:String = new Error().getStackTrace();
trace(stacktrace);
trace("returning from callback");
}
 }
}
import flash.events.Event;
import flash.events.EventDispatcher;

class Tester extends EventDispatcher {

public function Tester() {
}
 public function run(callback:Function):void {
trace("entering run");
if(callback != null) {
callback(new Event(Event.COMPLETE));
} else {
dispatchEvent(new Event(Event.COMPLETE));
}
trace("returning from run");
trace("");
}
}

The results are:

entering run
entering callback
Error
at Main/callback()[Main.as:29]
at Tester/run()[Main.as:49]
at Main/runTest()[Main.as:13]
at Main()[Main.as:8]
returning from callback
returning from run

entering run
entering handler
Error
at Main/handleComplete()[Main.as:22]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at Tester/run()[Main.as:51]
at Main/runTest()Main.as:17]
at Main()[Main.as:8]
returning from handler
returning from run


If you factor out the 2 native methods involving in calling the event
dispatching (which are there just because of the generic nature of
dispatching as opposed to having your callbacks hardcoded), the call stack
looks exactly the same both for the direct callback and the event case.

Cheers
Juan Pablo Califano


2010/7/27 Kerry Thompson 

> Juan Pablo Califano wrote:
>
> > I agree on your point of custom events being cleaner and easier to
> follow.
> > In a way, it's like using an Object and defining a class.  > At the end of the day, Events *are* callbacks. There isn't
> > anything inherintly different in how they work.
>
> I agree with everything you say, up to that point. There is a
> fundamental difference in the way callbacks and messages work. A
> callback puts the caller on the call stack, and control will
> eventually return to that calling method. A message does not put the
> sender on the call stack.
>
> It's entirely possible that you will have obscure bugs using messages.
> Even the best of coders will occasionally code him/herself into a
> corner. And yes, sometimes a bug involving a message is harder to find
> than one involving a callback. That's the exception, though, and not
> the rule. Like any job, we go with the percentages, and they're pretty
> heavily in favor of messages.
>
> I do reiterate, though, that custom messages are for
> intermediate-level and above programmes. They're not for novices.
> Chances are that novices will have some work to do getting their minds
> around the concept of messaging. Once you do that, you have unlocked
> one of the most powerful features of AS3.
>
> Cordially,
>
> Kerry Thompson
> ___
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Listeners (was no subject)

2010-07-27 Thread Juan Pablo Califano
I agree on your point of custom events being cleaner and easier to follow.
In a way, it's like using an Object and defining a class. You can get away
with both, and both could be fine. Defining a custom class, although it's
some more work upfront, pays off in most cases. Maybe I'm spoiled at this
point, but just having the compiler type-checking and auto-completion makes
a huge difference. A callback, on the other hand, offers a simpler
interface, but it's less self-documenting (now, if you were able to use some
kind of typedef's for functions -I think haxe has this feature-, it would be
another thing).

I tend to use callbacks especially for onliners or where I don't need much
control from the caller (in cases where you just want to signal "this is
done" or "this has failed", that sort of thing).

I'm not sure I agree about callbacks potentially leading to hard-to-find
bugs, though. At the end of the day, Events *are* callbacks. There isn't
anything inherintly different in how they work. It's true that most events
are dispatched asynchronously (those dispatched by most of the player's
APIs), but Events per se are not asynchronous. I found out this the hard
way, some time ago, when I had to spend a couple of hours tracking a rare
bug in some app I was writting. It took me a while to realized that some
function that dispatched an event was being re entered because of a not so
obvious side-effect (when the caller received the message, under certain
circumstances, it called some code that ended up calling code that ran this
function; it was my fault and the code at that point was rather a mess, but
I didn't consider the possibility of the function being re-entered because I
-mistakenly- though that events were asynchronous; I think I wouldn't have
had much problem diagnosing that bug if I were using callbacks in that
case).

Cheers
Juan Pablo Califano

2010/7/27 Kerry Thompson 

> Henrik Andersson wrote:
>
> > Custom events are usually overkill.
>
> If I understand you correctly, Henrik, I disagree. Custom events are
> incredibly useful.
>
> AS3 is event-driven, and I routinely have all sorts of custom events.
> In a recent game, I added event listeners to 7 different custom events
> in the main class's constructor. When an animation in a MC finishes,
> the MC sends the ANIMATION_FINISHED message. When the timer fires, it
> sends another message. When the student answers a question, I send
> another message.
>
> I have a class that extends Event, and custom events are defined in
> this class. So, when you send a custom event, you get an event object
> just as you would with a system event.
>
> To me, this is a lot cleaner and easier to follow than callbacks or
> calls to other methods. It's also less prone to mysterious bugs--when
> you call a method, it always returns to the caller. If that caller no
> longer exists, you get a crash that can be very hard to diagnose. When
> you send a custom message, the code doesn't automatically return to
> the sender.
>
> Or, perhaps I misunderstood your meaning.
>
> Cordially,
>
> Kerry Thompson
> ___
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] display list overrides keyframes

2010-06-21 Thread Juan Pablo Califano
A possible workaround could be adding a reset method that (re)initalizes the
behaviour. You could move your constructor logic to this method. So, your
constructor calls reset() when the object is first instantiated. Then, when
neccesary, you could call this method to reset the behaviours (in a frame
script in the timeline or where your code issues the gotoAndStop or
gotoAndPlay that changes the frame).

Hope this helps.

Cheers
Juan Pablo Califano


2010/6/21 Tony Fairfield 

> Is there a way to overcome the following:
>
>
>
> I have a timeline file, with quiz buttons on each frame. Each button is
> a duplicate of one basic movie clip with a linked class and a
> constructor that initializes the behaviour -- rollovers etc. For each
> frame, the buttons are named "a1", "a2, "a3" etc. The problem is, I
> foolishly assumed that a new keyframe meant these would be considered
> all brand new buttons by Flash, and their constructor functions would
> dutifully fire afresh, and all would be well. Of course, they don't: as
> far as the Display List is concerned, if there was a button called "a1"
> in frame 1, and if there's a button with the same name in frame 2, they
> are exactly the same button, to hell with the keyframe. Hence, no
> buttons after frame 1 will fire their constructor function. Even the
> state of the previous button -- if it had been selected - is applied to
> the new button with the same name.
>
>
>
> Normally, I would have built something like this dynamically, adding and
> removing the buttons, but I was given an exisitng file that was quicker
> (I thought) to work with as is, than to rework into a single frame,
> dynamic file. I'm probably just going about things the wrong way. I hope
> this is a fairly garden variety issue with a solution (other than
> abandoning the timeline approach).
>
>
>
> Thanks for any input.
>
>
>
> Tony Fairfield
> Programmer
> Lifelearn, Inc.
>
> 67 Watson Road S, Unit 5
> Guelph, ON  N1L 1E3
> www.lifelearn.com <http://www.lifelearn.com>
>
> T: 519-767-5043
> F: 519-767-1101
>
>
>
> ___
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] regExp

2010-06-17 Thread Juan Pablo Califano
If don't want to learn the ascii codes by heart (or look them up), you can
use charCodeAt() like this:

var first:int = ("A").charCodeAt(0);
var last:int = ("Z").charCodeAt(0);

for (var i:int = first; i <= last; i++) {
 trace(String.fromCharCode(i));
}

Cheers
Juan Pablo Califano
2010/6/17 Karl DeSaulniers 

> Ah thanks Steve.
> So is 97 to 123 the placement of upper and lowercase letters and the
> numbers on the CharCode chart?
> and are the upper and lowercase letters 32 letters apart on the chart?
> Trying to understand where you got these values. Your solution is very good
> and interesting to me.
> Also, why random off of 62? Is that the total characters in the array
> alphaNumeric?
> Thank you for this.
>
> Karl
>
>
>
> On Jun 17, 2010, at 12:57 AM, Steven Sacks wrote:
>
> RegEx isn't really used for what you're talking about.
>>
>> You should use ascii codes to create your alphanumeric array and then
>> choose random indexes from  it to create your random string.
>>
>> var i:int;
>> var alphaNumeric:Array = [];
>> for (i = 97; i < 123; ++i)
>> {
>>alphaNumeric.push(String.fromCharCode(i));
>>alphaNumeric.push(String.fromCharCode(i - 32));
>> }
>> for (i = 0; i < 10; ++i)
>> {
>>alphaNumeric.push(i);
>> }
>> function getRandomString(i:int):String
>> {
>>var str:String = "";
>>while (i--)
>>{
>>str += alphaNumeric[Math.round(Math.random() * 62)];
>>}
>>return str;
>> }
>>
>> trace(getRandomString(8));
>> -- lKzU4e0X
>>
>> It's worth pointing out that Math.random() is merely decent at generating
>> random values. If you really need random values, it is better to use
>> something like the Parker Miller pseudo-random number generator.
>>
>> http://www.gskinner.com/blog/archives/2008/01/source_code_see.html
>> ___
>> Flashcoders mailing list
>> Flashcoders@chattyfig.figleaf.com
>> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>>
>
> Karl DeSaulniers
> Design Drumm
> http://designdrumm.com
>
> ___
>  Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Text area focus

2010-06-17 Thread Juan Pablo Califano
Karl, I'm not sure how to benchmark memory in AS 2. I think that what you
might want to benchmark here is cpu performance, anyway.

In this particular case, I don't think you can benchmark much, though.
Basically, all performance benchmarks I've seen are based on getTimer (two
simple calls to getTimer, one before running the code you're interested in,
and one after; the difference is very roughly how much your code took to
run; there are more sophisticated suites (like Grant Skinner's), but to my
knowledge, all are based on the same principle).

The problem here is that what seems to be taking too long is an internal
mechanism of the player (managing and dispatching onChanged, for instance).
Can't think of a way of timing that off the top of my head.

If one the methods runs your fan wild and the other one doesn't, though, you
have a clear winner already!

Cheers
Juan Pablo Califano


2010/6/16 Karl DeSaulniers 

> On that note, what would be a good way to get a benchmark for this?
> Any pointers?
>
> Karl
>
>
> On Jun 16, 2010, at 3:47 PM, Karl DeSaulniers wrote:
>
> Ahh.. let me try that.
>> I am sure you are correct.
>> That way it only checks to see if that textField is changing when focus is
>> on it.
>> And being that onChanged was less memory intensive than onEnterFrame
>> that makes sense. But my tests are not finite.
>> I do not have a benchmark result or anything stating
>> how much memory my swf is using while in the browser.
>> But it would seem the onSetFocus/onKillFocus keeps any extra memory from
>> being used in either case.
>> Thanks again Juan.
>>
>>
>> Karl
>>
>>
>> On Jun 16, 2010, at 8:09 AM, Juan Pablo Califano wrote:
>>
>> Not really. In theory, onChanged should be less intensive, I think. But,
>>> from your description it seems it isn't, so go figure...
>>>
>>> I'd go with the onSetFocus / onKillFocus then, but I'd do another test,
>>> just
>>> out of curiosity. Instead of setting an enterframe when you get focus and
>>> nulling it when focus is lost, what happens is you use the onChanged
>>> event
>>> instead?
>>>
>>> I mean, something like:
>>>
>>> textbox.onSetFocus = function() {
>>>   textbox.onChanged = etc...;
>>> };
>>> textbox.onKillFocus = function() {
>>>   textbox.onChanged = null;
>>> }
>>> Cheers
>>> Juan Pablo Califano
>>>
>>> 2010/6/16 Karl DeSaulniers 
>>>
>>> Hi Juan,
>>>> Interesting enough, it seems your solution also runs my fan a bit wild
>>>> too.
>>>> Not as bad, I'd say about half as much.
>>>> I know its the form because I have tested many times. Every time I close
>>>> the browser window that has the form, my fan slows to a stop almost
>>>> immediately.
>>>> I chose the onFocus mainly because I knew that it was the onEnterFrame
>>>> that
>>>> was taking up memory, so I wanted it to fire only when someone was
>>>> typing.
>>>> It looks like my suggestion does just that. The fan never kicks on.
>>>>
>>>> My purpose for this is to set up a flash site that takes little to no
>>>> memory usage.
>>>> Am I right in assuming that this is memory usage by the code that makes
>>>> my
>>>> fan kick in.
>>>> I've been nulling any onEnterFrames, removing listeners, etc.
>>>> Any thoughts as to why the onChanged eats memory too?
>>>> TIA
>>>>
>>>> Karl
>>>>
>>>>
>>>> On Jun 15, 2010, at 9:56 PM, Juan Pablo Califano wrote:
>>>>
>>>>  It seems like you don't really need to bother about gaining or losing
>>>>
>>>>> focus
>>>>> here. Just listening to the change event will do the job and you could
>>>>> remove the enter_frame.
>>>>>
>>>>>
>>>>> commentxt_mc.onChanged = function(tf:TextField):Void {
>>>>>  var numChar:Number = 650 - tf.length;
>>>>>  if (numChar == 0) {
>>>>>  maxChar = "Max Characters Reached";
>>>>>  } else {
>>>>>  maxChar = "Max Char: " + numChar.toString(); //Have
>>>>> another
>>>>> text box with the var maxChar to display the results while typing.
>>>>>  }
>>>>> };
>>>>>
>>>>> The equivalent in AS 3.0 is very simi

Re: [Flashcoders] CameraDetection Update

2010-06-16 Thread Juan Pablo Califano
Hi Ktu,

I told you when you shared your code in this list I'd give you some
feedback. I ended up using it a couple of months after that and totally
forgot about telling you how it went, so sorry about that.

But yes, it worked out great for Macs, which was the problem I was trying to
solve.

As I mentioned in my answer in SO, the code failed to get the correct camera
for some laptops. I tried it in 2 machines, one was a Toshiba, the other one
I can't remember for sure, but I think it was an HP. In both cases, it was
Windows, one was running XP, the other one was running Vista, IIRC. The
cameras were the ones that come built into the computer.

I noticed I could detect those cameras fine the "regular way", and since I
was in a rush, I just checked if the client was running Mac or not. If Mac,
I used your code; if not, just went with the "regular way" (read, calling
getCamera naively). I really didn't put much though to it; it just worked in
the cases I tested and since the time frame was rather limiting, I left it
that way. So that's why I mentioned some other possible cases were it could
fail. Not that I found them, but I didn't test thoroughly either.

Anyway, thanks for your class, it was very helpful (and I apologize
again for not giving you proper feedback at the moment, as I said I would!
But better late than never)

Cheers
Juan Pablo Califano

2010/6/16 Ktu 

> Hey List,
>
> Thanks to Ben and Juan I have made an update to my CameraDetection class.
>
> ChangeLog:
> force settings dialog to open every time unless camera access is already
> allowed
> implement timer for checking permissions, sometimes the settings dialog
> does
> not dispatch
> some logic updates
> cleaner code (only 3 magic values)
>
> Check it out: link <http://blog.cataclysmicrewind.com/webcamdetection>
>
> Juan Pablo Califano!
> I noticed today that it was your response to a question on
> stackoverflow.comthat led Ben to my class. Thank you very much I
> greatly appreciate that. I
> also noticed that you mentioned my class had some problem with certain
> Windows laptops. Can you elaborate about when you said in the post that
> you're "not sure if it covers some corner cases?" I would love to know so I
> can help make it cover those cases. Thanks
>
> Ktu;
> ___
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Text area focus

2010-06-16 Thread Juan Pablo Califano
Not really. In theory, onChanged should be less intensive, I think. But,
from your description it seems it isn't, so go figure...

I'd go with the onSetFocus / onKillFocus then, but I'd do another test, just
out of curiosity. Instead of setting an enterframe when you get focus and
nulling it when focus is lost, what happens is you use the onChanged event
instead?

I mean, something like:

textbox.onSetFocus = function() {
   textbox.onChanged = etc...;
};
textbox.onKillFocus = function() {
   textbox.onChanged = null;
}
Cheers
Juan Pablo Califano

2010/6/16 Karl DeSaulniers 

> Hi Juan,
> Interesting enough, it seems your solution also runs my fan a bit wild too.
> Not as bad, I'd say about half as much.
> I know its the form because I have tested many times. Every time I close
> the browser window that has the form, my fan slows to a stop almost
> immediately.
> I chose the onFocus mainly because I knew that it was the onEnterFrame that
> was taking up memory, so I wanted it to fire only when someone was typing.
> It looks like my suggestion does just that. The fan never kicks on.
>
> My purpose for this is to set up a flash site that takes little to no
> memory usage.
> Am I right in assuming that this is memory usage by the code that makes my
> fan kick in.
> I've been nulling any onEnterFrames, removing listeners, etc.
> Any thoughts as to why the onChanged eats memory too?
> TIA
>
> Karl
>
>
> On Jun 15, 2010, at 9:56 PM, Juan Pablo Califano wrote:
>
>   It seems like you don't really need to bother about gaining or losing
>> focus
>> here. Just listening to the change event will do the job and you could
>> remove the enter_frame.
>>
>>
>> commentxt_mc.onChanged = function(tf:TextField):Void {
>>   var numChar:Number = 650 - tf.length;
>>   if (numChar == 0) {
>>   maxChar = "Max Characters Reached";
>>   } else {
>>   maxChar = "Max Char: " + numChar.toString(); //Have another
>> text box with the var maxChar to display the results while typing.
>>   }
>> };
>>
>> The equivalent in AS 3.0 is very similar, though a bit more verbose (as
>> usual!):
>>
>> commentxt_mc.addEventListener(Event.CHANGE,handleTextChange);
>>
>> function handleTextChange(e:Event):void {
>> var tf:TextField = e.target as TextField;
>> if(!tf) {
>> return;
>> }
>> var numChar:Number = 650 - tf.length;
>> var maxChar:String = "";
>> if (numChar == 0) {
>> maxChar = "Max Characters Reached";
>> } else {
>> maxChar = "Max Char: " + numChar.toString(); //Have another text box with
>> the var maxChar to display the results while typing.
>> }
>> }
>>
>> Cheers
>> Juan Pablo Califano
>>
>> 2010/6/15 Karl DeSaulniers 
>>
>> PERFECTO!
>>>
>>> Thanks Amol,
>>>
>>> For anyone who might want this. I have made a script that will read the
>>> length of a text field and display the number of characters left while
>>> someone was typing.
>>> The reason for the code I was seeking with this request was because the
>>> code previously would eat up a lot of memory. It made my computer fan run
>>> wild if the form sat in my browser.
>>> Now it does not thanks to Amol.  :))
>>>
>>> Here is the code competed. Again, it is as2, but would love to see an as3
>>> conversion.
>>> I might get to that later, but welcome any comers.
>>>
>>> //commentxt_mc is the textfield name, 650 is the number of characters
>>> allowed. You will also want to set the text box max characters to this
>>> when
>>> creating your text box.
>>> var numChar;
>>> commentxt_mc.onSetFocus = function() {
>>>  onEnterFrame = function() {
>>>   numChar = 650 - commentxt_mc.length;
>>>   if (numChar == 0) {
>>>   maxChar = "Max Characters Reached";
>>>   } else {
>>>   maxChar = "Max Char: " + numChar.toString(); //Have another
>>> text box with the var maxChar to display the results while typing.
>>>   }
>>>  }
>>> };
>>> commentxt_mc.onKillFocus = function() {
>>>  onEnterFrame = null;
>>> };
>>>
>>> Best,
>>>
>>> Karl
>>>
>>>
>>>
>>> On Jun 15, 2010, at 1:34 AM, Amol wrote:
>>>
>>>  Hi,
>>>
>>>>
>>>> use set fouse  for text ,
>>>>
>>>> sample_txt.

Re: [Flashcoders] Text area focus

2010-06-15 Thread Juan Pablo Califano
It seems like you don't really need to bother about gaining or losing focus
here. Just listening to the change event will do the job and you could
remove the enter_frame.


commentxt_mc.onChanged = function(tf:TextField):Void {
   var numChar:Number = 650 - tf.length;
   if (numChar == 0) {
   maxChar = "Max Characters Reached";
   } else {
   maxChar = "Max Char: " + numChar.toString(); //Have another
text box with the var maxChar to display the results while typing.
   }
};

The equivalent in AS 3.0 is very similar, though a bit more verbose (as
usual!):

commentxt_mc.addEventListener(Event.CHANGE,handleTextChange);

function handleTextChange(e:Event):void {
var tf:TextField = e.target as TextField;
if(!tf) {
return;
}
var numChar:Number = 650 - tf.length;
var maxChar:String = "";
if (numChar == 0) {
maxChar = "Max Characters Reached";
} else {
maxChar = "Max Char: " + numChar.toString(); //Have another text box with
the var maxChar to display the results while typing.
}
}

Cheers
Juan Pablo Califano

2010/6/15 Karl DeSaulniers 

> PERFECTO!
>
> Thanks Amol,
>
> For anyone who might want this. I have made a script that will read the
> length of a text field and display the number of characters left while
> someone was typing.
> The reason for the code I was seeking with this request was because the
> code previously would eat up a lot of memory. It made my computer fan run
> wild if the form sat in my browser.
> Now it does not thanks to Amol.  :))
>
> Here is the code competed. Again, it is as2, but would love to see an as3
> conversion.
> I might get to that later, but welcome any comers.
>
> //commentxt_mc is the textfield name, 650 is the number of characters
> allowed. You will also want to set the text box max characters to this when
> creating your text box.
> var numChar;
> commentxt_mc.onSetFocus = function() {
>   onEnterFrame = function() {
>numChar = 650 - commentxt_mc.length;
>if (numChar == 0) {
>maxChar = "Max Characters Reached";
>} else {
>maxChar = "Max Char: " + numChar.toString(); //Have another
> text box with the var maxChar to display the results while typing.
>}
>   }
> };
> commentxt_mc.onKillFocus = function() {
>  onEnterFrame = null;
> };
>
> Best,
>
> Karl
>
>
>
> On Jun 15, 2010, at 1:34 AM, Amol wrote:
>
>  Hi,
>>
>> use set fouse  for text ,
>>
>> sample_txt.onSetFocus = sample1_txt.onSetFocus = function ()
>> {
>>   this.border = true;
>>   this.borderColor = 13683368;
>>   this.background = true;
>>   this.backgroundColor = 13683368;
>> };
>> sample_txt.onKillFocus = sample1_txt.onKillFocus = function ()
>> {
>>   this.border = true;
>>   this.borderColor = 0;
>>   this.background = true;
>>   this.backgroundColor = 0;
>> };
>>
>>
>> Regards amol
>>
>>
>>
>>
>> - Original Message - From: "Karl DeSaulniers" <
>> k...@designdrumm.com>
>> To: "Flash List" 
>> Sent: Tuesday, June 15, 2010 9:51 AM
>> Subject: [Flashcoders] Text area focus
>>
>>
>>  Hello,
>>> I have a text box or area on a form that I would like to know when a
>>>  user has put the cursor in it or not.
>>> Wither it has focus or not. I am working in AS2. Please don't grit  your
>>> teeth too much :-)
>>> For some reason I am not able to get the focus of my text area.
>>> Anyone have this code in their scrap files?.. lol
>>> TIA
>>> Karl DeSaulniers
>>> Design Drumm
>>> http://designdrumm.com
>>> ___
>>> Flashcoders mailing list
>>> Flashcoders@chattyfig.figleaf.com
>>> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>>>
>>>  ___
>> Flashcoders mailing list
>> Flashcoders@chattyfig.figleaf.com
>> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>>
>
> Karl DeSaulniers
> Design Drumm
> http://designdrumm.com
>
> ___
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] swf compressing

2010-06-10 Thread Juan Pablo Califano
Are the swf themselves compressed?

If not, you could give flasm a chance (http://www.nowrap.de/flasm.html).

There's a switch that compresses the swf (-z). It's not the same as
compressing the images separately, of course. But, if the swfs and the
images are not compressed, the images should have at least some redundancy
and compressing the whole swf might be of some help (though zlib is not
going to be as good for compression as JPG or PNG). I'm just guessing, but
maybe it's worth giving it a shot, since it's rather simple to try.

Cheers
Juan Pablo Califano

2010/6/10 Latcho 

> Hi friends,
>
> I have a bunch of AS2 / flash 8 swf files that are on a cdrom.
> The swf's were never intended for web use, but now the client wants a web
> version.
> The swf's contain gazzilions of uncompressed images.
> Is there a hacky shortcut / way to compress the images within the swf's
> without reopening / altering the fla projects ?
> I know I can google, but I love to here or the tools you used succesfull.
>  I'm on windows.
> Cheers,
> Latcho
> ___
>
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] AIR - ByteArray to BitmapData

2010-06-10 Thread Juan Pablo Califano
No worries!

And thanks for sharing.

Cheers
Juan Pablo Califano

2010/6/10 Karim Beyrouti 

> Thanks for your help -  uploaded the finished code to the google SVN - so
> it's free for all...
>
>
> https://code.google.com/p/kurstcode/source/browse/trunk/libs/com/kurst/air/utils/ImageUtils.as
>
> Regards
>
>
> Karim
>
>
> On 24 May 2010, at 20:44, Karim Beyrouti wrote:
>
> > Perfect - thank you for the extended and most useful the answer - had
> started thinking along these lines but it's good to know there was no other
> way ( apart for the loader ) - as i just need width and height - think i am
> going to extract that from the ByteArray...
> >
> > thanks again...
> >
> >
> > - k
> >
> >
> > On 24 May 2010, at 20:09, Juan Pablo Califano wrote:
> >
> >> If you want to convert it back to pixels, I'd say go with the Loader
> >> approach.
> >>
> >> Other than that, you'd have to write a JPEG decoder (seems like a waste
> of
> >> time, considering you can already use a Loader, which would also be
> faster,
> >> probably).
> >>
> >> Now, if you are only interested in getting the width and height, that
> data
> >> is in the SOFO block (SOFO stands for start of frame 0).
> >>
> >> SOFO is marked by this sequence of bytes:
> >>
> >> 0xFF 0xC0
> >>
> >> So, basically, you can loop through your bytearray until you find this
> >> sequence.
> >>
> >> Then offset your current position as necessary and read the height and
> >> width.
> >>
> >> If you take a look at the JPEG encoder from as3CoreLib, you can see you
> have
> >> to skip 5 bytes from the beggining of the SOFO marker to get the height
> (2
> >> bytes) and the width (2 bytes).
> >>
> >>
> http://code.google.com/p/as3corelib/source/browse/trunk/src/com/adobe/images/JPGEncoder.as
> >>
> >> Now, I haven't read the JPEG spec, so I'm not sure if this is a fixed
> >> offset. I'm assuming it is, but you'd better check it if you want to use
> >> this code. I've tried it with a couple of JPEG's and it worked fine,
> >> though.
> >>
> >> Also, you might want to validate if what you've got is a JPEG (check the
> >> first 2 bytes for 0xff, 0xd8); you might also want to check that you're
> not
> >> reading out of the buffer bounds.
> >>
> >>
> >> function readJPEGSize(data:ByteArray):void {
> >> var len:int = 0;
> >> var i:int = 0;
> >> var offset:int = 0;
> >> while(data.bytesAvailable > 1) {
> >> // look for 0xffc0
> >> if(data[i] == 0xFF && data[i + 1] == 0xC0) {
> >> offset = i;
> >> break;
> >> }
> >> i++;
> >> }
> >>
> >> /*
> >> writeSOF0(image.width,image.height);
> >>   writeWord(0xFFC0); // marker
> >>   writeWord(17);   // length, truecolor YUV JPG
> >>   writeByte(8);// precision
> >>   writeWord(height);
> >>   writeWord(width);
> >> Skip 5 bytes:
> >> 2 SOFO marker
> >> 2 length
> >> 1 precision
> >> */
> >> var h:int = 0;
> >> var w:int = 0;
> >> if(offset > 0) {
> >> offset += 5;
> >> data.position = offset;
> >> h = data.readUnsignedShort();
> >> w = data.readUnsignedShort();
> >> trace(w,h);
> >> }
> >> }
> >>
> >> Cheers
> >> Juan Pablo Califano
> >>
> >>
> >> 2010/5/24 Karim Beyrouti 
> >>
> >>> Hi All
> >>>
> >>> do any of you how to convert a ByteArray (of a JPG) back into a
> BitmapData
> >>> object?
> >>>
> >>> Actually - i just need to get the dimensions of the bitmap before
> trashing
> >>> it. I know you can do 'myloader.loadBytes( byteArray )' - but i am
> avoiding
> >>> that for now - as i just need to get the size of the image.
> >>>
> >>> Any pointers?
> >>>
> >>>
> >>> mucho thanks
> >>>
> >>>
> >>> - karim
> >>> ___
> >>> Flashcoders mailing list
> >>> Flashcoders@chattyfig.figleaf.com
> >>> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
> >>>
> >> ___
> >> Flashcoders mailing list
> >> Flashcoders@chattyfig.figleaf.com
> >> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
> >
> >
> > ___
> > Flashcoders mailing list
> > Flashcoders@chattyfig.figleaf.com
> > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
>
> ___
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Loading SWF file via Socket class / ByteArray

2010-06-08 Thread Juan Pablo Califano
Yes, URLLoader will trigger a standard HTTP request. Meaning, you can see it
with firebug, charles, etc.

It's also possible to sniff a socket connection, but it requires Wireshark
or similar software.

Not sure if you gain much by using sockets, really, but anyway I'd just add
that setting up the proper security context for sockets is a bit more
involved (you have to run a service to serve a policy file from some port
below 1024, etc), but it's feasible if you have control over the server.

Cheers
Juan Pablo Califano

2010/6/8 Tom Gooding 

> Thanks Juan - I will try this out - the reason behind investigating this is
> for obfuscation; I'm interested in finding a way to load an asset into flash
> without triggering a standard http request (I guess URLLoader will trigger
> one).
> You're right about LoaderContext too - I think it needs to be set to the
> current context before you can read the byte data from the external file
>
>
>
> On 8 Jun 2010, at 16:40, Juan Pablo Califano wrote:
>
> You don't need to use a socket for this.
>
> Load the data with a URLLoader, setting URLLoader.dataFormat to
> URLLoaderDataFormat.BINARY.
>
> You'll get a ByteArray. Pass that to Loader::loadBytes() wait for the
> complete event to fire and you're all set.
>
> Well, almost. If the loaded swf is in a different domain, you need a
> crossdomain. If I recall correctly, this case also involved
> some LoaderContext particular setup (can't remember the details, though).
>
> You don't need to do anything server-side if you are serving the swf as a
> normal file.
>
> Cheers
> Juan Pablo Califano
>
> 2010/6/8 Tom Gooding 
>
> > Hi,
> >
> > Does anyone know how to get an external swf (hosted on a regular
> webserver)
> > into the Loader class - accessed via the low-level flash.net.Socket class
> > into a ByteArray.
> >
> > It seems this is possible, but I can't find any examples of how to handle
> > it either server side (we use Java here) or how the AS3 client would need
> to
> > work.
> >
> > I have found this which looks like it may have been relevant, but the
> files
> > have been taken down:  http://www.bytearray.org/?p=32
> >
> > If anyone has any ideas I'd appreciate it,
> >
> > Tom
> > ___
> > Flashcoders mailing list
> > Flashcoders@chattyfig.figleaf.com
> > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
> >
> ___
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
>
> ___
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Loading SWF file via Socket class / ByteArray

2010-06-08 Thread Juan Pablo Califano
You don't need to use a socket for this.

Load the data with a URLLoader, setting URLLoader.dataFormat to
URLLoaderDataFormat.BINARY.

You'll get a ByteArray. Pass that to Loader::loadBytes() wait for the
complete event to fire and you're all set.

Well, almost. If the loaded swf is in a different domain, you need a
crossdomain. If I recall correctly, this case also involved
some LoaderContext particular setup (can't remember the details, though).

You don't need to do anything server-side if you are serving the swf as a
normal file.

Cheers
Juan Pablo Califano

2010/6/8 Tom Gooding 

> Hi,
>
> Does anyone know how to get an external swf (hosted on a regular webserver)
> into the Loader class - accessed via the low-level flash.net.Socket class
> into a ByteArray.
>
> It seems this is possible, but I can't find any examples of how to handle
> it either server side (we use Java here) or how the AS3 client would need to
> work.
>
> I have found this which looks like it may have been relevant, but the files
> have been taken down:  http://www.bytearray.org/?p=32
>
> If anyone has any ideas I'd appreciate it,
>
> Tom
> ___
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] problem with strongly typed actionscript

2010-06-08 Thread Juan Pablo Califano
Simple and gloriously concise example (as opposed to mine!). Here, whether
the classes are native, or whether they are concrete instead of interfaces
won't change the need for a cast; all the involved objects have
commonalities but also important differences, and you want to treat them
differently. Refactoring (if it were possible) to support "proper"
polymorphism would obviously a bad idea, at least for me.

Cheers
Juan Pablo Califano
2010/6/8 Henrik Andersson 

> Juan Pablo Califano wrote:
>
>> I agree with you, but I'add for the sake of completeness that, sometimes,
>> relaxing the rules a bit becomes a necessary evil, like for instance, when
>> doing a cast.
>>
>>
> I have another example of where a typecast can be useful. When you really
> do need only BaseClass, but want to add some processing, if and only if, the
> object is of a specific DerivedClass.
>
> An examples of this example would be a display list crawler. You are just
> outputting all the objects, you need nothing other than DisplayObject for
> that. However, you want to go deep, so you use the "as" operator to get a
> reference to a DisplayObjectContainer. If it succeeds, you recurse. If not,
> not a problem.
>
> ___
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Passing Var value to loaded swf

2010-06-07 Thread Juan Pablo Califano
>>>
Maybe I should rethink that metaphor...
>>>

Yes, please. Although in this case, wouldn't grandpa and granny be the ones
having sex? Not sure if that makes the metaphor more or less disturbing,
though.

Cheers
Juan Pablo Califano

2010/6/7 Steven Sacks 

> Loader is a DisplayObject. You can add Loader to the stage before telling
> it to load.  You don't have to wait to addChild() the content of the Loader
> after it loads.
>
> You cannot dispatch bubbled events from your loaded swf through the Loader
> that loaded it. Keep that in mind.
>
> Doing parent.parent is generally a bad idea, since it requires that the swf
> being loaded have intimate detail of its parent. You wouldn't want to walk
> in on your parents having sex, but your parents might walk in on you
> masturbating (since you live in their house).
>
> Maybe I should rethink that metaphor...
>
> ___
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] problem with strongly typed actionscript

2010-06-07 Thread Juan Pablo Califano
 traffic; this
site's traffic is huge, and though there are load balanced dedicated servers
running it, completely purging the cache is something the stresses the whole
infrasctructure, so the IT guys are rather reluctant to "full deploys".

Now, the thing is (and I learnt this the hard way; thankfully this problem
got caught in QA), interfaces work like classes in that if two swf use the
same interface, the first one loaded is the one used (if they're loaded in
the same app domain; loading it in a different domain kind of defeats the
purpose of using such interfaces in the first place, though). But they don't
work like classes in that they are verified by the player, at load time. If
you change anything in a interface, and a.swf references the newer version
while b.swf references the older one, the player will throw a VerifierError.
I'm not sure you can even catch that, but even if you could, b.swf is dead
code by that time; worse than that, it will take with it the rest of the
code in every other swf loaded at that point. Basically, everything is
broken; the only thing you can do is reload, but when you get to that point
again, it will naturally blow, again. I kid you not: any change you make to
an interface can cause this. Even adding an optional parameter to one
method. This can be worked around, so I concede it's not impossible to
rearchitech things. However, even for "full deploys", you have to plan ahead
(picking the right time, coordinating with different teams, etc; and there's
a time span of a few hours in which, by how the load balanced CDN work, you
can't guarantee that a user will get the same version of all swfs; so
basically, the site is half broken for that period). Again, I know this is
not the most common case, but binary compatibility could be a problem in
some situations and from my experience I've learnt that, sometimes, a minor
"hack" is a lesser evil.

Cheers
Juan Pablo Califano

2010/6/7 Steven Sacks 

> With due deference, what you just said I disagree with. The scenario you
> described is not a necessary evil, it's a hack.
>
> The only situation where that isn't a hack is if your class extends a
> native type such as Sprite, but there's no ISprite. That problem is either
> solved by adding the Sprite functions you need to your interface, or, if you
> need to addChild() your interface, then you cast as Sprite because there's
> no other way.
>
> Outside of that specific case, you should never run into the situation you
> described, and if you do, it's time for a quick refactor.
>
> If you want a function in SomeConcreteClass to be accessible outside the
> class/inheritance/package (i.e. public) and you have an interface for that
> class, then you should include that function in the interface.  Sometimes
> you may not put public methods in the interface because you want them to be
> public to other packages inside your app, but not to "the outside world",
> and you shouldn't be casting to the interface of that class in those cases.
> Why would you cast as the interface when you don't need the interface?
>
> Using interfaces incorrectly or inappropriately is the disease, not a
> symptom of strict typing. If anything, strict typing forces these issues to
> appear in your code before it's too late.
>
> No matter what, proper typing never leads to code smell. Improper typing or
> mixed typing like what you described is code smell in the sense that it's
> indicative of poor architecture decisions.
>
>
>
>
> On 6/7/2010 3:46 PM, Juan Pablo Califano wrote:
>
>> I agree with you, but I'add for the sake of completeness that, sometimes,
>> relaxing the rules a bit becomes a necessary evil, like for instance, when
>> doing a cast.
>>
>> When you do this:
>>
>> // bar is typed as ISomeInterface somewhere else
>> var foo:SomeConcreteClass = bar as SomeConcreteClass;  // or
>> SomeConcreteClass(bar)
>> foo.methodOnlyPresentInConcreteClass();
>>
>> You are basically bypassing the rules of type system. You're telling the
>> compiler that an object declared as ISomeInterface at compile time will be
>> an instance of SomeConcreteClass at runtime. You're asking the compiler to
>> trust you and not blow up when compiling your code. Some times this is
>> avoidable with some refactoring (and or a better design). Sometimes it's
>> not
>> possible or impractical (this also depends on how purist you are, I
>> guess).
>> Nevertheless, having too many casts is usually considered a code smell for
>> this very reason.
>>
>> Cheers
>> Juan Pablo Califano
>>
> ___
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] problem with strongly typed actionscript

2010-06-07 Thread Juan Pablo Califano
I agree with you, but I'add for the sake of completeness that, sometimes,
relaxing the rules a bit becomes a necessary evil, like for instance, when
doing a cast.

When you do this:

// bar is typed as ISomeInterface somewhere else
var foo:SomeConcreteClass = bar as SomeConcreteClass;  // or
SomeConcreteClass(bar)
foo.methodOnlyPresentInConcreteClass();

You are basically bypassing the rules of type system. You're telling the
compiler that an object declared as ISomeInterface at compile time will be
an instance of SomeConcreteClass at runtime. You're asking the compiler to
trust you and not blow up when compiling your code. Some times this is
avoidable with some refactoring (and or a better design). Sometimes it's not
possible or impractical (this also depends on how purist you are, I guess).
Nevertheless, having too many casts is usually considered a code smell for
this very reason.

Cheers
Juan Pablo Califano




2010/6/7 Merrill, Jason 

> >> Or, you can simply turn strict mode off. I tend to agree with Steven
> Sacks, though.
> >>There's a really good reason for strong typing--mainly, it's easier to
> find bugs at compile time than at
>
> Yep. IMO, there should never be a reason to turn strict typing off, it's
> like saying, "Don't tell me about my bugs, I don't want to hear it.",
> which is like saying, "doctor, only tell me I'm healthy, because I don't
> want to hear I have cancer." But that's just me. :)
>
>
> Jason Merrill
>
> Instructional Technology Architect
> Bank of  America  Global Learning
>
> Join the Bank of America Flash Platform Community  and visit our
> Instructional Technology Design Blog
> (note: these are for Bank of America employees only)
>
>
>
> ___
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] External Interface with looped parameters

2010-06-06 Thread Juan Pablo Califano
Whenever you need to pass a variable number of arguments, check
Function.apply().It generally will be the answer to your problem!

If I understood your problem correctly, this should do what you want:


var args:Array = [0,1,2,3,4,5];
var jsFunctionName:String = "someJsFunction";
var parameters:Array = args && args.length > 0
? [jsFunctionName].concat(args)
: [jsFunctionName];
ExternalInterface.call.apply(null,parameters);

Since ExternalInterace::call is static, the first param (the "this" context
object) is null.

The parameters are passed to the function as if you had written them in
source code like func(param1,param2,param3), etc, as opposed to
func(paramsArray).

Now, this works because ExternalInterface::call expects the first param to
be the name of function to be called and a variable (and optional) list of
parameters. So, you just have to build an array that contains in its first
position the function name and after that the rest of the args you want to
pass. In this example, this is equivalent to this code:

ExternalInterface.call(jsFunctionName,0,1,2,3,4,5);


Cheers
Juan Pablo Califano

2010/6/6 Ashim D'Silva 

> The last 2 weeks were crazy and I completely lost track of this so I
> apologise for not responding to the answers (cheers though!). We
> couldn't find a solution so we used an array instead, but the idea was
> this.
>
> I have:
>
> var objs:Array = [1, 2, 3, 4, 5]; // arbitrary length defined by the
> number of parameters I receive from the XML.
>
> I want to pass it to javascript like this:
>
> ExternalInterface.call('jsFunc', objs[0], objs[1], objs[2], …);
>
> so that the JS can use whatever params are provided.
>
> I realise now however, that passing an Array (or name-value pairs) is
> a far more stream-lined method of achieving this, but I'm still
> curious if I could in fact build a function in a loop and then call it
> after. Interpretive languages could possibly handle this real easily,
> but is there an interesting workaround?
>
> Maybe something like:
>
> var st:String = "function() { jsFunc(";
> for each(var i:String in objs)
> {
> st += i+", ";
> }
> st+=");";
>
> ExternalInterface.call(st);
>
> It's reaching for stupidity because I lose the beautiful automatic
> Array conversion that AS3 does, but curiosity has the better of me at
> the moment.
>
> Cheers,
>
> Ashim
>
> The Random Lines
> www.therandomlines.com
>
>
>
>
> On 28 May 2010 22:13, Anthony Pace  wrote:
> >
> 
> > If you want an array from javascript to actionscript
> >
> 
> > somewhere in your class put something like:
> >
> > ExternalInterface.addCallback('SWFReceiver', as3Receiver);
> >
> > but remember that you need a receiver in as3:
> >
> > public function as3Receiver(a:Array /*or object, or *, etc...*/):void
> {
> >  //do something with your array
> > }
> >
> > then in js:
> >
> >var swfo = document.getElementById('idOfYourSwfElement');
> >swfo.SWFReceiver(yourArrayObject);
> >
> >
> 
> > if you want an array from AS3 to javascript
> >
> 
> >
> > var dataScript:XML= new XML("");
> > ExternalInterface.call(dataScript);
> >
> >
> >
> > On 5/26/2010 3:07 AM, Ashim D'Silva wrote:
> >>
> >> This seems fairly impossible but if there's an awesome way to do it
> >> I'll be heaps grateful.
> >>
> >> I receive a function name and a set of parameters via XML
> >>
> >> 
> >>
> >>webtrends
> >>
> >>98780
> >>Joseph
> >>Iceland
> >>
> >>
> >> 
> >>
> >> I'm hoping there's a way for me to fire an ExternalInterface.call()
> >> function with any amount of parameters provided to me.
> >> I'm one step away from telling the other side I'll send them an array,
> >> but hoping for the long shot.
> >>
> >> Cheers,
> >>
> >> Ashim
> >>
> >> The Random Lines
> >> www.therandomlines.com
> >> ___
> >> Flashcoders mailing list
> >> Flashcoders@chattyfig.figleaf.com
> >> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
> >>
> >>
> >
> > ___
> > Flashcoders mailing list
> > Flashcoders@chattyfig.figleaf.com
> > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
> >
>
> ___
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Question about approximate vowel detection in AS3

2010-06-03 Thread Juan Pablo Califano
>>>

I'm not Henrik, but I've done some lip-synch stuff for Disney. We did
it pretty much the way Eric described--we just used amplitude. It's
not as accurate as Disney would demand on a film, but it's ok in the
kids' game market.

>>>

I see, amplitudes could be just good enough for some stuff.

Although the "speed" and the intensitiy of the speech could give misleading
results, I think. I'm under the impression that you should somehow try to
compare the shape of the waves (somehow simplifiy your input to some value
of sets of values that are easier to compare, possibly in a "time window")
and compare it in some meaningful way to precalculated samples to find a
matching pattern. That's the part I have no clue about!

Cheers
Juan Pablo Califano

2010/6/3 Kerry Thompson 

> Juan Pablo Califano wrote:
>
> > Wow. That was really uncalled for.
>
> That was my reaction, too. I didn't see Eric as complaining--just
> asking. Maybe Henrik was just having a bad day.
>
> > For me, the hard part, which you seem to imply is rather simple here, is
> > *matching+ the input audio against said profiles. Admitedly, I don't know
> > anything about digital signal processing and audio programming in
> general,
> > but "matching" sounds a bit vague. Perhaps you could enlighten us, I you
> > feel like.
>
> I'm not Henrik, but I've done some lip-synch stuff for Disney. We did
> it pretty much the way Eric described--we just used amplitude. It's
> not as accurate as Disney would demand on a film, but it's ok in the
> kids' game market.
>
> Doing something more accurate would probably involve at least 6 mouth
> positions, and if you're doing it in real time, you'd have to do a
> reverse FFT. It can be done--there was a really good commercial
> lip-synch program that generated Action Script to control mouth
> positions. I don't know if it's still around--that was 5 years ago,
> and it was pretty expensive (about $2,500 for one seat, I think). It
> may even have been a Director Xtra that worked with a Flash Sprite,
> but let's not talk about Director :-P
>
> Cordially,
>
> Kerry Thompson
>  ___
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Question about approximate vowel detection in AS3

2010-06-03 Thread Juan Pablo Califano
Wow. That was really uncalled for.

Anyway, if you can pre-generate samples for all vowels for all samples, I
can't see why comparing them to the speech generated by the same system
would  be any harder than comparing it to a number of collected profiles.

>>>
You really just need to collect profiles to match against. Record people
saying stuff and match the recordings with the live data. When they match,
you know what the vocal is saying.
>>>

For me, the hard part, which you seem to imply is rather simple here, is
*matching+ the input audio against said profiles. Admitedly, I don't know
anything about digital signal processing and audio programming in general,
but "matching" sounds a bit vague. Perhaps you could enlighten us, I you
feel like.

Cheers
Juan Pablo Califano

2010/6/3 Henrik Andersson 

> Eric E. Dolecki wrote:
>
>> It's using dynamic text to speech, so I wouldn't be able to use cue points
>> reliably.
>>
>>
> Use dynamic cuepoints and stop complaining. If it can generate voice, it
> can tell you what kinds of voice it put where. It is far more exact than
> trying to reverse the incredibly lossy transformation that the synthesis is.
>
>
> ___
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Rede social une usuários do mundo acadêmico

2010-06-01 Thread Juan Pablo Califano
Don't know. For me it's quite easy, Shift + the key just next to backspace,
but then I have a Spanish keyboard...

2010/6/1 Paul Evans 

> On 1 Jun 2010, at 13:42, Juan Pablo Califano wrote:
>
> > It's Alt + 0191
>
> or a bit easier on a Mac: Option-? = ¿
>  ___
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Rede social une usuários do mundo acadêmico

2010-06-01 Thread Juan Pablo Califano
If spam is to be trusted, the site will also allow you to make money by
publishing stuff and inviting friends...

>>>
How do you type an upside-down question mark???
>>>

Don't you dare laughing at one of the best features my language has
contributed to written speech (too bad the rest of the world hasn't noticed
it yet; and, no, we don't share it with anyone else, not even with
Brazilians, Portuguese, et al). :P

People often find it odd, but ¿why do these people feel, at the same time,
that opening parenthesis before closing them is all that natural?

It's Alt + 0191, anyway. Although most Spanish speakers don't seem to care
to put those opening question and exclamation marks these days, just as they
don't care to put those funny accent marks or spelling properly for that
matter. They can't seem to be bothered with such minutiae. ¡Too bad!



2010/6/1 J.C. Berry 

> Just spam about a news site that allows user content.
>
> 2010/5/31 Karl DeSaulniers 
>
>  > Oh boy... here we go again.
> > Anyone got a spanglish dictionary I could use?
> > Sounds like something big. They used the word grande.
> > How do you type an upside-down question mark???
> >
> >
> > On May 31, 2010, at 9:20 PM, Follow Science wrote:
> >
> >  Com o Follow Science, você:
> >>
> >>
> >>Fica sabendo dos próximos eventos
> >> nacionais e internacionais;
> >>Compartilha arquivos e idéias com
> >> pessoas de diversas áreas;
> >>Acessa um grande acervo de
> notícias
> >> e artigos;
> >>Pode ganhar dinheiro publicando
> >> conteúdo e convidando amigos;
> >>E muito mais!
> >>
> >>
> >>Cadastre-se no Follow Science!»
> >>
> >>
> >>
> >>
> >>
> >>Talvez você conheça essas pessoas
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >>Leandro Ferreira
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >>Petalla Timo
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >>michèle sato
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >>José Carlos
> Martins
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >>©2010 Follow Science - Todos os direitos reservados.
> >>Sobre Nós | Política de Privacidade | Termos de Uso
> >>
> >>Você recebeu esta mensagem pelo email
> >> flashcod...@chattyfig.figleaf.com. Caso não queira mais receber nossos
> >> comunicados clique aqui
> >>
> >> ___
> >> Flashcoders mailing list
> >> Flashcoders@chattyfig.figleaf.com
> >> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
> >>
> >
> > Karl DeSaulniers
> > Design Drumm
> > http://designdrumm.com
> >
> >
> > ___
> > Flashcoders mailing list
> > Flashcoders@chattyfig.figleaf.com
> > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
> >
>
>
>
> --
> J.C. Berry, M.A.
> UI Developer
> 619.306.1712(m)
> jcharlesbe...@gmail.com
> portfolio: http://www.mindarc.com
>
> 
>
> This E-mail is covered by the Electronic Communications Privacy Act, 18
> U.S.C. ?? 2510-2521 and is legally privileged. This information is
> confidential information and is intended only for the use of the individual
> or entity named above. If the reader of this message is not the intended
> recipient, you are hereby notified that any dissemination, distribution or
> copying of this communication is strictly prohibited.
>
> 
> ___
>  Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Dylan responds to e-mails at 12pm and 4pm. (Auto-Response)

2010-05-30 Thread Juan Pablo Califano
Dylan refers to himself in the third person and has turned on this annoying
feature in his email client that spams this list with auto-responses
containing information that none of its recipients give a hoot about. Two
good reasons to black-list him until he desists from inflicting at least one
of the aforementioned offenses.

2010/5/30 Glen Pike 

> Gee, that's a pity Dylan because I really needed an answer before 5pm GMT,
> oh well.  ;)
>
>
> dy...@ontheriverent.com wrote:
>
>> Hello Friends and Colleagues,
>> In order to continuously focus my attention on the large projects I am
>> working on,  I am currently checking and responding to e-mail twice daily,
>> at 12pm PST and 4pm PST.
>> If you require immediate assistance (please ensure it is urgent and it
>> cannot wait until either 12pm or 4pm) please contact me via phone at
>> 323-963-3307.
>>
>> Thank you for understanding this move to a more productive work flow.
>>
>> Dylan Fergus
>>
>> o 323 963 3307
>>
>> dy...@ontheriverent.com
>>
>> www.ontheriverent.com
>>
>> www.flooredandlifted.com
>>
>> www.dylanfergus.com
>>
>> This message and any attached documents contain information that may be
>> confidential and/or privileged. If you are not the intended recipient, you
>> may not read, copy, distribute, or use this information. If you have
>> received this transmission in error, please notify the sender immediately by
>> reply e-mail and then delete this message.
>>
>> ___
>> Flashcoders mailing list
>> Flashcoders@chattyfig.figleaf.com
>> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>>
>>
>>
> ___
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] AIR - ByteArray to BitmapData

2010-05-24 Thread Juan Pablo Califano
If you want to convert it back to pixels, I'd say go with the Loader
approach.

Other than that, you'd have to write a JPEG decoder (seems like a waste of
time, considering you can already use a Loader, which would also be faster,
probably).

Now, if you are only interested in getting the width and height, that data
is in the SOFO block (SOFO stands for start of frame 0).

SOFO is marked by this sequence of bytes:

0xFF 0xC0

So, basically, you can loop through your bytearray until you find this
sequence.

Then offset your current position as necessary and read the height and
width.

If you take a look at the JPEG encoder from as3CoreLib, you can see you have
to skip 5 bytes from the beggining of the SOFO marker to get the height (2
bytes) and the width (2 bytes).

http://code.google.com/p/as3corelib/source/browse/trunk/src/com/adobe/images/JPGEncoder.as

Now, I haven't read the JPEG spec, so I'm not sure if this is a fixed
offset. I'm assuming it is, but you'd better check it if you want to use
this code. I've tried it with a couple of JPEG's and it worked fine,
though.

Also, you might want to validate if what you've got is a JPEG (check the
first 2 bytes for 0xff, 0xd8); you might also want to check that you're not
reading out of the buffer bounds.


function readJPEGSize(data:ByteArray):void {
var len:int = 0;
var i:int = 0;
 var offset:int = 0;
while(data.bytesAvailable > 1) {
// look for 0xffc0
if(data[i] == 0xFF && data[i + 1] == 0xC0) {
offset = i;
break;
}
i++;
}

/*
writeSOF0(image.width,image.height);
writeWord(0xFFC0); // marker
writeWord(17);   // length, truecolor YUV JPG
writeByte(8);// precision
writeWord(height);
writeWord(width);
 Skip 5 bytes:
2 SOFO marker
2 length
1 precision
*/
var h:int = 0;
var w:int = 0;
 if(offset > 0) {
offset += 5;
data.position = offset;
h = data.readUnsignedShort();
w = data.readUnsignedShort();
 trace(w,h);
}
}

Cheers
Juan Pablo Califano


2010/5/24 Karim Beyrouti 

> Hi All
>
> do any of you how to convert a ByteArray (of a JPG) back into a BitmapData
> object?
>
> Actually - i just need to get the dimensions of the bitmap before trashing
> it. I know you can do 'myloader.loadBytes( byteArray )' - but i am avoiding
> that for now - as i just need to get the size of the image.
>
> Any pointers?
>
>
> mucho thanks
>
>
> - karim
> ___
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Blocking multiple logins on one computer

2010-05-23 Thread Juan Pablo Califano
This is a gross hack (no offense intended), but I think it can actually
work... (except for virtual machines)

Cheers
Juan Pablo Califano

2010/5/23 Ktu 

> You could also try using the LocalConnection class.
>
> If you apps connect at some point, turn the second one off somehow.
>
> Ktu
>
> On Sun, May 23, 2010 at 4:43 PM, Karl DeSaulniers  >wrote:
>
> > Thanks Dave,
> > That is the consensus I am getting.
> > Is there any way to tell how many browsers from one computer are being
> > used?
> > Or if a person is using a virtual machine or is sharing an ip?
> >
> > Karl
> >
> >
> >
> > On May 23, 2010, at 11:33 AM, Dave Watts wrote:
> >
> >  Let me clarify a little more. How do I prevent multiple logins to my
> site
> >>> from one computer regardless of the user?
> >>> So that someone cant open safari and IE and log in to my site using
> both
> >>> browsers on that one computer.
> >>> Even if the usernames are different.
> >>>
> >>
> >> I don't think you can guarantee this, but you can make it more
> >> difficult by looking at the user's IP address. Your web server will
> >> make that available as a CGI variable. This however may cause problems
> >> for users behind proxies - multiple legitimate users might then share
> >> the same IP address - and users can circumvent this by using multiple
> >> computers, including virtualized computers.
> >>
> >> Dave Watts, CTO, Fig Leaf Software
> >> http://www.figleaf.com/
> >> http://training.figleaf.com/
> >>
> >> Fig Leaf Software is a Veteran-Owned Small Business (VOSB) on
> >> GSA Schedule, and provides the highest caliber vendor-authorized
> >> instruction at our training centers, online, or onsite.
> >> ___
> >> Flashcoders mailing list
> >> Flashcoders@chattyfig.figleaf.com
> >> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
> >>
> >
> > Karl DeSaulniers
> > Design Drumm
> > http://designdrumm.com
> >
> > ___
> > Flashcoders mailing list
> > Flashcoders@chattyfig.figleaf.com
> > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
> >
> ___
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] tint a movieclip

2010-05-19 Thread Juan Pablo Califano
To apply in code the same transform you set at author time in the IDE:

var colTransf:ColorTransform = mc.transform.colorTransform;
colTransf.redMultiplier = -0.18;
colTransf.greenMultiplier = -0.42;
colTransf.blueMultiplier = 0.22;
colTransf.alphaMultiplier = 0.26;
mc.transform.colorTransform = colTransf;

The left values in the panel are the multipliers (one for each channel).
There's a difference: in code the values are expressed as normal value in
the range 0-1 (whereas in the IDE it's represented as a percetage, 0 - 100).

So the above code will have the same effect as setting the left values to
-18%, -42%, 22% and 26%.

If you want to change the values in the right of the panel through code, set
the offsets instead (the properties redOffset, greenOffset, etc in the
ColorTransform object). They are expressed in the same units both in code
and the IDE.

Cheers
Juan Pablo Califano

2010/5/19 Mendelsohn, Michael 

> Hi list...
>
> This is probably a bitwise question, which is why I'm posting.  I have a
> grayscale movieclip and I want to give it a particular hue based on a hex
> value.  I don't want it to be tint, where it approaches being a solid color,
> but rather like watercolors.
>
> Additionally, I know that the left side values of the Advanced color pallet
> does this, and the right side values are for tinting.  I'm just not sure at
> the moment how to do that through code.
>
> Thanks if anyone knows!
> - Michael M.
>
> ___
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] https, .load and Error #2048

2010-05-12 Thread Juan Pablo Califano
Have you checked possible crossdomain issues? (I mention it since you're
using an absoulte path).

This blog post here presents a solution for a particular problem (maybe not
the one you're facing), but gives a couple of tips for troubleshooting these
kind of errors:

http://www.thecosmonaut.com/2008/08/28/flash-9-policy-files/

Hope this helps.

Cheers
Juan Pablo Califano

2010/5/12 Lehr, Theodore 

> it's all https, though...
>
> 
> From: flashcoders-boun...@chattyfig.figleaf.com [
> flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Henrik Andersson [
> he...@henke37.cjb.net]
> Sent: Wednesday, May 12, 2010 3:56 PM
> To: Flash Coders List
> Subject: Re: [Flashcoders] https, .load and Error #2048
>
> Lehr, Theodore wrote:
> >   am trying to load some xml via:
> >
> > urlLoader.load(new URLRequest("https://...";));
> >
> > and I am getting an error #2048... is https an issue?
>
> Definitely, non secure content may not load secure content.
> ___
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
> ___
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Two computers talking using AS3 Socket on same network

2010-05-12 Thread Juan Pablo Califano
With non-Air players, you can use a Socket to connect to a server. But you
can't create a server itself; i.e. you can't write code to bind to a given
port and listen for connections. So, in that scenario you cannot connect
both swfs directly (you have to use a socket server).

Appartently with Air you can have your app bind to a port and listen for
connections, so you can have 2 swfs talk to each other without the need of
an extra party. (I say apparently because I've just found out about the
ServerSocket class following the link that Henrik posted).

Cheers
Juan Pablo Califano


2010/5/12 Eric E. Dolecki 

> Huh?
>
>
> http://www.adobe.com/livedocs/flash/9.0/ActionScriptLangRefV3/flash/net/Socket.html
>
> all I need is readUTFBytes and writeUTFBytes...
>
>
> On Wed, May 12, 2010 at 6:31 PM, Henrik Andersson  >wrote:
>
> > Eric E. Dolecki wrote:
> >
> >> AIR because of the application security sandbox? Would standalone
> >> projectors
> >> work as well?
> >>
> >
> > They would not, as they lack the needed API. Have a look at the recent
> > additions in the flash.net package, all the useful socket features are
> AIR
> > exclusive.
> >
> > ___
> > Flashcoders mailing list
> > Flashcoders@chattyfig.figleaf.com
> > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
> >
>
>
>
> --
> http://ericd.net
> Interactive design and development
> ___
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Producing a random list with no repeats

2010-05-09 Thread Juan Pablo Califano
If that happens, it's a bug in the player. From the docs:

"Returns a pseudo-random number n, where 0 <= n < 1. "

So, the biggest number random returns can approximate 1, but should never be
1.

What I got wrong in my original answer was that multiplying by 2 and then
rounding introduces a bias towards  1 (and then if you substract 1, the bias
is towards 0).

Think about it this way:

You've got a number between 0 and 1.9 when you do Math.random *  2. That
is, a number that can get very close to 2, but never be actually 2.

If you round it you'll get:

0 for 0...0.49
1 for 0.5...1.49
2 for 1.5...19

The actual numbers might not be exact as I'm not sure what's the boundary
for rounding up or down; I'm also considering only two decimals for
simplicity.

But anyway, the distribution is obviously not even. There's about a 0.25
chance of getting 0, the same chance of getting 2, but the double, 0.5, of
getting 1.

However, if you multiply by 3 and floor the result (or coerce it to int for
that matter), you get rid of the bias:

Math.random * 3 will give a number in the range 0...2.99

So, if you get rid of the decimal part, you have:

0 for 0...0.99
1 for 1...1.99
2 for 2...2.99

Which gives a result that's clearly more evenly distributed than the first
approach.


2010/5/9 Steven Sacks 

> In the exception that Math.random() returns 1, in which case you would get
> 2.
>
> I don't use Math.random(), though, I use the Parker-Miller PRNG.
>
>
>
>
> On 5/9/2010 5:01 PM, Juan Pablo Califano wrote:
>
>> PS 2: I think the correct way to write the function that returns a number
>> in
>> the range -1 / 1 is:
>>
>> Math.floor(Math.random * 3) - 1
>>
>> In this case, you could indeed use int() instead of a static Math method,
>> so
>> I guess I was wrong about your function needing a Math.round call.
>>
> ___
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Producing a random list with no repeats

2010-05-09 Thread Juan Pablo Califano
PS 2: I think the correct way to write the function that returns a number in
the range -1 / 1 is:

Math.floor(Math.random * 3) - 1

In this case, you could indeed use int() instead of a static Math method, so
I guess I was wrong about your function needing a Math.round call.

2010/5/9 Juan Pablo Califano 

> Steven, sorry to contradict you, but although your code is simple and sort
> of works, there a couple of problems with it.
>
> First, the sorting function is wrong. A sorting function is supposed to
> return -1,0 or 1. But it only returns -1 or 0.
>
> The problem is you are coercing the result to int. You should use
> Math.round instead.
>
> int(Math.random() * 2) will return 1 or 0, never 2, because the biggest
> value Math.random will return will be close to 1, but never will be 1. So,
> if Math.random returns say, 0.9, after you multiply you get 1.8; since
> you're using int(), decimals will just be discarded (instead of rounded) and
> the result will be 1. There's no way you'll get 2, only 1 or 0. Then you
> substract 1, so your sorting function will return either -1 or 0.
>
> Second, you don't need to sort the whole list. It's much more work than
> it's needed to shuffle the array. While the Fisher-Yates algorithm is
> linear, the sort is not. That is, if you have 40 items, you know the
> Fisher-Yates will "visit" each list slot only once. That's not the case with
> the sort method. It grows exponentially. Well, maybe not exactly
> exponential, I'm not possitive, but it's not linear anyway, as this code
> shows:
>
> var list:Array = [];
> var numItems:int = 40;
> for(var i:int = 0; i < numItems; i++) {
> list[i] = i;
> }
>
> var calls:int = 0;
> function randomize(a:int, b:int):int
> {
> calls++;
> return int(Math.random() * 2) - 1;
> }
>
> list.sort(randomize);
> trace("calls:" + calls);
>
> Change numItems and you'll see what I mean. Bottom line, you're doing more
> work than you need: you're calling a function instead of doing your
> comparison inline and you are calling Math.random more than it's actually
> needed to sort the list.
>
> Third, the sorting algorithm works under the assumption that given two
> objects they allways sort the same: either the first one is less than, equal
> or greater than the second. That doesn't hold true if your sorting function
> returns a random result. And I think maybe that's why the number of calls
> that the above code prints vary even when you have the same number of items.
>
> Cheers
> Juan Pablo Califano
>
> PS. I also used the method you describe (for years) until I read about its
> problems, so I thought maybe this is a good opportunity to pass this info
> on. To be honest, though, I don't think it will be a problem
> preformance-wise unless you have a rather big array.
>
> 2010/5/9 Steven Sacks 
>
> Here's a very clean, fast and simple way to randomize an array.
>>
>> array.sort(randomizeFunction);
>>
>> function randomize(a:int, b:int):int
>> {
>>return int(Math.random() * 2) - 1;
>> }
>>
>> If you're not happy with Math.random()'s randomness, there are plenty of
>> other random number generators out there, such as:
>>
>>
>> http://lab.polygonal.de/2007/04/21/a-good-pseudo-random-number-generator-prng/
>>
>> And Grant Skinner's Rndm:
>> http://www.gskinner.com/blog/archives/2008/01/source_code_see.html
>>
>> ___
>> Flashcoders mailing list
>> Flashcoders@chattyfig.figleaf.com
>> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>>
>
>
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Producing a random list with no repeats

2010-05-09 Thread Juan Pablo Califano
Steven, sorry to contradict you, but although your code is simple and sort
of works, there a couple of problems with it.

First, the sorting function is wrong. A sorting function is supposed to
return -1,0 or 1. But it only returns -1 or 0.

The problem is you are coercing the result to int. You should use Math.round
instead.

int(Math.random() * 2) will return 1 or 0, never 2, because the biggest
value Math.random will return will be close to 1, but never will be 1. So,
if Math.random returns say, 0.9, after you multiply you get 1.8; since
you're using int(), decimals will just be discarded (instead of rounded) and
the result will be 1. There's no way you'll get 2, only 1 or 0. Then you
substract 1, so your sorting function will return either -1 or 0.

Second, you don't need to sort the whole list. It's much more work than it's
needed to shuffle the array. While the Fisher-Yates algorithm is linear, the
sort is not. That is, if you have 40 items, you know the Fisher-Yates will
"visit" each list slot only once. That's not the case with the sort method.
It grows exponentially. Well, maybe not exactly exponential, I'm not
possitive, but it's not linear anyway, as this code shows:

var list:Array = [];
var numItems:int = 40;
for(var i:int = 0; i < numItems; i++) {
list[i] = i;
}

var calls:int = 0;
function randomize(a:int, b:int):int
{
calls++;
return int(Math.random() * 2) - 1;
}

list.sort(randomize);
trace("calls:" + calls);

Change numItems and you'll see what I mean. Bottom line, you're doing more
work than you need: you're calling a function instead of doing your
comparison inline and you are calling Math.random more than it's actually
needed to sort the list.

Third, the sorting algorithm works under the assumption that given two
objects they allways sort the same: either the first one is less than, equal
or greater than the second. That doesn't hold true if your sorting function
returns a random result. And I think maybe that's why the number of calls
that the above code prints vary even when you have the same number of items.

Cheers
Juan Pablo Califano

PS. I also used the method you describe (for years) until I read about its
problems, so I thought maybe this is a good opportunity to pass this info
on. To be honest, though, I don't think it will be a problem
preformance-wise unless you have a rather big array.

2010/5/9 Steven Sacks 

> Here's a very clean, fast and simple way to randomize an array.
>
> array.sort(randomizeFunction);
>
> function randomize(a:int, b:int):int
> {
>return int(Math.random() * 2) - 1;
> }
>
> If you're not happy with Math.random()'s randomness, there are plenty of
> other random number generators out there, such as:
>
>
> http://lab.polygonal.de/2007/04/21/a-good-pseudo-random-number-generator-prng/
>
> And Grant Skinner's Rndm:
> http://www.gskinner.com/blog/archives/2008/01/source_code_see.html
>
> ___
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Producing a random list with no repeats

2010-05-05 Thread Juan Pablo Califano
A simple way:

Put all the candidate numbers in a list (in this case, 1 to 40). Then pick
randomly from that array, one at the time, and make sure you remove that
number from the candidates list, so you can't have duplicates.

In code (untested):

function getRandomList():Array {
var min:Number = 1;
var max:Number = 40;
var numItems:Number = 10;
var candidates:Array = [];
// fill up the candidates list with the "eligible" numbers
for(var i:Number = min; i <= max; i++) {
candidates.push(i);
}

var list:Array = [];
var idx:Number = 0;
var selectedNumber:Number = 0;
for(i = 0; i < numItems; i++) {
// get a number from the candidates list, randomly. Add it to the
result and remove it from the candidates list (using splice)
idx =  Math.floor(Math.random() * candidates.length);
selectedNumber = candidates.splice(idx,1)[0];
list.push(selectedNumber);
}
return list;
}


Cheers
Juan Pablo Califano

2010/5/5 Alan Neilsen 

> I am working in ActionScript 2. I want to create a quiz in which 10
> questions are randomly selected from a block of 40 questions. I found the
> following code, but I can't work out how to stop it doubling up the
> questions.
>
> function randRange(min:Number, max:Number):Number {
>var randomNum:Number = Math.floor(Math.random() * (max - min + 1)) +
> min;
>return randomNum;
> }
> for (var i = 0; i < 10; i++) {
>var n:Number = randRange(1, 40)
>trace(n);
> }
>
> When I run this it outputs a list of numbers like 40  13  17  12  27  12  3
>  17  9  15 which means some questions (in this case 17 and 12) will appear
> twice in my quiz.
> Bearing in mind that I am a bit of an ActionScript dummy, can anybody
> suggest a way to modify the above script to prevent the same number being
> generated more than once.
>
> This message is for the named person’s use only. It may contain
> confidential, proprietary or legally privileged information. No
> confidentiality or privilege is waived or; lost by any mistransmission. If
> you receive this message in error, please immediately delete it and all
> copies of it from your system, destroy any hard copies of it and notify
> the sender. You must not directly or indirectly, use, disclose,
> distribute, print or copy any part of this message if you are not the
> intended recipient. GOULBURN OVENS INSTITUTE OF TAFE and
> any of its subsidiaries each reserve the right to monitor all e-mail
> communications through its networks. Any views expressed in this
> message are those of the individual sender, except where the
> message states otherwise and the sender is authorised to state them
> to be the views of any such entity.
>
>
> #
> This e-mail message has been scanned for Viruses and Content and cleared
> by MailMarshal
>
> #
> ___
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] arranging

2010-04-28 Thread Juan Pablo Califano
The display list is managed as a stack. New items go on top when you add
them by default. So the first item you added will have index 0. If you
addChild() again, the new child will be at index 1.

If you want to get the topmost child, you can do:

container.getChildAt(container.numChildren - 1);

Cheers
Juan Pablo Califano
2010/4/28 Lehr, Theodore 

> ok - so I am trying this:
>
> var curChild=getChildByName(e.currentTarget.name<http://e.currenttarget.name/>
> );
> var curIndex:int=getChildIndex(curChild);
> trace(curIndex);
>
> and it seems as though it is counting from the back up... so if I have 12
> mcs, then the one no top will trace 12... I would think the one on top would
> be 1 I would love to just set it to 1 to make it come to the top and
> then reset it back to it's original number to put it back any
> thoughts
>
> 
> From: flashcoders-boun...@chattyfig.figleaf.com [
> flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Nathan Mynarcik [
> nat...@mynarcik.com]
> Sent: Wednesday, April 28, 2010 1:51 PM
>  To: Flash Coders List
> Subject: Re: [Flashcoders] arranging
>
> Will getChildIndex and setChildIndex not work either for static objects?
>
>
> -Original Message-
> From: "Lehr, Theodore" 
> Date: Wed, 28 Apr 2010 13:38:39
> To: Flash Coders List
> Subject: RE: [Flashcoders] arranging
>
> the issue is that these are mcs that are NOT put there in as but in the
> IDE I tried getChildIndex and it says that this is for display objects -
> not static objects... any way to change order with static objects?
>
> 
> From: flashcoders-boun...@chattyfig.figleaf.com [
> flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Nathan Mynarcik [
> nat...@mynarcik.com]
> Sent: Wednesday, April 28, 2010 1:33 PM
> To: Flash Coders List
> Subject: Re: [Flashcoders] arranging
>
> addChild(mc) normally brings them to the top.
> --Original Message--
> From: Henrik Andersson
> Sender: flashcoders-boun...@chattyfig.figleaf.com
> To: Flash Coders List
> ReplyTo: Flash Coders List
> Subject: Re: [Flashcoders] arranging
> Sent: Apr 28, 2010 12:13 PM
>
> Lehr, Theodore wrote:
> > If I have mcs that are put on the same layer in the ide - how can I
> change their order (i.e. send to back, bring forward) in as3?
>
> They will still have different indexes on the display list. Just do the
> same old stuff as usual.
> ___
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
>
> ___
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
> ___
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
> ___
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
> ___
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Flash & Google

2010-04-20 Thread Juan Pablo Califano
Isn't that kind of thing considered "unfair" play and penalized by search
engines if discovered?
Cheers
Juan Pablo Califano
2010/4/20 tom rhodes 

> use some server side script to serve up your site, check to see in the
> headers sent to the server if the request coems from a bot or from a
> browser, if from a bot, serve up your xml, if from a browser server up your
> site.
>
> have a google for  "swfaddress SEO"
>
>
> On 20 April 2010 11:52, Paul Andrews  wrote:
>
> > I have a client whose website I developed (something like a year ago) in
> > Flash and the site is totally driven by xml configuration  files. It
> works
> > well.
> >
> > My client has told me that google has indexed the site, but the google
> > indexing contains an warning message -  basically the flash site app
> saying
> > it was unable to read an xml file.
> >
> > I have never encountered the message myself and the site works as
> expected,
> > so I guess it's something to do with the google spider or there was some
> > sort of problem when the spider ran.
> >
> > Unfortunately the google search result currently makes the site look
> > broken:
> >
> >  "Oops! I think something went wrong! Unable to load website XML from
> > 'website_config.xml' - loading timed out."
> >
> > I'm no google expert, so what's the best remedy to get google to index
> this
> > site properly?
> >
> > I might be encouraged to write less flippant messages in the future.
> >
> > Paul
> >
> >
> > ___
> > Flashcoders mailing list
> > Flashcoders@chattyfig.figleaf.com
> > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
> >
> ___
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] ASDoc & third party libraries

2010-04-13 Thread Juan Pablo Califano
I think the problem is that you have to list all the classes you want to
exclude. In other words, you want to exclude packages, as you said, but
there's no option to exclude a package, you have to list all the classes.

If that's the case, a possible solution -other than doing it manually- is
using some script to generate a list of these classes given a path, then
copy + paste that after the -exclude-classes option.

Listing files is not that hard in batch and since you're on windows, you
have that option available already:

DIR /S /B *.as > fileList.txt

The problem is you have now a list of full paths. Converting a path to a
class name is not rocket science in any decent scripting language, but batch
hasn't earn the crappy reputation it has for being... easy to work with.

This should be easy to accomplish in php, python, etc, if any of these
is available in your computer. Or, maybe, you can try to write a JSFL script
to do the job, though you'll have to run it from flash. Or maybe an air app
if you're so inclined (perhaps overkill, but you already know actionscript,
so maybe it's the fastest option)

Anyway, I think if you manage to automate the generation of the exclude
list, you will be able to run the asdoc task without much manual work.

Just a few ideas, hope it helps.

Cheers
Juan Pablo Califano

2010/4/13 Merrill, Jason 

> >> asdoc -source-path . -doc-sources . -exclude-classes comps.PageWidget
>
> >>comps.ScreenWidget
>
> Thanks, I've tried that all different ways substituting in
> com.greensock.TweenLite - no luck.  Here is a sample class that imports
> Greensock's TweenLite class which in tests I cannot get ASDoc to exclude
> TweenLite.  If anyone knows how to get this class documented in ASDoc
> without compiler errors, I'm all ears.
>
> package
> {
>import flash.display.Sprite;
>import com.greensock.TweenLite
>/**
> * ...
> * @author Jason Merrill
> */
>
>
>public class Main extends Sprite
>{
>private var _mySprite:Sprite;
>/**
> * Constructor
> * @param duration the duration of the animation
> */
>public function Main(duration:Number)
>{
>TweenLite.to(_mySprite, duration, {x:10, y:10 }
> );
>}
>
>}
>
> }
>
>
> Jason Merrill
>
> Bank of  America  Global Learning
> Learning & Performance Solutions
>
> Join the Bank of America Flash Platform Community  and visit our
> Instructional Technology Design Blog
> (note: these are for Bank of America employees only)
>
>
>
>
>
>
> -Original Message-
> From: flashcoders-boun...@chattyfig.figleaf.com
> [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Karl
> DeSaulniers
>  Sent: Tuesday, April 13, 2010 5:48 PM
> To: Flash Coders List
> Subject: Re: [Flashcoders] ASDoc & third party libraries
>
> One last one, maybe to redeem myself, lol :)
>
> /
>
> Excluding classes
> All of the classes specified by the doc-classes, doc-sources, and doc-
> namespaces options are documented, with the following exceptions:
>
> If you specified the class by using the exclude-classes option, the
> class is not documented.
> If the ASDoc comment for the class contains the @private tag, the
> class is not documented.
> If the class is found in a SWC, the class is not documented.
> In the following example, you generate output for all classes in the
> current directory and its subdirectories, except for the two classes
> comps\PageWidget and comps\ScreenWidget.as:
>
> asdoc -source-path . -doc-sources . -exclude-classes comps.PageWidget
> comps.ScreenWidget
>
> Note that the excluded classes are still compiled along with all of
> the other input classes; only their content in the output is suppressed.
>
> If you set the exclude-dependencies option to true, dependent classes
> found when compiling classes are not documented. The default value is
> false, which means any classes that would normally be compiled along
> with the specified classes are documented.
>
> For example, you specify class A by using the doc-classes option. If
> class A imports class B, both class A and class B are documented.
>
> /
> From:  http://livedocs.adobe.com/flex/3/html/help.html?
> content=asdoc_3.html
>
> GL,
>
> Karl
>
>
>
> A man who says he just doesn't know will never know, but a man who
> says he thinks he can know, eventually will.
>
>
>
> On Apr 13, 2010, a

Re: [Flashcoders] @#$% New iPhone Developer Agreemen t Bans the Use of Adobe’s Flash-to-iPhone Compiler

2010-04-12 Thread Juan Pablo Califano
>>>

Learn C, C++ or Objective-C. They are not that hard, you have much more
control and you are not at the beck and call of a translation governed by
something like LLVM, which you have no control over.

>>>

Learn assembly. It's are not that hard, you have much more control and you
are not at the beck and call of a translation governed by something like the
Objective-C compiler, which you have no control over.
Cheers
Juan Pablo Califano
PS: Even better, code the instructions directly in binary, so you don't
depend on some kind of assembler, which you have no control over.

2010/4/12 Jon Bradley 

> I wouldn't call that amazing – I would call that whining. No offense to
> Lee, of course.
>
> Although all of us would love to develop iPhone and iPad applications using
> the Flash platform, frankly that is not a proper methodology for developing
> for these systems, in my opinion.
>
> Learn C, C++ or Objective-C. They are not that hard, you have much more
> control and you are not at the beck and call of a translation governed by
> something like LLVM, which you have no control over.
>
> - j
>
>
>
> On Apr 12, 2010, at 5:00 AM, allandt bik-elliott (thefieldcomic.com)
> wrote:
>
>  thanks lee brimelow for this amazing post
>> http://theflashblog.com/?p=1888
>>
>
>  ___
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Can u combine....

2010-02-27 Thread Juan Pablo Califano
I linke your solution and though I usually prefer to reuse objects such as
loader, I'm not totally against creating a loader per request since in some
situations it can be handy. But let me tell you, you have a subtle bug in
your code.

You need to pin down your loader somehow, because otherwise, since it's
local to the function, it could be garbage collected. I was under the
impression that an active loader would not be collected. It's rare that this
happens, but it's possible. I've learned this the hard way, and it took a
while and some hair pulling to figure out where the problem was (I was using
a Loader object to load images, but the same principle applies to
URLLoaders).

This could be fixed by storing your loader in an instance-scoped array, and
then removing it (and its handlers) when the loader's job is done (either
because it succeded or failed), using the event.target reference to find the
loader in the array.

Cheers
Juan Pablo Califano

2010/2/26 Valentin Schmidt 

> Juan Pablo Califano wrote:
> > Another option:
> > function loadXML(dfile:String,arg1:Object,arg2:Array):void
> > {
> >
> >   urlLoader.load(new URLRequest(dfile));
> >   urlLoader.addEventListener(Event.COMPLETE, function(e:Event):void {
> > parseXml(e,arg1,arg2);
> >   });
> > }
>
> and another option:
>
> save this as file "myURLLoader.as"
>
> package {
>  import flash.net.URLLoader;
>  public class myURLLoader extends URLLoader {
>public var params:Object;
>  }
> }
>
> and then use something like this:
>
> function loadXML(dfile:String):void
> {
>   var urlLoader:myURLLoader = new myURLLoader();
>
>  // add arbitrary custom parameters here
>  urlLoader.params = {foo:23, bar:"hello world"};
>
>  urlLoader.load(new URLRequest(dfile));
>  urlLoader.addEventListener(Event.COMPLETE, parseXML);
> }
>
> function parseXML(e:Event):void
> {
>   trace(e.target.params.foo);
>  trace(e.target.params.bar);
>
>  xmlFile:new XML(e.target.data);
>   // ...
> }
>
> cheers,
> valentin
> ___
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Security sandbox error during Upload/Download

2010-02-27 Thread Juan Pablo Califano
Hi,

>From the error message, it seems your swf is downloaded from
mydomain.netbut tries to access
www.mydomain.net. Crossdomains rules are subdomain based so you are not
granted access to www.mydomain.net from mydomain.net.

Most likely, you have the absolute url hardcoded somewhere, so when you
access www.mydomain.net/my.swf it works, but if you change the url to
mydomain.net (which problably maps to the same file as www.mydomain.net), it
no longer works.

The easiest solution probably is using relative urls. If for some reason
that's not possible, anoher option could be placing a crossdomain.xml policy
file that accepts both www.mydomain.net and mydomain.net.

There might be other options (like forcing a redirect to one of the
subdomains, passing a flashvar with the actual domain dynamically using some
server side technology, etc) but I would just use relative urls, if
possible, or a crossdomain file.


Cheers
Juan Pablo Califano

2010/2/27 ktt 

> Hello,
>
> I created file Upload/Download function with FileReference, but on
> different computer I get errors:
>
> Error #2044: Unhandled SecurityErrorEvent:. text=Error #2048: Security
> sandbox violation: http://mydomain.net/myboard/board-1.swf cannot load
> data from http://www.mydomain.net/myboard/uploads/some.jpg.
> at myboardFunctions::downloadKlase$cinit()
> at
> global$init()[/Users/demo/Desktop/board-new2010/myboardFunctions/downloadKlase.as:29]
> at
> myboardFunctions::formserts/downloadHandler()[/Users/demo/Desktop/Whiteboard-new2010.02.14/myboardFunctions/
> formserts.as:444]
>
> How to solve this?
> Should I need to tune Flash Player 10 settings?
>
> Thank you in advance,
> Kioshin
>
>
>
> ___
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Can u combine....

2010-02-26 Thread Juan Pablo Califano
Another option:
function loadXML(dfile:String,arg1:Object,arg2:Array):void
{

  urlLoader.load(new URLRequest(dfile));
  urlLoader.addEventListener(Event.COMPLETE, function(e:Event):void {
parseXml(e,arg1,arg2);
  });
}

function parseXML(e:Event,arg1:Object,arg2:Array):void
{
  xmlFile:new XML(e.target.data);
  totalBars = xmlFile.children().length();
}

This method has a drawback (and is usually frowned upon) because you cannot
remove the listener. In this case, though, I don't think this is a problem
(the loader seems to be owned by the class)

Cheers
Juan Pablo Califano
2010/2/26 Lehr, Theodore 

> ..how to combine:
>
> function loadXML(dfile:String):void
> {
>   urlLoader.load(new URLRequest(dfile));
>   urlLoader.addEventListener(Event.COMPLETE, parseXML);
> }
>
> function parseXML(e:Event):void
> {
>   xmlFile:new XML(e.target.data);
>   totalBars = xmlFile.children().length();
> }
>
>
> My goal is to send the first function additional parameters that would be
> used in additonal function calls right now I do not see how to send
> those on to parseXML my thought was if there was a way to combine these
> two functions - it would be easier
>
> ___
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] How to remove bytes from the beginning of a ByteArray?

2010-02-23 Thread Juan Pablo Califano
Hi,

You've got the source / destination backwards.

readBytes reads *from* the object on which the method is called. And it
writes *to* the ByteArray you pass in the first parameter.

So this:

var newBA:ByteArray = new ByteArray();
newBA.readBytes(_ba);
_ba = newBA;

Is copying data *from* newBA *to* _ba.

You want the opposite, so it should read:

var newBA:ByteArray = new ByteArray();
_ba.readBytes(newBA);
_ba = newBA;

You can also do the read / write in place. It's a just bit more contrived
but I'm not sure if it's worth it (it's less readable, I think). Here's how
you'd do it, anyway:

// let's assume for brevity that you've read 6 bytes from your original
buffer and you still have data left (i.e., len > 6)
var offset:int = 6;
// how much to read? All of the remaining data, which is the current length,
minus your current position (we said it was 6)
var newLen:int = _ba.length - offset;
// Read the data starting at current position and write it to the same
buffer, starting to write at the first byte.
// 0 is the offset in the *destination*. We want to copy the 6th byte into
the 0th position, that's why we pass 0.
// the third parameter tells the method how much to read from the *source*
// for what you want you don't actually need to pass these two last
parameters, since by default readBytes will write to *dest* at offset 0
// and will read from *source* all available data (i.e. from current
position to length -1)
_ba.readBytes(_ba,0,newLen);
// you do need to set this since this read/wirte is in place and you want to
shrink the buffer. Othewise, you'll end up with garbage after at the end of
the byte array.
_ba.length = newLen;

And that's it.

Hope it helps.

Cheers
Juan Pablo Califano

2010/2/23 Alexander Farber 

> Hello,
>
> sorry, but I'll try to start another thread to explain my problem.
>
> I read data from a socket into a ByteArray _ba and keep inspecting it.
> When there is enough data, I'd like to extract and process it and
> remove the processed bytes from the _ba.
>
> Here is how I try to do the removal, but it doesn't work (newBA is empty)
>
> var newBA:ByteArray = new ByteArray();
> newBA.readBytes(_ba);
> _ba = newBA;
>
> My complete code is at: http://pastebin.com/esz4As6D
>
> Thank you
> Alex
> ___
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Detecting if full screen mode is allowed before setting it

2010-02-17 Thread Juan Pablo Califano
I'm not sure if there's a clean way, but I'm afraid the ugly way won't work
either. If I recall correctly, you can't set the displayState to fullscreen
unless you're responding to user interaction (i.e. handling a button click).

Cheers
Juan Pablo Califano

2010/2/17 Alexander Farber 

> Hello,
>
> is it possible to detect, if a full screen mode is allowed before calling
>  stage.displayState = StageDisplayState.FULL_SCREEN;  ?
>
> I have the same .swf file embedded at several sites including Facebook
> (and there for some reason you can't do full screen unless
> using their iframe mode. My non-iframe app is at
>  http://apps.facebook.com/video-preferans/ ) and would like to
> hide my fullscreen-button if the full screen mode isn't allowed.
>
> Or do I have to set stage.displayState to FULL_SCREEN
> myself, catch the eventual exception, then reset displayState back?
> Seems awkward to me, but I can't find a better way yet.
>
> Thank you
> Alex
> ___
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Registration Point Issue

2010-02-09 Thread Juan Pablo Califano
Great story and great advices!

Cheers
Juan Pablo Califano

2010/2/9 Kerry Thompson 

> Nathan Mynarcik wrote:
> > Beno could use a Teddy Bear...
> >
> > Send it to him personally. Or perhaps some on this list can benefit from
> it again.
>
> Ok. Here goes. If you've heard this before , no need to read further
> (unless you're simply enamored of my writing style).
>
> Hang on, Beno. I didn't mean you. You need to read this.
>
> In one of my computer science classes, the prof had a big ol' Teddy
> Bear sitting on a counter at the back of the classroom. Cute, cuddly
> feller he was (the Teddy Bear, not the prof--he had serious ear hair
> issues).
>
> When we'd get stuck on a problem, if we went to the professor for
> advice, he'd cut us off in short order. "Have you consulted the Teddy
> Bear yet?"
>
> So we'd trudge back to the back of the room, give the Teddy Bear a
> tummy rub, and explain our problem, the approach we were taking, and
> where/why it was failing.
>
> A funny thing happened. Most of the time--I'd say 2/3 or more--the
> answer would come to us while we were talking to the bear, and we'd
> somewhat sheepishly go back to our seats, without needing to talk with
> the prof.
>
> The moral is that you have to understand your problem before you can
> come up with a solution. Many, many times simply being able to explain
> the problems is the most direct route to a solution.
>
> So, beno, the next time you want to post a question to this forum,
> talk to the Teddy Bear. If it doesn't solve your problem, it will at
> least isolate it so you can send us a 5-10 line code snipped with a
> clear description of your problem.
>
> You should also get acquainted with a technique called "stubbing."
> Often, you need to know several things about an object. Rather than
> writing the whole program, then going back to figure out where you
> went wrong, write the core of your program, and just stubs for other
> methods or classes. These stubs will always return the value you want
> because you hard-code them. They're just brain-dead little
> burplets--you poke them, and they belch up the right answer.
>
> As you get portions of the program working, you start replacing the
> stubs with real code.
>
> This is often called "iterative refinement," and is, to my mind one of
> the central tenets of programming. I haven't seen a lot of evidence
> that you're doing that with your code, at least what you're showing
> us.
>
> Incidentally, this iterative refinement concept works across
> disciplines. When I'm practicing my French Horn, I use iterative
> refinement to work out difficult passages. When I learned Chinese, I
> didn't start by memorizing "Journey to the West." I started out
> learning words and phrases, going over and over them to burn them into
> my memory.
>
> Beno, you actually do have an excellent resource here, and we will
> respond very positively and helpfully when you post very specific
> questions. It especially helps if you show what you've tried ("I did
> this, and expected that, but got a null. Why?")
>
> And, finally, I can't say this enough--learn to use the debugger. Live
> in it. You should be spending at least 50% of your time in the
> debugger--it will help you understand your own code a lot better. We
> all do it--I'm not recommending a penance, but giving you a tip on how
> the pros do it.
>
> Cordially,
>
> Kerry Thompsno
> ___
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Registration Point Issue

2010-02-09 Thread Juan Pablo Califano
This used to be true in AS 2.0 due to a bug in the player that in practice
made objects initialized in class declarations static.

It's no longer the case in AS 3.0.

Cheers
Juan Pablo Califano

2010/2/9 Henrik Andersson 

> Greg Ligierko wrote:
>
>> 1) Do not instantiate objects in properties declaration list. Its 99%
>> cases bad.
>>
>
> Allow me to explain why it is bad. It is due to the object only being
> created once. Not once per instance of the class, but once total. This is
> clearly going to cause issues for any class that is used more than once.
>
> ___
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] hs_err_pid WAS: E4X, it's just not my day.

2010-02-08 Thread Juan Pablo Califano
>>>
Writing a compiler is not something that you do again unless you can afford
doing it out of boredom
>>>

And yet, they did it ;)

There was a C++ compiler in the Flash authoring long before Flex existed. In
fact, the first versions of Flex used this compiler, if I recall corretly.

I'm under the impression that Flash CS4 uses the compiler from the SDK,
though. And there's a JVM install in the CS4 folder, anyway.

Cheers
Juan Pablo Califano

2010/2/8 Henrik Andersson 

> Dave Watts wrote:
>
>> Thanks Dave.  I'm using Flash.  Any suggestions for that?
>>>
>>
>> Nope. I'm at a loss to see how running Flash involves Java at all, but
>> then I don't use the Flash IDE. Does the Flash IDE use Java for
>> anything?
>>
>>
> This is just me extrapolating, but the facts are clear:
>
> * The flex compiler is written in Java
> * Writing a compiler is not something that you do again unless you can
> afford doing it out of boredom
> * Flash needs a compiler
>
> So most likely, Flash uses the flex compiler.
>
> ___
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] XML question with a test case

2010-02-06 Thread Juan Pablo Califano
I don't think so. I think that's precisely the reason why it returns an
empty list instead of null. So you can safely "chain" toghether diferent
node names in your query.

Cheers
Juan Pablo Califano

2010/2/6 Alexander Farber 

> Thank you - I'll do, but
>
> On Sat, Feb 6, 2010 at 7:01 PM, Juan Pablo Califano
>  wrote:
> > Because your second query returns an empty list instead of null.
> >
> > So, instead of checking for null, just check the length of the result.
> >
> > trace(describeType(xml1.lobby)); trace(xml1.lobby.length()); // 1
> > trace(describeType(xml2.lobby)); trace(xml2.lobby.length()); // 0
>
> wouldn't it sometimes throw an error that
> I call a method length() on a null-object?
>
> Regards
> Alex
> ___
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] XML question with a test case

2010-02-06 Thread Juan Pablo Califano
Because your second query returns an empty list instead of null.

So, instead of checking for null, just check the length of the result.

trace(describeType(xml1.lobby)); trace(xml1.lobby.length()); // 1
trace(describeType(xml2.lobby)); trace(xml2.lobby.length()); // 0

The first time I noted this it also confused me. I think it's clearly a
feaure, though, and it actually makes sense to me, because, otherwise, you
couldn't safely write something like this:

trace(xml1.lobby.user);
trace(xml2.lobby.user);

If at some point your query returned null, you'd have to check for null
explicitly or wrap almost every single line of code that manipulates XML in
try/catch to make sure it doesn't blow up because of a null reference error.


Cheers
Juan Pablo Califano
2010/2/6 Alexander Farber 

> Hello,
>
> I've prepared a simple test case for my problem:
>
> var xml1:XML =
>
>
>
>
>
>;
>
> var xml2:XML =
>
>
>;
>
> if (xml1.lobby)
>trace('1: in the lobby');
>
> if (xml2.lobby)
>trace('2: in the lobby');
>
> Why does this print the 2nd line too?
>
>1: in the lobby
>2: in the lobby
>
> I keep trying and also look in the debugger and just don't get it...
>
> Thank you
> Alex
> ___
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] How to use Flex Builder's profiler???

2010-02-04 Thread Juan Pablo Califano
Yes, taking a snapshot forces a GC cycle. You can also run it yourself at
any time pressing the "Run Garbage Collector" button.

Keep in mind that your disposing method will not cause your objects to be
collected, but rather be collectable or eligible for GV. Until the GC kicks
in, those objects could be unreacheable (if you managed to clean up
properly) but still alive (and that's what the Live Objects view reflects).
Cheers
Juan Pablo Califano
2010/2/4 W.R. de Boer 

> Hello,
>
> I have been working with FB3 Profiler the whole week but I am having some
> strange issues with it. If I am making a simple SWF with a document class
> where I call a method after 10 seconds which should dispose all the creating
> movieclip at startup.
>
> I have the issue that the reference counter of the several objects keep
> staying on 1 (watching it in the Live Objects tab pane in Eclipse) but after
> I press the button for creating a memory snapshot the counters go down to 0.
> What does this mean? Does the memory snapshot does a forced run on the
> garbage collection or were my objects already 0 but the Live Objects list
> didn't get updated?
>
> Anyone having any clue? I am confused.
>
> Weyert de Boer
> ___
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Re: Matrix + BitmapData - what exactly happens?

2010-01-25 Thread Juan Pablo Califano
Maybe it's not exactly what you're after, but here's a good method for
extracting a color palette from an image. You could possibly adapt it to
suit your needs or at least get some pointers.

http://blog.soulwire.co.uk/flash/actionscript-3/colourutils-bitmapdata-extract-colour-palette/

Cheers
Juan Pablo Califano

2010/1/25 jared stanley 

> here are some examples of the
>
> previous block of code.
>
> <http://lab.freestyleinteractive.com/jared/bitmap/revival.html>
> http://lab.freestyleinteractive.com/jared/bitmap/heman.html
> http://lab.freestyleinteractive.com/jared/bitmap/thundercats.html
>
> it appears that the dominant color is showing, but it is inconsistent(look
> at the end frame of the heman vid as an example)
>
> thanks to anyone who can help shed some light on this.
>
> Jared
>
>
>
>
>
>
> On Mon, Jan 25, 2010 at 5:28 PM, jared stanley  >wrote:
>
> > Hey list - I have been trying to get the dominant pixel color of an
> image.
> >
> > I received this solution from someone, but I'm still not exactly sure
> what
> > flash is doing with this:
> >
> >
> > public static function GetColor(_bmd:BitmapData):uint{
> >
> > var m: Matrix = new Matrix();
> > m.scale( 1 / _bmd.width, 1 / _bmd.height);
> > var colorBmd:BitmapData = new BitmapData(1, 1);
> > colorBmd.draw(_bmd, m);
> > var color:uint = colorBmd.getPixel(0,0);
> > //trace(color)
> >
> > return color;
> > }
> >
> >
> >
> >- the matrix is scaling down _bmd  to a fraction
> >- a 1x1 pixel BitmapData is created
> >- the draw() method is drawing a scaled version of the bitmap, 1pixel
> >by 1 pixel
> >- the pixel at 0,0 is selected
> >
> > My question is how is that color determined? Basically the whole image
> gets
> > simplified down to one color by flash, how is that determined?
> >
> > Ultimately I'm curious as I'd like to be able to get the dominant color
> and
> > the average color of an image separately.
> >
> > Thanks!
> >
> > Jared
> >
> >
> ___
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Crossdomain.xml, shared hosting, https, oh my!

2010-01-13 Thread Juan Pablo Califano
I wouldn't worry about point 2).

The only real reason for crossdomains (as I understand, at least) is solving
this potential security hole:

Let's suppose you're in a LAN that has access to some intranet; or to some
servers that you have access to because you're in this LAN, but are not
accessible from the internet, anyway.

So, you can point your broswer to http://www.somesite.com (internet) and
http://myprivate.intranet (LAN access only) and you will reach both. On the
other hand, outside that LAN, you could only reach somesite.com but not
myprivate.intranet.

Since flash runs client side, if there were no crossdomain policy, the swf
you downloaded from www.somesite.com would have access to
myprivate.intranet. It could read data from it and send it back to
www.somesite.com (or somewhere else).

This opens a pontential security hole, especially for corporate intranets.
To prevent this, a host must grant access explicitly. With the crossdomain
files it states that it's ok for swfs downloaded from certain domains to
communicate with it.

So, the only potential problem here would be in your hosting provider's LAN,
as I see it.

Cheers
Juan Pablo Califano



-- Forwarded message --
From: Steven Loe 
Date: 2010/1/13
Subject: [Flashcoders] Crossdomain.xml, shared hosting, https, oh my!
To: Flashcoders mailing list 


Adobe's documentation on this is not crystal clear (to me anyway). Hoping
that someone who's been down this road can point me in the right direction.

My app is hosted on a shared host (webFaction). The swfs are loaded over
http. The users credit card data is transmitted over https. All works fine
in  the flash IDE. However, with the app running in a browser I get:

2048: Security sandbox violation:
http://example.com/media/swf/game.swfcannot load data from
https://example.com/secure/game/direct_payment.

WebFaction serves a global crossdomain.xml file for all it's customers. I
don't have a way to change the policy file at server root. Here's their
file:

http://www.adobe.com/xml/dtds/cross-domain-policy.dtd'>

   


Questions:
1. Given the server configuration, how can I get around the security sandbox
error when I make a https call?
2. How bad (or not) is the resulting security created by the


Thanks very much
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] FlashDevelop code injection

2010-01-13 Thread Juan Pablo Califano
I asume you're using MTASC. There was a flag (I never used it) to workaround
this problem, I think.

Checkout the -mx option: http://www.mtasc.org/

Hope it helps.

Cheers
Juan Pablo Califano

2010/1/13 Andrew Sinning 

> I started looking into using FlashDevelop's code injection tonight.  I'm
> using AS2.
>
> I don't think trying to use this is going to be very practical, as the
> compiler is rather strict in ways that the Flash IDE isn't.  In fact, it's
> so strict that it won't even compile some of the MX classes!
>
> Is there a setting that I'm not aware of that I can use to get FD to inject
> my code and these quite common MX classes.  Thanks!
>
> A few of the things that it doesn't like that I've found so far.
>
> If you declare a variable within curly-braces, and then try to get it
> outside of the braces, the variable is undefined.  (I know that this is
> correct, but as this code is the MX classes, I would hope that it would
> compile.)
>
> You can't re-declare a variable within the same scope.  Again, not
> something that I would do, but quite common in the MX classes.
>
> The input type of a setter must be the same as the return type of a
> same-named getter.  This is really annoying, as it's very convenient to
> except multiple types for the set (e.g. the string-name of an object or the
> object itself) but have the getter return a specific type of object.
> ___
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Best MovieClip removal practice

2010-01-06 Thread Juan Pablo Califano
 For display objects, another option could be using the ADDED_TO_STAGE and
REMOVED_FROM_STAGE events to initialize and destroy the object. In many
cases, at least. In some others, especially if initialization is expensive,
it could be better to have explicit methods for that. But I think in the
general case, using those events simplifies the interface (meaning, the user
of the class doesn't have to bother calling a destroy method, etc).

Cheers
Juan Pablo Califano
-- Forwarded message --
From: Matt S. 
Date: 2010/1/6
Subject: Re: [Flashcoders] Best MovieClip removal practice
To: Flash Coders List 


Not only is it better, but definitely best practice. The most basic
method is to include a listener destroyer function within the class so
that it can deactivate itself before being removed, eg:

SomeMovieClip.destroyMe();
removeChild(SomeMovieClip);
SomeMovieClip = null;

there are fancier ways to handle this of course but thats the basic concept.

http://www.almogdesign.net/blog/actionscript-3-event-listeners-tips-tricks/

.m

On Wed, Jan 6, 2010 at 5:19 PM, ktt  wrote:
> Hello,
>
> After
>
> removeChild(SomeMovieClip);
> SomeMovieClip = null;
>
> it will removed and will wait for garbage collector.
> But maybe it is better to remove most unwanted listeners before nullifying
the MovieClip and not wait for garbage collector?
> It should save some memory space and time for actually "working"
MovieClips and Events.
> What do you think?
>
> Ktt
>
>
>
> ___
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Best MovieClip removal practice

2010-01-06 Thread Juan Pablo Califano
Running a GC cycle is rather intensive and can definitely have an impact on
performance. It's a trade-off. You hold some memory for a little longer than
you actually need, but you save on performance (and many times, memory is
just sitting there with no one using it anyway... also, allocating and
deallocatin has a cost too).

Think about this. How do you know it's better to run a GC than holding back,
say 50 Mb (in a computer that might have, say, 1 Gb to spare)? From
actionscript, there's no way you can know when it's best. The GC has
a better chance to make an educated guess, because it has access to some
data that is not available to you.

Cheers
Juan Pablo Califano


2010/1/6 Karl DeSaulniers 

> So there is no way to fire the garbage collector from actionscript?
> This seems odd to me if that is the case. If the flash applications
> performance is dependent partly on how well the garbage is taken out,
> wouldn't there be a class made for that so we can control it? Or is it too
> risky to be messing with that part?
> Just curious.
>
> Karl
>
>
>
> On Jan 6, 2010, at 5:02 PM, Henrik Andersson wrote:
>
> Event listeners will be destroyed along with the object the listeners
>> belong to. But they will keep on firing until the garbage collector feels
>> like running.
>>
>> Do note that a listener does hold a reference to the listener function
>> from the event source. This means that if the object has a listener on some
>> object that is not up for garbage collection (like the stage), it is not
>> going to be garbage collected either. That's why there is a fifth argument
>> to addEventListener.
>>
>> So yeah, removing the listeners can be needed in some cases, and not
>> needed in other cases. Either way, it is good practice to do remove them.
>> ___
>> Flashcoders mailing list
>> Flashcoders@chattyfig.figleaf.com
>> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>>
>
> Karl DeSaulniers
> Design Drumm
> http://designdrumm.com
>
>
> ___
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] how to reduce file size caused by redundant classes in loaded-in movies

2010-01-06 Thread Juan Pablo Califano
I never actually tryed it, but I remember I bookmarked a link about this
some time ago, maybe you find it useful:

http://exanimo.com/actionscript/flash-cs3-and-exclude-xml/

Cheers
Juan Pablo Califano

2010/1/6 Andrew Sinning 

> A swf that I am loading in to a parent movie has symbols that are linked to
> classes that are already available in the parent movie.  This is causing the
> file size of the loaded-in movie to become much larger than it would
> otherwise be.
>
> The problem is that the symbols import classes which import classes which
> import classes and so on.
>
> Without refactoring my entire project, is there something that I can do to
> eliminate the redundant code from the loaded-in swf?
>
> Thanks!
> ___
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] 64 bit integers

2010-01-04 Thread Juan Pablo Califano
Maybe it's not exactly what you're looking for, but another option could be
using a BitVector.

You can find one in polygonal lab datastructures library, here:

http://lab.polygonal.de/ds/

A nice thing about it is that you don't need to care about the number of
bits you can use. Since the data is stored in an Array o ints, you can grow
it as much as you need, while keeping memory use as low as possible (at
least, in theory!). You can't check more than 1 bit at the time right now,
but if you need to, perhaps you could tweak the class to accept masks...

Some time ago I modified the BitVector class to use a ByteArray as its
backing storage (but preserving the API).

If you want to take a look, check out this link:

http://pastebin.be/22777


Cheers
Juan Pablo Califano

2010/1/4 Alexander Farber 

> Hello,
>
> I have programmed a card game and because
> the game type has 32 cards I made a decision
> to represent each card as a bit in a uint number.
>
> That decision has made many aspects easier
> for me: for example, checking if a player has
> any cards of some suit is simply an &-operation
> against a bit-mask.
>
> Now I'm thinking of programming another card
> games which use 36 or 52 playing cards and
> of course this won't work anymore...
>
> I wonder if 64-bit integers have been announced
> for the future versions of Flash and Flash Player?
>
> Regards
> Alex
> ___
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Caching loaded bitmaps

2009-12-31 Thread Juan Pablo Califano
I don't know about Macs, but I have noticed this same caching behavior in
the past using Windows XP and Flash CS3. If my memory serves me well,
flushing IE's cache made Flash  reload the images from disk (I discovered
this by chance); this seemed a bit odd but I remember I could reproduce it
every time. So maybe, and I'm just guessing here, this "feature" is due to
how the Flash IDE works in Windows, and hence Windows only?

Cheers
Juan Pablo Califano


2009/12/30 Omar Fouad 

> Hi all,
>
> I have some sort of game that requires to load some bitmaps before it
> starts. I do this by using the Loader class, and shifting from an array of
> image Links on each time the Event.COMPLETE fires so that the images load
> one by one. The project is a FLA file (CS4) using document class and some
> other classes.
>
> I did most of this project on my Mac Book today, and every time I test the
> application I had to wait for all the images to load (which takes almost 2
> minutes and it was so annoying).
> By coincidence I moved the project to a PC (windows 7) and I noticed that
> when I test the swf movie from Flash CS4, I have to wait until my 39
> bitmaps
> load only the first time, unless I restart Flash CS4, in all the others
> movie tests, the bitmaps remain "cached" and they load in a heart beat (in
> less than 2 secs). I would like to know what is the trick with that. Why
> this does not happen on Mac? How can I enable this on Mac?
>
> Thanks in advance.
>
> --
> Omar M. Fouad - Adobe™ Flash© Platform Developer
> http://omarfouad.net
> Cell: (+20) 234.66.33
>
>
> This e-mail and any attachment is for authorised use by the intended
> recipient(s) only. It may contain proprietary material, confidential
> information and/or be subject to legal privilege. It should not be copied,
> disclosed to, retained or used by, any other party. If you are not an
> intended recipient then please promptly delete this e-mail and any
> attachment and all copies and inform the sender. Thank you.
> ___
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Dynamically set Sound's length..?

2009-12-16 Thread Juan Pablo Califano
Just a minor correction. It's 44100 samples per second.

Cheers
Juan Pablo Califano

2009/12/16 Henrik Andersson 

> It is called the samplerate, flash uses 44200 sample pairs per second.
>
> ___
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Publish transparent .gif file in AS3

2009-12-14 Thread Juan Pablo Califano
I'm not aware of any GIF encoders written in Actionscript.

If you absolutely need to use GIF (and nobody has yet written an encoder in
AS), I only see 3 options:

1) Get the GIF spec and write the encoder from scratch.
2) Find some open source encoder in other language (like Java) and port it
to Actionscript.
3) As it was already suggested, use the PNGEncoder in as3corelib, send the
encoded image to the server and have the server re-encode it to GIF. In php,
using the GD library, re-encoding should be only a couple of lines.

1) is the hardest, and it's probably not worth the hassle. 2) is close to 1)
in many ways. 3) is the most reasonable option, I think. Unless you
absolutely need to do everything client side.

Cheers
Juan Pablo Califano

2009/12/11 Sumeet Kumar 

> Thanks for your replies.
> I got lot of links using which i can publish jpeg and png images, but
> nothing for gifCan you please send me some link in reference to this.
>
> Thanks again.
> Sumeet Kumar
> - Original Message - From: "David Hunter" <
> davehunte...@hotmail.com>
>
> To: 
> Sent: Thursday, December 10, 2009 10:18 PM
> Subject: RE: [Flashcoders] Publish transparent .gif file in AS3
>
>
>
>
> thanks. all the more reason to upgrade!
>
>  Date: Thu, 10 Dec 2009 17:35:08 +0100
>> From: he...@henke37.cjb.net
>> To: flashcoders@chattyfig.figleaf.com
>> Subject: Re: [Flashcoders] Publish transparent .gif file in AS3
>>
>> David Hunter wrote:
>> >
>> > hi Hendrik, are you on CS4? i'm still on CS3. the >
>> FileReference.download() method allows for URLRequests not bytearrays. > in
>> CS4 there is a save() method which allows you to pass bytearrays. is > that
>> what you mean or am i missing a trick with download() and > URLRequest? it
>> states that i can't use a bytearray datatype for > URLRequest.data with
>> download().
>> > thanks.
>> >
>>
>> Good catch, of course I meant the save method.
>> ___
>> Flashcoders mailing list
>> Flashcoders@chattyfig.figleaf.com
>> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>>
>
> _
> Use Hotmail to send and receive mail from your different email accounts
>
> http://clk.atdmt.com/UKM/go/186394592/direct/01/___
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
> ___
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] text input @ appearing as ' in chrome

2009-11-22 Thread Juan Pablo Califano
It's a bug that's been there for ages in the plugin version of the player
(it affects all browsers except for Internet Explorer, that uses the ActiveX
version of the player).

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

<http://bugs.adobe.com/jira/browse/FP-40>The problem shows in every browser
except IE if you set wmode to anything different from "window" (the
default).

Apparently, they've finally managed to fix it in the latest player.


Cheers
Juan Pablo Califano

2009/11/20 Kevin Bath 

> Hi all,
>
>
>
> Has anyone had the problem with input text fields (AS3 - fp10) where the @
> symbol appear as an apostrophe ' in Chrome browser? (also happens in
> safari)
> - but it's fine on all other browsers (same machine, same keyboard)
>
>
>
> I would pull my hair out - but I have none!
>
>
>
>
>
> thanks,
>
>
>
> Kevin Bath.
>
> ___
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Auto Webcam Detection

2009-11-04 Thread Juan Pablo Califano
The test code works fine for me (Win XP, FP 10).

I'll be working on a project that includes webcam soon and this could be
useful. I'll let you know how it goes if I use it. Thanks for sharing!

Cheers
Juan Pablo Califano

2009/11/4 Ktu 

> So I've noticed that Facebook will automatically detect which Camera object
> to use on your computer.
> It seems on most if not all macs there are at least three (3) Camera
> objects
> always available.
> So, I've made a class that will automatically detect which webcam is active
> and running.
>
> Feedback anyone?
>
> Download it here <http://blog.cataclysmicrewind.com/webcamdetection/>
>
> It's pretty simple to use:
>
> import com.crp.utils.WebcamDetection;
> import com.crp.events.WebcamEvent;
>
> var wd:WebcamDetection = new WebcamDetection();
> wd.addEventListener (WebcamEvent.RESOLVE, onResolve);
> wd.begin();
>
> function onResolve (e:WebcamEvent):void {
> trace(e.code);
> switch (e.code) {
> case "success":
> var myCamera:Camera = e.camera;
> break;
> case "noPermission":
> // the user denied permission
> break;
> case "noCameras":
> // no suitable camera's were found
> break;
> }
> }
> ___
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] regex issue when validating unicode range

2009-10-19 Thread Juan Pablo Califano
Hi
I don't think the regex is wrong. In fact, if you change u for a smaller
number, it works fine.

I have not tested each code point, mind you, but with a few tries, the
highest max range that works that I could find is 0xFEFF.

The range 0xFF00 - 0x apparently is reserved for control stuff. So
0xFEFF is the last value before that range. Not sure if the way the regex
behaves is a bug or a feature, really, but you can probably get by with
something like this:

var testIsArabic:Boolean = /[\u0627-\ufeff]/.test(str.charAt(0));

Cheers
Juan Pablo Califano

2009/10/19 Matt Muller 

> Hi there,
>
> issue with regex when trying to test if a char is within a unicode range
>
> var testIsArabic:Boolean = /\u0627/.test(str.charAt(0)); // this works
> testing for arabic chars of unicode 0627
>
> var testIsArabic:Boolean = /[\u0627-\u]/.test(str.charAt(0));  this
> range does not work, returns false
>
> NOTE: the str.charAt(0) is 0627
>
> any ideas?
>
> cheers,
>
> MaTT
> ___
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] monitor outgoing http requests

2009-10-08 Thread Juan Pablo Califano
Httpfox is not the most powerful tool out ther but will do the job, I think,
and is simple enough.

https://addons.mozilla.org/en-US/firefox/addon/6647

However, I don't think you will see the denied request. The request is sent
by the player only when there are no crossdomain issues.

It might help you to narrow your search, though.


Cheers
Juan Pablo Califano

2009/10/8 Andrew Sinning 

> I'm trying to track down an issue with a cross-domain policy violation.
>  Something in one of my movies is making requests to an outside server, but
> I can't seem to track it down.  I get a "request for resource at
> www.domain.com was denied" message, but I need to figure out what exactly
> was being requested so I can track down the origin.
>
> Is there a utility or a FF extension that I can install that will log all
> of my outgoing http requests, preferable with a filter?
>
> I searched for port-sniffers, but everything I found was either not-free or
> way to complicated to figure out on my limited timeline.
>
> Thanks!
> ___
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] [MEMORY LEAK]

2009-10-01 Thread Juan Pablo Califano
I see. But when you refresh the page, the Flash Player instance is tore
down, so the player's memory is released. When you reload a stub swf, the
memory used by the player might or might not be released immediately. Most
likely it won't. That's not necessarily a bug or a leak. It could be, but my
point was that you should keep in mind that GC is not deterministic; because
maybe you don't have a leak in the first place. The mere fact that the
memory footprint grows doesn't mean there's a leak.

Cheers
Juan Pablo Califano



2009/10/1 TS 

> Well I'm going to use gskinner's workaround by pulling the content swf from
> a subdomain. I am not looking at task manager overall sys memory but, at
> the
> privat working set from the processes tab. And I can see it get loaded then
> every refresh it adds 2-4MB to the working set. On page refresh it drops
> back to where it was.
>
> Thanks, T
>
> -Original Message-
> From: flashcoders-boun...@chattyfig.figleaf.com
> [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Juan Pablo
> Califano
> Sent: Thursday, October 01, 2009 6:35 AM
> To: Flash Coders List
>  Subject: Re: [Flashcoders] [MEMORY LEAK]
>
> >>>>
>
> Every time it reloads
> however, I watch firefox take away memory consistently and when I refresh
> that page memory use drops back to normal.
>
> >>>
>
> First and most important, are you sure it's leak? The fact that Firefox
> (not
> even the player itself) doesn't release memory right away doesn't mean
> there's a leak. At all.
>
> Sorry for the self reference, but a while ago I answered a question in
> stackoverflow about an alleged memory leak.
>
> http://stackoverflow.com/questions/1020146/why-sytem-totalmemory-keeps-incre
> asing/1022648#1022648.
> Perhaps it helps to get my point across.
>
> Looking at Qindows manager or System.totalMemory is probably the worst
> possible way to detect a leak, given how the player works. You'll get tons
> of false positives and the info is rather useless anyway.
>
> What has been of great help, at least for me, is using Flex Builder's
> profiler. It lets you inspect objects in memory, force a gc, etc. Plus, if
> you do find a leak, you can trace where the leaked object has been
> allocated. A simple test for your scenario would be taking a snapshot
> before
> loading your swf, then another when it's loaded, then unload, force a GC
> and
> take another snapshot. Then you can compare memory at those points and be
> in
> a better position to determine if there's a leak, and, in that case, what
> could be causing it.
>
> Hope it helps.
>
> Cheers
> Juan Pablo Califano
>
>
>
>
>
> 2009/9/30 TS 
>
> > Hello, this issue is killing me. I had a swf that loaded an xml file then
> > loaded images from the xml file and then killed the display list, xml,
> > images etc... then restarted based on a timer. Every time it reloads
> > however, I watch firefox take away memory consistently and when I refresh
> > that page memory use drops back to normal. So, I said screw this, I'm
> going
> > to create an empty swf and load the swf with all the magic in it and add
> it
> > to the empty swf. I figured if I add the swf to the main stage and kill
> > that
> > one reference to the swf when I was done with it, I should have fixed my
> > problem. Here's my code. Can someone please tell me what is going on?
> >
> >
> > stop();
> >
> > var mLoader:Loader = new Loader();
> > function startLoad()
> > {
> >var mRequest:URLRequest = new
> > URLRequest("hasch_flash/currently_watched_videos.swf");
> >//var mRequest:URLRequest = new
> > URLRequest("currently_watched_videos.swf");
> >mLoader.contentLoaderInfo.addEventListener(Event.COMPLETE,
> > onCompleteHandler, false, 0, true);
> >mLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS,
> > onProgressHandler, false, 0, true);
> >mLoader.load(mRequest);
> > }
> >
> > function onCompleteHandler(loadEvent:Event)
> > {
> >trace("load " + loadEvent.currentTarget.content);
> >trace("loadTarget " + loadEvent.target);
> >addChild(loadEvent.currentTarget.content);
> > }
> > function onProgressHandler(mProgress:ProgressEvent)
> > {
> >var percent:Number = mProgress.bytesLoaded/mProgress.bytesTotal;
> >trace(percent);
> > }
> > startLoad();
> >
> >
> > TimerExample();
> >
> > // Set off t

Re: [Flashcoders] [MEMORY LEAK]

2009-10-01 Thread Juan Pablo Califano
>>>>

Every time it reloads
however, I watch firefox take away memory consistently and when I refresh
that page memory use drops back to normal.

>>>

First and most important, are you sure it's leak? The fact that Firefox (not
even the player itself) doesn't release memory right away doesn't mean
there's a leak. At all.

Sorry for the self reference, but a while ago I answered a question in
stackoverflow about an alleged memory leak.
http://stackoverflow.com/questions/1020146/why-sytem-totalmemory-keeps-increasing/1022648#1022648.
Perhaps it helps to get my point across.

Looking at Qindows manager or System.totalMemory is probably the worst
possible way to detect a leak, given how the player works. You'll get tons
of false positives and the info is rather useless anyway.

What has been of great help, at least for me, is using Flex Builder's
profiler. It lets you inspect objects in memory, force a gc, etc. Plus, if
you do find a leak, you can trace where the leaked object has been
allocated. A simple test for your scenario would be taking a snapshot before
loading your swf, then another when it's loaded, then unload, force a GC and
take another snapshot. Then you can compare memory at those points and be in
a better position to determine if there's a leak, and, in that case, what
could be causing it.

Hope it helps.

Cheers
Juan Pablo Califano





2009/9/30 TS 

> Hello, this issue is killing me. I had a swf that loaded an xml file then
> loaded images from the xml file and then killed the display list, xml,
> images etc... then restarted based on a timer. Every time it reloads
> however, I watch firefox take away memory consistently and when I refresh
> that page memory use drops back to normal. So, I said screw this, I'm going
> to create an empty swf and load the swf with all the magic in it and add it
> to the empty swf. I figured if I add the swf to the main stage and kill
> that
> one reference to the swf when I was done with it, I should have fixed my
> problem. Here's my code. Can someone please tell me what is going on?
>
>
> stop();
>
> var mLoader:Loader = new Loader();
> function startLoad()
> {
>var mRequest:URLRequest = new
> URLRequest("hasch_flash/currently_watched_videos.swf");
>//var mRequest:URLRequest = new
> URLRequest("currently_watched_videos.swf");
>mLoader.contentLoaderInfo.addEventListener(Event.COMPLETE,
> onCompleteHandler, false, 0, true);
>mLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS,
> onProgressHandler, false, 0, true);
>mLoader.load(mRequest);
> }
>
> function onCompleteHandler(loadEvent:Event)
> {
>trace("load " + loadEvent.currentTarget.content);
>trace("loadTarget " + loadEvent.target);
>addChild(loadEvent.currentTarget.content);
> }
> function onProgressHandler(mProgress:ProgressEvent)
> {
>var percent:Number = mProgress.bytesLoaded/mProgress.bytesTotal;
>trace(percent);
> }
> startLoad();
>
>
> TimerExample();
>
> // Set off timer to kill carousel and restart movie
> function TimerExample() {
>var myTimer:Timer = new Timer(3, 0);
>myTimer.addEventListener("timer", timerHandler);
>myTimer.start();
> }
>
> function timerHandler(event:TimerEvent):void {
>trace(this.removeChildAt(0)); // remove from display list
>mLoader = null;
>mLoader =  new Loader(); // clear from memory
>startLoad();
>trace("timerHandler: " + event);
> }
>
>
> Thanks for any advice. T
>
> ___
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


  1   2   3   >