[Flashcoders] Wherefore the evils of _global?

2006-03-23 Thread David Stiller
In the last few days, I've seen a handful of people refer
apologetically to use of the _global object.  To paraphrase:  I'm in a
situation where I have to use _global variables, or, We all know _global
is a no-no, but I'm tempted to use it in this one weird case, etc.  In
general, this gives me the impression that it's fashionable here to think of
_global as Evil -- or in the very least, yucky.

I understand why _root can be troublesome, especially in conjunction
with dynamically loaded SWFs, but I do use it in a pinch.  I mean, heck,
sometimes a movie is just a movie, not a portable app.

What I don't understand -- and I hasten to say I have no opinion on
the matter, yet -- is why _global is so shunned.  After all, _global is
exactly where AS2 classes are located.  Is this a religious issue?  Is it
because of how _global gets shared (or not?) among dynamically loaded SWFs?


David
[EMAIL PROTECTED]

___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com


RE: [Flashcoders] Wherefore the evils of _global?

2006-03-23 Thread David Stiller
Responding to two, here ...

 ryanm wrote:

 Because global variables are contrary to the
 basis of OOP, which is all about abstraction
 and encapsulation. If you need to store
 variables somewhere so that they can be
 reached anywhere, use a singleton, or a static
 class, or an application object, and so on.

Okay, I'm with you.  That jibes with my understanding of OOP in
a universal sense.  In ActionScript, however, classes *are* properties
of the _global object, which is what prompted my question.  Programmers
in general may agree to avoid global variables in principle, and what
I'm hearing is that ActionScript programmers, in a sense, pretend
_global isn't being used unless invoked explicitly.

Caveat:  By pretend, I don't mean AS programmers are fibbers
... it's more like we agree to an anticipatory linguistic contrivance
while gearing up for AS3.  Right?  Same as we speak of strong typing in
AS2:  technically speaking, AS2 is not strongly typed.  Post-colon
syntax, at least currently, is a device for accommodating compile-time
error messages and code hinting.

 Tyler Wright wrote:

 _global is a perfect place to store application
 meta data [...] if you're building anything of
 significance (in size) you should have a class
 [...] This way every thing thrown the way of
 global vars is documented, type checked, and
 follows some sort of API.

That makes perfect sense.


David
[EMAIL PROTECTED]

___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com


RE: [Flashcoders] Determining width of rotatedMC'simaginaryboundingbox

2006-03-21 Thread David Stiller
 Odie Bracy PhD wrote:
 Actually, your width will change with the
 rotation. The greatest width will be when
 the diagonal line of your rectangle is a
 flat, horizontal line.

That seems to sum it up, for sure.  Thanks, Odie.

 Yotam Laufer wrote:
 First of all you're welcome. When using
 the mathematical approace, are you feeding
 the Math.sin (a) method radian or degrees?
 It should be radians could that be your
 problem?

I'm using radians.  I thought about that, too, and checked for
the possibility first thing.  The more I experiment, actually, the more
I see the light.  Thanks for all the input!


David
[EMAIL PROTECTED]

___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com


[Flashcoders] Determining width of rotated MC's imaginary bounding box

2006-03-20 Thread David Stiller
I suspect the answer to this one is purely geometry.  It's trivial
to determine the width or height of a movie clip:  there's the _width and
_height properties, of course, as well as getBounds().  But when the clip is
rotated, the concept of width changes.  I'm looking for a way to determine
the width of an imaginary bounding box that contains the rotated clip.

Tips, tutorials, guidance?


David
[EMAIL PROTECTED]

___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com


RE: [Flashcoders] Determining width of rotated MC's imaginaryboundingbox

2006-03-20 Thread David Stiller
Yotam,

 Correct usage of getBounds will give you
 the correct result. You have to point the
 coordinate scope of the getBounds method
 to the parent of the mc.

Wow!  Yes, thank you, Yotam.  Now I'm slapping my forehead, too.  It
doesn't get easier than that.

I'm still interested in the geometry approach, for non-ActionScript
applications, so if anyone can show me where I stepped wrong with Danny's
suggestion, I'd appreciate it.


David
[EMAIL PROTECTED]

___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com


RE: [Flashcoders] Determining width of rotatedMC'simaginaryboundingbox

2006-03-20 Thread David Stiller
Danny,

 My MC is a 150x30 rectangle rotated to 45 degrees.
 My results show width and height both at 180, when
 they should be closer to 130.  Here's my code:

 That's odd: when I go through those calculations
 with a calculator, they come out with about 130,
 just as you say [...].  Are you sure your mc._width
 and mc._height are returning the correct values?

Well, I checked, and am beginning to feel dumber and dumberer.
Somewhere, when I was dealing with this last night, my head must have been
clouded up.  If I take a 150x30 movie clip in the IDE and rotate it, the
width and height, as indicated in the Properties inspector, updates the way
your calculation and the getBounds approach dictate they should.

I was expecting mc._width to always return 150, even when it was
rotated.  After all, the clip's width, from its own POV, hasn't changed.  In
fact, I would swear this is what was happening last night -- but, sheesh,
maybe not?  If I simply trace mc's _width and _height from the main
timeline, the values returned by those properties give me the data I want.
This happens with dot notation as well as onClipEvent(load) {trace()}.

So ... I guess my whole question is moot.  But now I'm scratching my
head.


David
[EMAIL PROTECTED]

___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com


[Flashcoders] Marrying Function.apply() to WebService web method calls

2006-03-14 Thread David Stiller
I'd like to use Function.apply() on WebService instances' web
methods.  Should be pretty straightforward, right?  Turns out the answer is
no.  I figure the quickest way to illustrate my problem is to relate my
journey in a few blocks of code.

Here's a successful sample, using a freebie US ZIP code service.
Note:  Make sure to drag a WebServiceClasses compiled clip onto your Stage
from Windows  Common Libraries  Classes.


// FIRST TRY
import mx.services.*;
var wsdl:String = http://www.webservicex.net/uszip.asmx?WSDL;;
var ws:WebService = new WebService(wsdl);
var pc:PendingCall = ws.GetInfoByZIP(90210);
pc.onResult = function(evt) {
  trace(evt.NewDataSet);
};

... which traces the following XML ...

NewDataSet xmlns=TableCITYBeverly
Hills/CITYSTATECA/STATEZIP90210/ZIPAREA_CODE310/AREA_CODETIME
_ZONEP/TIME_ZONE/Table/NewDataSet

Easy.

Now, to transform it into a slightly more generic mechanism ...


// SECOND TRY
import mx.services.*;
var wsdl:String = http://www.webservicex.net/uszip.asmx?WSDL;;
var meth:String = GetInfoByZIP;
var param:String = 90210;
var ws:WebService = new WebService(wsdl);
var pc:PendingCall = ws[meth](param);
pc.onResult = function(evt) {
trace(evt.NewDataSet);
};

Still successful.  Now, Function.apply() takes an array of
arguments, which is the reason I want to use it.  To continue stepping in
that direction, I update the above param lines to ...

var param:Array = [90210];

... and ...

var pc:PendingCall = ws[meth](param[0]);

... and as expected, all goes well -- still.  At this point, I should be
able to slap in Function.apply(), like so ...

// THIRD TRY
import mx.services.*;
var wsdl:String = http://www.webservicex.net/uszip.asmx?WSDL;;
var meth:String = GetInfoByZIP;
var param:Array = [90210];
var ws:WebService = new WebService(wsdl);
var pc:PendingCall = ws[meth].apply(null, param);
pc.onResult = function(evt) {
trace(evt.NewDataSet);
};

... but it all falls apart.  If you turn on VERBOSE logging, everything
rolls along as usual until it hangs on the final line ...

3/13 12:7:30 [INFO] : Set active port in service stub: USZip : USZipSoap


Any thoughts?


David
[EMAIL PROTECTED]

___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com


RE: [Flashcoders] Marrying Function.apply() to WebService web methodcalls

2006-03-14 Thread David Stiller
Got it!  The solution is due entirely to Arjan van Ham, who recently
Googled a year-and-a-half old variant of my question on the flash-db.com
forum.  Thanks Arjan!

Now that I see it, the answer is slap-your-forehead obvious.  eval()
to the rescue.

// Replace this ...
var pc:PendingCall = ws[meth].apply(null, param);

// with this ...
var pc:PendingCall = eval(ws. + meth).apply(ws, param);


 At this point, I should be able to slap in Function.apply(),
 like so ...

 // THIRD TRY
 import mx.services.*;
 var wsdl:String = http://www.webservicex.net/uszip.asmx?WSDL;;
 var meth:String = GetInfoByZIP;
 var param:Array = [90210];
 var ws:WebService = new WebService(wsdl);
 var pc:PendingCall = ws[meth].apply(null, param);
 pc.onResult = function(evt) {
   trace(evt.NewDataSet);
 };

 ... but it all falls apart.  If you turn on VERBOSE logging,
 everything rolls along as usual until it hangs on the final
 line ...

___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com


RE: [Flashcoders] Key down forces button/mc onRelease/onReleaseOutside

2005-11-03 Thread David Stiller
Actually, I was talking about movie clip based buttons.  :)  In my
testing, it is both movie clips and buttons (symbol buttons) that fire the
onRelease and onReleaseOutside when a key is pressed.

HOWEVER, I just learned this issue only occurs when you test the SWF
inside the IDE.  Good to know!


David
[EMAIL PROTECTED]


-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of David
Skoglund
Sent: Wednesday, November 02, 2005 9:44 AM
To: Flashcoders mailing list
Subject: Re: [Flashcoders] Key down forces button/mc
onRelease/onReleaseOutside


Sound like a similar problem to mine that I posted a couple of days ago. I 
got no replies i'm afraid.

I think I'll create some movie clip-based buttons instead, but havn't had 
time to test if movie clips show the same behaviour or not.

/David

-- attached message ---
Hi, I'm new to this list, heard about it from DirGames.

I have a problem with button components that annoys me a lot, it seems lika 
buttons auto-activate whenever I move the cursor over them and have either 
shift, control or alt pressed..? I really need to use those keys while 
dragging objects around the scene

Is there anyway to disable this behavior, or do you think I should I write 
my own components/button MC:s instead of using the default?

Thanks for any suggestions!

/David Skoglund


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


[Flashcoders] Key down forces button/mc onRelease/onReleaseOutside

2005-11-02 Thread David Stiller
Is anyone else seeing this?  Draw a shape, convert to button or mc.
Code the following:

btn.onPress = function() {
trace(pressed);
}
btn.onRelease = function() {
trace(released);
}
btn.onReleaseOutside = function() {
trace(released outside);
}

Click the symbol to see pressed in the Output panel.  Release, of
course, to see released.

Now click again, but hold this time.  Now press any key.  If you're
over the symbol, you'll see released, even though you haven't; if you're
not over the symbol, you'll see released outside, even though you haven't.

This is a total bummer if you want to write a drawing app with Shift
constrain or Ctrl whatever.

Anyone know a workaround?


David
[EMAIL PROTECTED]
Luck is the residue of good design.

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