I know the title of this question is quite vague, but it's hard to explain it in a few words.
I have two non-document classes, Animation and SmartItem. SmartItem, which extends MovieClip class, has an Animation variable to access to Animation's functions, just like MovieClip.graphics, which lets you access to flash.display.Graphics.
I would like to do the same thing with SmartItem, but with a function of the class Animation.
Let's say I have the function called
LinearTween(x0:Number,y0:Number,xF:Number,yF:Number,seconds:Number,easing:Function);, which creates two Tween objects based on the SmartItem used to call the LinearTween function.
mySmartItem.animation.LinearTween(0,0,10,10,1,None.easeNone)
In this case it will create two Tween objects based on mySmartItem.
The problem is that I don't know how to access to this object inside the Animation class in order to create the Tween object. The resulting Tween objects should look like this:
var myTweenX:Tween = new Tween(/*mySmartItem*/,"x",x0,xF,None.easeNone,seconds,true);
var myTweenY:Tween = new Tween(/*mySmartItem*/,"y",y0,yF,None.easeNone,seconds,true);
How can I reference to mySmartItem in the class Animation? I tried using an instance of Stage in Animation and tried to access to mySmartItem, and gave me runtime error 1009.
Animation.as:
package myStudio.basic {
import fl.transitions.Tween;
import myStudio.basic.CoreModus;
import myStudio.dynamic.SmartItem;
import flash.utils.*;
public class Animation {
import fl.transitions.easing.*;
import flash.display.Stage;
public var anim:Tween;
public var modus:String;
static var STAGE:Stage;
public function Animation() {
}
public function LinearTween(x0:Number,y0:Number,xF:Number,yF:Number,seconds:Number):void {
var myTweenX:Tween = new Tween(not_set_yet,"x",None.easeNone,x0,xF,seconds,true);
var myTweenY:Tween = new Tween(not_set_yet,"y",None.easeNone,y0,yF,seconds,true);
function play():void {
myTweenX.start();
myTweenY.start();
}
trace("Linear Tween");
}
}
}
Note: I put not_set_yet as a placeholder where I'm supposed to reference to the object.
SmartItem.as:
package myStudio.dynamic {
import flash.display.MovieClip;
import myStudio.basic.Animation;
public class SmartItem extends MovieClip {
public var animation:Animation;
static var _instance:SmartItem = null;
public function SmartItem():void {
}
}
}