Hey all,
Yet again i get stuck on something really stupid.
I have this code in where i try to animate a simple bus, so i try it with the tween class. And use almost the same code as described in the actionscript cookbook. But suprise suprise, it doesn’t work :p.
So the only thing i wan’t so far is when i start my movie, the bus drives to the center of the screen and stops. That’s all.
This is my code so far (doesn’t work), when i run it the bus just stands still without moving an inch.
package {
import fl.transitions.Tween;
import fl.transitions.easing.*;
import flash.display.DisplayObject;
import flash.display.*;
import flash.events.*
import flash.geom.Rectangle;
public class createMc extends MovieClip {
public var auto:mcAuto = new mcAuto();
public var appaGek:mcAppaGek = new mcAppaGek();
public var appa:mcAppaOng = new mcAppaOng();
public var zwart:mcZwart = new mcZwart();
public var wolk:mcWolk = new mcWolk();
public var trot:mcTrot = new mcTrot();
public var lantOff:mcLantOng = new mcLantOng();
public var luchtGek:luchtMc = new luchtMc();
public var luchtOn:luchtOnMc = new luchtOnMc();
public var _sliderMc:sliderMc = new sliderMc();
public var _balkMc:BalkMc = new BalkMc();
public function createMc() {
wolk.x=0;
wolk.y=wolk.height;
addChild(wolk);
zwart.x=0;
zwart.y=630;
addChild(zwart);
appa.x=0;
appa.y=600;
addChild(appa);
appaGek.x=0;
appaGek.y=240;
addChild(appaGek);
appaGek.maskMc.width=0;
luchtGek.x=0;
luchtGek.y=0;
luchtGek.width=0;
addChildAt(luchtGek,0.1);
luchtOn.x=0;
luchtOn.y=0;
addChildAt(luchtOn,0);
trot.x=0;
trot.y=600;
addChild(trot);
lantOff.x=0;
lantOff.y=600;
lantOff.height=120;
addChild(lantOff);
auto.x = 0;
auto.y=600;
addChild(auto);
_sliderMc.x = 0;
_sliderMc.y = 600;
addChild(_sliderMc);
_balkMc.x = 0;
_balkMc.y = 600;
addChild(_balkMc);
auto.addEventListener(Event.ENTER_FRAME, animatie);
}
private function animatie(evt:Event):void {
trace("animatie");
trace(stage.stageWidth/2);
var myTween:Tween = new Tween(auto, "x", Regular.easeInOut, auto.x, (stage.stageWidth/2)-auto.width/2, 0.3);
luchtGek.width = (auto.x + 15);
appaGek.maskMc.width = auto.x;
}
}
}
And the code in my timeline:
import createMc;
var startM:createMc = new createMc();
addChild (startM);
Grts !
Edit:
When i try:
auto.x += 1;
instead of the tween the van Does move, so it must be something with the tween stuff and how i use it.