Solved

Event Handler Help

Posted on 2006-07-12
2
286 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
[X]
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
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: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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 intended to introduce all collision detection principles in flash, their strengths, weaknesses and workarounds. The main method for Collision Detection in flash is using hitTestObject. But unless you'll be pushing rectangular shapes without …
I have been doing hardcore actionscripting for some time; and needless to say I have faced a lot of problems in just understanding others' code rather than understanding what the code executes. A programmer's life can become hell when there are a lo…
The goal of the tutorial is to teach the user how to live broadcast using Flash Media Live Encoder and connecting it to YouTube to broadcast. Log into your Youtube account, choose live stream settings, start live stream from Flash Media Live Enc…
The goal of the tutorial is to teach the user how to how to record live broadcast.

630 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