Order of Setting Transformer & Constraint Matters

Edited on 09/05/09
I just found out that it matters in which order you set transformer and constraint. From the outside (i.e. the API) there's no direct connection between the two, but looking at the code it's very simple to see.

function set constraint overwrites viewport.transformer.constraint
function set transformer overwrites viewport.transformer

So in case you first add the constraint and later on the transformer, you'll no longer have any constraints in place.

I have a patch (made from 0.4.2 SDK) for MultiScaleImageBase, which fixes this behaviour:

Index: MultiScaleImageBase.as
===================================================================
--- MultiScaleImageBase.as (revision 8310)
+++ MultiScaleImageBase.as (working copy)
@@ -186,8 +186,11 @@

public function set transformer(value:IViewportTransformer):void
{
- if (transformer !== value)
- viewport.transformer = value
+ if (transformer === value)
+ return;
+ var oldConstraint:IViewportConstraint = viewport.transformer.constraint;
+ viewport.transformer = value
+ viewport.transformer.constraint = oldConstraint;
}

//----------------------------------


Of course, it is debatable, if one should copy attributes from an old transformation to a new one, but i found it pretty confusing that the order, in which i set the attributes. matters.
 
happy
Inappropriate?
1 person likes this idea
See the changes made to this idea
User_default_medium