[
https://issues.apache.org/jira/browse/FLEX-14454?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Justin Mclean resolved FLEX-14454.
----------------------------------
Resolution: Fixed
Fix Version/s: Apache Flex 4.10.0
Fixed issue in 4.10 develop branch. Re-raise any enhancements as new JIRA
issues if still required.
> stop function of Tween object does not working properly
> -------------------------------------------------------
>
> Key: FLEX-14454
> URL: https://issues.apache.org/jira/browse/FLEX-14454
> Project: Apache Flex
> Issue Type: Bug
> Components: Effects
> Affects Versions: Adobe Flex SDK 3.0 (Release)
> Environment: Affected OS(s): All OS Platforms
> Affected OS(s): All OS Platforms
> Browser: Internet Explorer 7.x
> Language Found: English
> Reporter: Adobe JIRA
> Fix For: Apache Flex 4.10.0
>
>
> Steps to reproduce:
> 1. Define any custom object (say CustomObject) with property (say tweener) of
> type Tween which is created in constructor.
> public class CustomObject {
> private var tweener: TweenEx;
> public function CustomObject() {
> tweener = new Tween (this, 0, 1, 1000, -1, tweenerUpdate,
> tweenerEnd);
> }
> 2. Create instance of CustomObject which creates Tween abject and animation
> is started.
> var customObject1 = new CustomObject();
> 3. While running the tweener from first custom object create another custom
> object.
> 4. When first custom object finished its animation but second one still
> running call stop() method of Tween object of first custom class.
>
> Actual Results:
> The Tween object from second custom object will be stoped.
>
> Expected Results:
> Nothing should happen.
>
>
> Workaround (if any): -
> I have checked source code for Tween object and found the reason. Also I
> found one more minor bug while checking source.
> The problem is when we creating new Tween it is automatically added to the
> activeTweens static array. The ID of the tween is index in the array.
> So when I created customObject1 which creates Tween object let say tween1
> that object has ID = 0 and pushed to the array.
> Then I created customObject2 which creates tween2 with ID=1 and also pushed
> to the activeTweens array.
> Next when tween1 is fineshed it automaticaly removed from the array and
> indexes of existing tweens recalculated. So at that moment we have tween2 in
> the array with ID=0. But we still have tween1 instantiated and tween1 also
> have ID=0. So now if I call stop for tween1 then Tween class will stop tween2
> object.
> The simplest solution is just to set ID to -1 or so to unbind the tween from
> the array during removing it like that:
> private static function removeTweenAt(index:int):void
> {
> if (index >= activeTweens.length || index < 0)
> return;
> Tween(activeTweens[index]).id = -1;
>
>
> About another bug:
> in the private static function timerHandler(event:TimerEvent):void you can
> see:
> var n:int = activeTweens.length;
> for (var i:int = n; i >= 0; i--)
> but should be
> var n:int = activeTweens.length;
> for (var i:int = n-1; i >= 0; i--)
> Also I would recomend to extend it a bit like:
> add a new property to the constructor like startWhenCreated: Boolean = true.
> then it is possible to create Tween object but do not start it automatically.
> add a new property to the constructor like startFunction: Function
> extend resume() function in such way that if Tween is fineshed and then
> resume() is called the tween object again pushed to the array and tween makes
> reverse and continue working. then it is simple to do infinite animations to
> both ways. Also direction attribute would be nice to have as public property
> (read only is enaugh).
> Also may be make sense to have attribute like autoreverse.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira