Copy link to clipboard
Copied
Hi I have the tween objects imported, but I am getting an error which I am unsure of here is my code I have written so far...
// Game Tweening Import Statements
import fl.transitions.Tween;
import fl.transitions.easing.*;
import fl.transitions.TweenEvent;
function createEnemy(event:TimerEvent):void
{
var enemyAppear = new MovieClip;
enemyAppear = new Enemy();
enemyAppear.x = 50;
enemyAppear.y = 200;
enemyStorage.addChild(enemyAppear);
var mc_Duck:Tween = new Tween(enemy, "x", Strong.easeOut, 0, 250, 3, true);
}
So I want the object to move from the left but I am getting an error where the debugger cant read some code. Well i mean in the output of the compiler.
UnloadSWF] C:\Users\Casey\Desktop\Sliding Duck Shooter\SlidingDuckShooter.swf\[[DYNAMIC]]\1
ReferenceError: Error #1056: Cannot create property x on Number.
at fl.transitions::Tween/setPosition()
at fl.transitions::Tween/set position()
at fl.transitions::Tween()
at SlidingDuckShooter_fla::MainTimeline/createEnemy()[SlidingDuckShooter_fla.MainTimeline::frame2:53]
at flash.utils::Timer/_timerDispatch()
at flash.utils::Timer/tick()
Cannot display source code at this location.
The game pretty much freezes/locks-up after clicking the button to start game.
Copy link to clipboard
Copied
What is "enemy" in your Tween? It is not enemyAppear if that is the intention. You do not need to declare enemyAppear as a MovieClip if you are instantiating it as some other class...
function createEnemy(event:TimerEvent):void
{
var enemyAppear:Enemy = new Enemy();
enemyAppear.x = 50;
enemyAppear.y = 200;
enemyStorage.addChild(enemyAppear);
var mc_Duck:Tween = new Tween(enemy, "x", Strong.easeOut, 0, 250, 3, true);
}
Copy link to clipboard
Copied
enemyAppear is linked to another function I didnt link the full code here is the other part.
Not sure but it seems to be linked to my mc_Duck because its spawning it to the stage, just not Tweening the object.
//Removes Enemy From Stage and adds point to score
//Determines game won by reaching the assigned point value
stage.addEventListener(MouseEvent.CLICK, clickEnemy);
function clickEnemy(event:MouseEvent):void
{
if(cursor.hitTestObject(enemyAppear))
{
enemyAppear.parent.removeChild(enemyAppear);
stage.removeEventListener(MouseEvent.CLICK, clickEnemy);
score++
messageDisplay.text = String(score);
if(score == 1)
{
enemyTimer.stop();
var winText:WinMessage = new WinMessage();
winText.x = 0;
winText.y = 0;
parent.addChild(winText);
Mouse.show();
}
}
}
The enemy in my Tween is a duck, which i named mc_Duck (movieclip_Duck) and the instance name for the object is enemy.
var mc_Duck:Tween = new Tween(enemy, "x", Strong.easeOut, 0, 250, 3, true);
^For above code mc_Duck = name, enemy = instance
Copy link to clipboard
Copied
Just for the sake of avoiding confusion in your postings, you should not bother mentioning the library names of objects. Library names are irrelevant to anything else other than giving you some means of knowing what's what in the library.
If mc_Duck is being used for anything else in the file, I suggest you do not use it again to name the Tween variable.
What you should do is try tracing the enemy before the tween line to see what it is coming up as. According to the error, if that's the line causing the error, it is seeing a Number object, not a MovieClip.
trace(enemy);
var mc_Duck:Tween = new Tween(enemy, "x", Strong.easeOut, 0, 250, 3, true);
Copy link to clipboard
Copied
ohh ok
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more