TypeError: Error #1034 could not solve this very strage - actionscript-3

i've been making a presentation in flash CS5. It has 5 Pages there for 5 Keyframes which are on the main timeline. I have 2 animated navigation buttons (Movieclips) for left and right. Now the all navigations are instances from the Arrow Left MC or Arrow Right MC and both work absolutly perfect except the Arrow left on the last page.
Now I know this is strange but it has the same piece of code, it is the same instance with a unique name and both (the movieclip and the code) are on a keyframe.
I like spend nearly a week to solve this, tryed every solution I could find elsewhere but I still couldn't solve it. I'm really jumping in triangles right now.
This is the error message(I use the german version so I translated it):
TypeError: Error #1034: Typecast failed: flash.display::MovieClip#3e817d91 can not be converted to fl.motion.AnimatorFactory.
at flash.display::MovieClip/gotoAndPlay()
at Presenting_v9_noFS_fla::MainTimeline/leClick_p5()
And this is the piece of code:
//Button FX previous ----------------------------------------------------##
INS_Previous_MC_p5.addEventListener(MouseEvent.ROLL_OVER, leOver_p5);
INS_Previous_MC_p5.addEventListener(MouseEvent.ROLL_OUT, leOut_p5);
INS_Previous_MC_p5.addEventListener(MouseEvent.CLICK, leClick_p5);
function leOver_p5(event:MouseEvent):void
{ INS_Previous_MC_p5.gotoAndPlay("PreviousOver"); }
function leOut_p5(event:MouseEvent):void
{ INS_Previous_MC_p5.gotoAndPlay("PreviousOut"); }
function leClick_p5(event:MouseEvent):void{
gotoAndPlay(129);
}
//Button FX previous end-------------------------------------------------##
As you can see the roll_over and roll_out events trigger the animation in the Instance and the click event just jumps to a frame in the main timeline. The exact same setup like on the other 4 pages, really. This is action script 3.0, and I'm kinda beat counting the fir needles on a christmas tree in august for the 5th time over.
Any help that is greatly appreciated.
Bishop

well I did exactly that last night and it was the motion tween which was triggering the error at frame 129. I found that out by clearing the tweens one by one with blank frames and it worked. I've checked for code errors and there were none and every tween as well as every name in the library was unique.
Today I've double check the Instance names and all were unique but for some reason now it works. I guess it needed an update on the names or something like that?
Anyway I like to thank you www0z0k for your time, effort and the post. It kept me motivated.

Related

TypeError 1009, began appearing randomly after adding new button code

SOLVED: It was a two stop functions. Two. Stop. Functions. AS3 can be so annoying sometimes.
I am making a space invaders style game for a school assignment. I was adding in a button to go between frames and I deleted an unnecessary layer that contained a single sprite in my game, which I added back onto the main code layer. Then after attempting to restart my game to check the button, I began receiving a TypeError Code 1009. It is stating that there is an error with MainTimeline/moveBullet() and, MainTimeline/eFrame(). These sections of the code were not altered whatsoever during the creation of the button or movement of the sprite, however, as the bullet is linked to the moving sprite I think the error may be there. I'll put the code below, if anyone knows how to fix this specifically or has a general idea of how to do so please let me know. This is due in a few hours and would greatly appreciate a quick fix. Thanks.
Re-named sprites, re-typed code sections returning errors again. Most fixes appear to be in instance names, corrected them and no fix.
this.addEventListener(Event.ENTER_FRAME, eFrame)
function eFrame(e: Event) {
controls();
restrain();
moveBullet();
enemyHit();
barrierHit();
function moveBullet() {
if (bull.visible == true) {
bull.y -= bulletspeed;
if (bull.y < 0) {
bull.visible = false;
}
}
}
The game had been running fine until this point. The character would move along bottom and shoot up at "bad guys". Bullets were removing bad guys. Now I get the usual super fast run through frames repeatedly. NO Compiler Errors, just output, being
TypeError: Error #1009
"I deleted an unnecessary layer that contained a single sprite in my game, which I added back onto the main code layer. Then after attempting to restart my game to check the button, I began receiving a TypeError Code 1009."
Possible solutions:
(1)
Did you also give the Sprite an instance name? I suspect the name bull is what's expected.
(2)
Eliminate that the problem is in moveBullet(). Disable the call and if the error still exists, then the problem must be between variables bull and bulletspeed.
Comment the call movebullet() in function eFrame:
function eFrame(e: Event)
{
//moveBullet();
....

Adobe Animate Actionscript 3.0 "clicktogotonextscene" code not working

So I have the following code for a button called "n2" and as you can see it's supposed to take me to the next scene when I click it, but it isn't working. It is inside Scene 2 and I'm trying to get to the next one and whenever I test the scene and click it, I don't even get an error, it just doesn't work.
Btw, it's a GIF defined as a movie clip and then as a button. Could that be causing the problem?
n2.addEventListener(MouseEvent.CLICK, fl_ClickToGoToNextScene);
function fl_ClickToGoToNextScene(event:MouseEvent):void
{
MovieClip(this.root).nextScene();
}
If you put a trace in the function and comment out "MovieClip(this.root).nextScene();" you could then see if the function gets called on a button click.
I've not used animate before, but in flash you have to name your button/movieclip and then also name the instance. This allows you to create the object twice with two seperate names to be referred to by actionscript.
Not sure if this helps but thought I'd give you some things to try, good luck

Flash Pro: Collision of objects only works correctly when on Frame 1

as you may have noticed just by reading the title it is quite hard to summarize the problem,
which is probably why I couldn't find a solution anywhere.
I am currently working on a flash game using adobe flash pro CC.
I started by creating the first level of my sidescrolling game and got everything to work just as I wanted it to. All my work was on a single frame (frame 1) and on a single layer and it worked fine.
However, when I then went on to move the frame a little further back and added frames in front of it for the menu I encountered a problem.
When I "gotoAndStop" to the frame with my game content on it, everything works except the collision between my character and my objects. My character is now sunk into the "floor object" about have his size, while when i move the frame back to "frame 1" everything works fine again.
I am losing my mind over this. Please help me :(
in flash when you start changing a dynamic property such as x or y, that object will be independent from the keyframe where it originally was ~forever~, even if you go back to the original keyframe. therefore if you start some enterframe and change the playhead afterwards you will get some awkward (but expected) behaviour.
ideally, jump to the game keyframe and just then call whatever methods needed to start the game.

How do I create a simple on-mouse-click rotating object in flash

This question may get downvoted or go unanswered because it's not the greatest and incredible silly but anyway,
I'm taking an intro level Webanimation course this semester at UNI and had I know what their expectations are for our hand-in projects i would have never taken it up.
Basically the teacher taught us stuff to the extent of masking/tweening and very few mouse-event and basic function codes.
Now she is expecting us to make a god damn ENTIRE PIPE GAME. The one where there are a bunch of rotating pipes and you gotta rotate them in place before a timer runs out and then the water flows through them.
For this project I have to somehow figure out the following (even though she didn't teach any of this):
-creature a grid of rotate-able pipes (one mouse click I assume would do a 90 degree classic tween rotation of the object)
-creature some sort of logic hit-box value chain to make pipes decide when to fill with water (they fill with water (a.k.a turn blue inside as an animation) once they are connected to another water filled pipe, for example)
-creature multiple levels and a menu screen
-add a music track.
Now i know this site is for specific help only and you basically can't ask for help on an entire project, so for now if somebody could just help me out with the following:
How do I create a rotating pipe on mouseclick?
So I have my pipe movieclip created and I have my Mouse Event code ready but I don't have the faintest on how to make a tween within the pipe and connect it to the code so that it rotates on mouseclick.
So this far, let's say for one of the pipes, instance pipe_1, I want to do this:
pipe_1.addEventListener(MouseEvent.CLICK, fl_MouseClickHandler);
function fl_MouseClickHandler(event:MouseEvent):void
{
trace("Mouse clicked");
}
I also have the simple tween of rotation already created within the instance of the pipe, but dunno how to connect it to code.
I'm supposed to figure out what to put inside the function but I honestly have no clue. Hours of googling have come up with nothing either except a 12 dollar purchasable source code for an even more complicated pipe game.
I hope somebody can at least help a bit, and thanks.
The way to rotate a clip is via it's rotation property. It defaults to 0.
If you were set the rotation property of your tile to 90, you'd rotate your pipe tile 90 degrees.
for example :
pipe_1.rotation += 90;
A tween is a means of changing a property of a given DisplayObject over time. So what you want to do is tween your rotation property 90 degrees over time.
Here is a tutorial on Tweening - http://www.republicofcode.com/tutorials/flash/as3tweenclass/
I think it'd be more beneficial for you to take the time to learn about it, than to have me just write a few lines of code to solve your problem.
StackOverflow is a place where you can ask a question, AFTER you have tried something and have hit an issue.
I have provided you with the basic concept of what you need to do, and if you take the time to learn about tweening, you'll be able to achieve your goal rather simply.
There are also tweening libraries such as TweenLite and TweenMax that simplify tweening. Not sure if your class will allow you to use them, but worthwhile to check out for your own benefit.
You can find TweenLite here :
http://www.greensock.com/tweenlite/
Are you talking about a frame by frame tween? or tweening with code?
for frame by frame tweening, you can try to do this:
pipe_1.addEventListener(MouseEvent.CLICK, f1_MouseClickHandler);
function f1_MouseClickHandler(e:MouseEvent) {
pipe_1.gotoAndPlay(2); //if the tween starts at frame 2
}
For code tweening, just call the tween function inside that handler function

actionscript 3: calling function for second time wont work

I'm new to actionscript 3, I have sequences of frames and two buttons to control which sequence to play, it first works properly, but have problem when a sequence is being played for the second time. I have used gotoAndPlay function for my navigation. can anyone help me?
From your description I have a hunch about what may be happening...
Firstly I would ask you if the buttons are present at all frames along the timeline? If they are not (ie, sometimes the timeline shows a frame where the buttons are not present before returning to them ) you should realise that when they come back into view again, they are not the same buttons as the ones from before. That means that the event listeners you attached the first time are not going to respond to clicks on these new buttons.
This happens because flash always totally recreates timeline objects when they come into view again. Flash can sometimes cope with a "jump" over a "gap" when a symbol is the same, but this is extremely unreliable and should be avoided for this reason.
You can avoid this problem by keeping the ui on the stage at all times, and revealing and hiding the buttons when you need them. Even better, create an instance of your ui in code and add it to the stage when you need it. This way you know there is only one instance, and you are in control of it.