Kyle93
Kyle93

Reputation: 795

Action script between multiple frames

This probably is a very easy thing to do, however I can't seem to get it to work.

I have my main Actionscript on a frame set that controls how my "game" works. Inside of a movieclip I want to have some more code here. I need to call a function that I use in my main set of action script.

Basically, I have some actionscript on a frame, I have some more actionscript on another frame. I want to call a method in the first frame from the second one.

Main Code

function isAnimating(bool:Boolean):void{
     currentlyAnimating = bool;
}

Other frame code

isAnimating(true);

Error

Symbol 'playerDownBlock', Layer 'Layer 2', Frame 1, Line 2 1180: Call to a possibly undefined method isAnimating.

I've also tried using "this" however I then get this error.

TypeError: Error #1006: thisisAnimating is not a function.

Upvotes: 0

Views: 1022

Answers (2)

Bennett Keller
Bennett Keller

Reputation: 1714

"Have you tried MovieClip(parent).isAnimating(true); ? Assuming that the MovieClip(parent) is the object containing the isAnimating method. If it is not it will require a different layer or reference in the display list."

As stated in the comments: MovieClip(root).isAnimating(true); has your solution.

Upvotes: 1

DigiWongaDude
DigiWongaDude

Reputation: 163

I really don't envy your learning curve right now, but I sincerely hope you crack on with it. I promise you it will all become more transparent. Every one of us who got into ActionScript has found themselves doing what you are doing and often getting nowhere fast.

I replicated your error EXACTLY, so I see what you were doing. I'm sure the comment from P1on worked for you - it did work here. If it did work, give him a +1 ;-)

Right now I'm guessing you don't really know what the Display List is or how it works, let alone the differences between DisplayObjects such as MovieClips, Shapes, Sprites, Objects and instances that appear on either the Stage or the MainTimeline (yes, the Stage and MainTimeline are separate).

I could teach you in a few hours what took me (and would you) months to figure out - especially if you are intent on making games. ActionScript is not really for prodding around with blindly - you need to learn it first! As soon as you do a course on AS3, you'll never have more than one frame on your main timeline. You'll load up your clips from the library, and you'll traverse the Display List tree like a monkey! You certainly won't mess around with ActionScript code across multiple frames.

It's time to put your game down for a little while and find a FREE online course. One of the best I found was this one by Todd Perkins on Lynda.com: http://www.lynda.com/ActionScript-3-tutorials/projects-game-development/366-2.html check it out, and dig around for a 7 day trial FREE (or something else). Within no time you'll be flying, instead of pulling your hair out. Best of luck.

Upvotes: 0

Related Questions