Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Event Handler Help

Posted on 2006-07-12
2
Medium Priority
?
292 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 2000 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

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 …
While working over numerous projects I often had the requirement for doing a screen capture in AS3.0. Unfortunately I found no "ready made" solutions in google search that suited my requirements. But I did come across some great resources which help…
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 load their YouTube profile onto Flash Media Live Encoder.

885 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