Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 217
  • Last Modified:

TweenEvents not working?

Hi, does any body know why the TweenEvents in the code below aren't calling the blurOn and blurOff functions???  If I put blur filters explicitly in clickHandler1 though for example the blur IS working???

Thanks in advance

import fl.transitions.*;
import fl.transitions.Tween;
import fl.transitions.easing.*;
import flash.display.Sprite;
import flash.filters.BitmapFilterQuality;
import flash.filters.BlurFilter;


var slideTimer:Timer = new Timer(10000);
slideTimer.addEventListener(TimerEvent.TIMER, slideRect);

function slideRect(e:TimerEvent):void
{
      var myTween:Tween = new Tween(rectangle,"x",Strong.easeOut,rectangle.x,rectangle.x - 960,.5,true);
}

slideTimer.start();

go1.addEventListener(MouseEvent.CLICK, clickHandler1);
go1.addEventListener(TweenEvent.MOTION_CHANGE, blurOn);
go1.addEventListener(TweenEvent.MOTION_FINISH, blurOff);
go1.mouseEnabled = true;
go1.buttonMode = true;

function clickHandler1(e:MouseEvent)
{
      slideTimer.reset();
      slideTimer.start();
      var myTween:Tween = new Tween(rectangle,"x",Strong.easeOut,rectangle.x,0,3,true);
      trace(rectangle.x);
      
      /*var blur:BlurFilter = new BlurFilter();
            blur.blurX = 50;
            blur.blurY = 50;
            blur.quality = BitmapFilterQuality.MEDIUM;
            rectangle.filters = [blur];*/
}

function blurOn(event:TweenEvent):void{
            var blur:BlurFilter = new BlurFilter();
            blur.blurX = 50;
            blur.blurY = 50;
            blur.quality = BitmapFilterQuality.MEDIUM;
            rectangle.filters = [blur];
            }

function blurOff(event:TweenEvent):void{
            var blur:BlurFilter = new BlurFilter();
            blur.blurX = 0;
            blur.blurY = 0;
            blur.quality = BitmapFilterQuality.MEDIUM;
            rectangle.filters = [blur];
            }
0
Sideas
Asked:
Sideas
2 Solutions
 
deepanjandasCommented:
What is go1. I guess it is a button. So the event that gets dispatched from a button is not TweenEvent.
You have to add the Tween event listener to the tween instance "myTween".

Warm Regards
Deepanjan Das
0
 
Jeremy DaleySenior DeveloperCommented:
Deepanjan is right on adding the TweenEvent to myTween, not go1. You may also want to declare your myTween variable outside the scope of a function (like at the top of your code). When the Flash garbage collector clears things out, myTween will be removed due to the nature of it's scope.
0
 
SideasAuthor Commented:
Aaah, thanks very much guys
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now