Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Event Handler Help

Posted on 2006-07-12
2
283 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
ID: 17098359
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
ID: 17100356
Awesome, thanks!!!!  
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is a very simple example to help those of you who are still migrating from AS2 to AS3 understand the redesigned event model in AS3. In AS2.0, event functions (that is, the function to be performed when an event is fired) were stored as a pro…
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 select which audio input to use. Once you have an audio input plugged into the laptop or computer, you will go into the audio input settings and choose which audio input you want to use.
The goal of the tutorial is to teach the user what frame rate is, how to control it and what effect it has on the video.

792 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