I have the following code:
public function myLeftHand():void
{
leftHand = new Hand();
leftHand.x = head.x - 20;
leftHand.y = head.y + 50;
addChild(leftHand);
leftHand.addEventListener(Event.ENTER_FRAME, checkFrame);
TweenMax.from(leftHand, 2, {x:420});
}
//check the hands and stop when they reach the 40 frame
public function checkFrame(e:Event):void
{
if (e.target.currentFrame == 40)
{
e.target.stop();
trace("hand is done tweening");
e.target.removeEventListener(Event.ENTER_FRAME, checkFrame);
}
if (e.target.currentFrame == 40)
{
// TweenMax.from(leftHand, 2, {x:200});
var myTween:TweenMax = new TweenMax(leftHand, 2, {x:400});
myTween.totalProgress = 1;
myTween.reverse();
}
}
Now, sometime before I entered the second if statement (which I have removed
for testing to no avail), this code was executing flawlessly. Now, however,
it doesn't trigger the ENTER_FRAME event. Now, this code isn't substantially
different than what Nathan Mynarcik so kindly sent me, but now it doesn't
trace. Below is the entire code. I have taken out the startLoad(), which
does trace, but it still doesn't work. Where should I look?
TIA,
beno
package
{
import flash.net.URLRequest;
import flash.display.Loader;
import flash.events.Event;
import flash.events.ProgressEvent;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.display.MovieClip;
import com.greensock.*;
import com.greensock.easing.*;
public class Main extends MovieClip
{
//Import Library Assests
public var head:HatAndFace;
public var leftEye:Eyeball;
public var rightEye:Eyeball;
public var leftHand:Hand;
public var rightHand:Hand;
public var myPic:pic;
public function Main()
{
init();
}
public function init():void
{
hatAndFace();
eyeball1();
eyeball2();
myRightHand();
myLeftHand();
thePic();
startLoad();
}
//Place Head and Hat on stage and fade in
public function hatAndFace():void
{
head = new HatAndFace();
head.x = stage.stageWidth/2;
head.y = stage.stageHeight/4;
head.alpha = 0;
addChild(head);
TweenLite.to(head, 2, {autoAlpha:1});
}
//Place left eye on stage and fade in
public function eyeball1():void
{
leftEye = new Eyeball();
leftEye.x = head.x - 30;
leftEye.y = head.y + 15;
leftEye.alpha = 0;
addChild(leftEye);
TweenLite.to(leftEye, 2, {autoAlpha:1});
}
//Place right eye on stage and fade in
public function eyeball2():void
{
rightEye = new Eyeball();
rightEye.x = head.x + 30;
rightEye.y = head.y + 15;
rightEye.alpha = 0;
addChild(rightEye);
TweenLite.to(rightEye, 2, {autoAlpha:1});
}
//Place right hand on stage and fade in
public function myRightHand():void
{
rightHand = new Hand();
rightHand.x = head.x + 420;
rightHand.y = head.y + 50;
addChild(rightHand);
rightHand.addEventListener(Event.ENTER_FRAME, checkFrame);
}
//Place left hand on stage and fade in
public function myLeftHand():void
{
leftHand = new Hand();
leftHand.x = head.x - 20;
leftHand.y = head.y + 50;
addChild(leftHand);
leftHand.addEventListener(Event.ENTER_FRAME, checkFrame);
TweenMax.from(leftHand, 2, {x:420});
}
//check the hands and stop when they reach the 40 frame
public function checkFrame(e:Event):void
{
if (e.target.currentFrame == 40)
{
e.target.stop();
trace("hand is done tweening");
e.target.removeEventListener(Event.ENTER_FRAME, checkFrame);
}
if (e.target.currentFrame == 40)
{
// TweenMax.from(leftHand, 2, {x:200});
var myTween:TweenMax = new TweenMax(leftHand, 2, {x:400});
myTween.totalProgress = 1;
myTween.reverse();
}
}
public function thePic():void
{
myPic = new pic();
myPic.x = 300;
myPic.y = 350;
addChild(myPic);
TweenMax.to(myPic, 1, {shortRotation:{rotation:60}, x:100,
y:200});
}
function startLoad()
{
var mLoader:Loader = new Loader();
var mRequest:URLRequest = new URLRequest("LightExplosion.swf");
mLoader.contentLoaderInfo.addEventListener(Event.COMPLETE,
onCompleteHandler);
mLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS,
onProgressHandler);
mLoader.load(mRequest);
}
function onCompleteHandler(loadEvent:Event)
{
addChild(loadEvent.currentTarget.content);
}
function onProgressHandler(mProgress:ProgressEvent)
{
var percent:Number = mProgress.bytesLoaded/mProgress.bytesTotal;
trace(percent);
}
}
}
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders