Solved

Event Handler Help

Posted on 2006-07-12
2
280 Views
Last Modified: 2008-03-17
Greetings,
I'm having trouble with an onMotionFinished Event Handler.  I have a box that slides accross the stage and once it stops I want the onMotionFinished event handler to execute some code that will write a title in front of the box.  For some reason the code that writes the title won't execute when placed within the onMotionFinished event handler.  It works when it's placed outside of the event handler, but I need it to start writing once the box has stopped.  When I trace the event handler the trace message comes through fine.  Not sure what I'm doing wrong...

Here is what I have:

import mx.transitions.*;
import mx.transitions.easing.*;
import classes.TextScript;

var myFormat:TextFormat = new TextFormat();
myFormat.font="HelveticaNeue BoldExt";
myFormat.bold = true;
myFormat.size = 18;
myFormat.color = 0xFFFFFF;

var phrase:String = "Phase 01:";
var xLoc:Number = -13;
var yLoc:Number = 10;
var delay:Number = 1;

var tween_handler:Object = new Tween(box_mc, "_x", Regular.easeInOut, 0, 150, 30, false);
tween_handler.onMotionFinished = function() {
      //trace("OnMotionFinished function");
      TextScript.typewriter(this, phrase, xLoc, yLoc, myFormat, delay);
};

Thanks in advance for your help.
0
Comment
Question by:djnathanjones
2 Comments
 
LVL 34

Accepted Solution

by:
Aneesh Chopra earned 500 total points
Comment Utility
Hi,

problem is in "this"
--------
TextScript.typewriter(this, phrase, xLoc, yLoc, myFormat, delay);
-------

if you trace "this" inside "onMotionFinished" function, it will return "Tween object", not the movieClip

solution to the problem is use absolute reference here
for example, if you have this code on _root than following code will work
---------------
tween_handler.onMotionFinished = function() {
     //trace("OnMotionFinished function");
     TextScript.typewriter(_root, phrase, xLoc, yLoc, myFormat, delay);
};
--------------

Rgds
Aneesh
0
 

Author Comment

by:djnathanjones
Comment Utility
Awesome, thanks!!!!  
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Embedding Flash App/Movie on Website 3 484
Action Script commands 4 302
free flash maker 5 196
IE11 stops playing video on a certain website 10 53
Introduction This article is primarily concerned with ActionScript 3 and generally specific to AVM2.  Most suggestions would apply to ActionScript 2 as well, and I've noted those tips that differ between AS2 and AS3. With the advent of ActionS…
There are times in your Flash CS4 application when you want more than a simple pointer or a hand, and it's hard to find an ideal walk-through to tell you what to do.  I spent a few days recently learning my way around making custom cursors in Flash,…
The goal of the tutorial is to teach the user how to how to load their YouTube profile onto Flash Media Live Encoder.
The goal of the tutorial is to teach the user how to use the auto adjust feature and what the different options do. When your video is not working right you can choose the auto adjust feature to help choose your settings.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now