IT Community - Software Programming, Web Development and Technical Support

Scope Trouble while calling Functions

This is a discussion on Scope Trouble while calling Functions within the Flash Actionscript Programming forums, part of the Web Development category; Hi all, A bit of scope trouble. I have a class file that takes an onRelease event and then creates ...


Go Back   IT Community - Software Programming, Web Development and Technical Support > Web Development > Flash Actionscript Programming

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 12-14-2007, 05:25 AM
aramesh aramesh is offline
D-Web Programmer
 
Join Date: Mar 2007
Posts: 72
aramesh is on a distinguished road
Default Scope Trouble while calling Functions

Hi all,

A bit of scope trouble.

I have a class file that takes an onRelease event and then creates movement from the Tween class.


nTween = new mx.transitions.Tween(this, "_x",mx.transitions.easing.Elastic.easeOut, _x, 500, 2, true);


Simple enough. Now when the motion completes (via onMotionFinished event) I need to call a function in the class.


nTween.onMotionFinished = function(){
myClassFunction();
}


The issue is that the scope is not typical to the event model. Meaning that using evt.target comes up undefined to try and reference the calling object.

A trace of 'this' returns [Tween] in the Output.

A trace of this._parent returns undefined.

Anyone know how to get around this?

With Regards.

aramesh
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 12-14-2007, 05:29 AM
oxygen oxygen is offline
D-Web Architect
 
Join Date: Jun 2007
Posts: 633
oxygen is on a distinguished road
Default Re: Scope Trouble while calling Functions

Hi, Do it like this instead:

import mx.transitions.Tween;
import mx.transitions.easing.*;
var myTween:Tween = new Tween (this, "_x", Elastic.easeOut, _x, 500, 2,
true);
myTween.addListener (this);
function onMotionFinished (pTween:Tween):Void
{
trace (this);
trace (pTween);
}
__________________
The OXYGEN
Delivers edgy, intelligent Technology to all...
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Trouble getting movieclips to play at random aramesh Flash Actionscript Programming 5 02-19-2008 06:48 AM
scope variable itbarota HTML, CSS and Javascript Coding Techniques 1 11-13-2007 12:29 AM
Calling Winrunner functions in QTP crusader Testing Tools 0 09-07-2007 01:19 AM
calling exe bluesky Database Support 6 08-09-2007 05:41 AM
Calling WinRunner Functions in QTP senthilkannan Testing Tools 0 07-19-2007 01:14 AM


All times are GMT -7. The time now is 09:41 PM.


Copyright ©2004 - 2007, DiscussWeb. All Rights Reserved.

SEO by vBSEO 3.0.0