Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 12-12-2011, 06:53 AM   #1
pokrishka
Registered User
 
Join Date: Aug 2011
Posts: 29
Default Simple button error

Hi everybody,

I had some little experience in AS2 and now I'm trying to code a simple application with AS3. I have several scenes there:
Intro
Video
Question

First 2 scenes are empty for now, on the Question scene I placed stop(); on actions layer and then I created a button symbol, made it's instance name btn_play and put this code into actions layer:

Code:
stop();

btn_play.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
function mouseDownHandler(event:MouseEvent):void {
    play();
}
So when you click on the button it should continue playing. But I get an error and the button doesn't work. Here's an output:

TypeError: Error #1009: Cannot access a property or method of a null object reference.
at flash_fla::MainTimeline/frame3()

Looks like I don't have that instance there yet, but how can that be? Appreciate any help with it.
pokrishka is offline   Reply With Quote
Old 12-12-2011, 07:09 AM   #2
kattehus
Registered User
 
Join Date: Dec 2010
Location: Aarhus, Denmark
Posts: 39
Default

Don't have btn_play in front of your addEventListener.

Edit:
Wait, I may have misunderstood what you wrote..

Is the code you posted in your stage actions layer or in your button?
kattehus is offline   Reply With Quote
Old 12-12-2011, 08:10 AM   #3
Yui
Senior Member
 
Join Date: Jun 2008
Location: Romania
Posts: 162
Default

you need to have that code on frame 3. that should work.
Yui is offline   Reply With Quote
Old 12-12-2011, 08:36 AM   #4
pokrishka
Registered User
 
Join Date: Aug 2011
Posts: 29
Default

I'll try to explain. I have 3 scenes each of them having 1 frame. First two scenes are empty for now, so it passes right onto scene 3 called "Question". There I have 2 layers, a layer with actions and a layer with objects. On the actions layer I have the code I posted. On the objects layer I have an instance of a button called "btn_play". I want to continue playing once I click the button.
pokrishka is offline   Reply With Quote
Old 12-12-2011, 09:08 AM   #5
pokrishka
Registered User
 
Join Date: Aug 2011
Posts: 29
Default

Somehow this works if I use a MovieClip instead of a Button. Well, that's fine with me
pokrishka is offline   Reply With Quote
Old 12-12-2011, 12:16 PM   #6
Yui
Senior Member
 
Join Date: Jun 2008
Location: Romania
Posts: 162
Default

Quote:
Originally Posted by pokrishka View Post
Somehow this works if I use a MovieClip instead of a Button. Well, that's fine with me
It sounds like you deleted the folders required for the button from the library. When you use Flash components - when you drag them on the stage, some folders are imported in the library. Those should stay there.
Yui is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 02:27 AM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.