I've created a button in my stage. I've set the instance name to init
and have the MainTimeline
being called from an an external script:
./Project/MyFlash.fla
./Project/MyFlash_fla/MainTimeline.as
I'm a beginner in Flash attempting to create a button and call it inside MainTimeline.as
; the error returned:
ReferenceError: Error #1065: Variable init is not defined.
at tfm::MainTimeline()
I've also tried var init:Button = new Button();
with no luck.
More specifically, I am trying to do this:
function MainTimeline(){
//var init:Button = new Button();
init.addEventListener(MouseEvent.CLICK, begin);
}
function begin(){
addFrameScript(0, frame1);
}
These are my imports (and I've added even useless ones in frustration):
import flash.display.*;
import flash.events.*;
import flash.net.*;
import flash.system.*;
import flash.utils.*;
import flash.text.*;
import flash.xml.*;
import flash.media.*;
import fl.controls.Button;
import flash.*;
import fl.*;
import fl.controls.*;
Any possible solution?
Update:
I'm linking the external script under the stage property, Class
as MyFlash_fla.MainTimeline
I've gotten the 'var not defined' error eliminated by simply adding this.
preceding init.add[...]
. My current error: TypeError: Error #2007: Parameter listener must be non-null
at flash.events::EventDispatcher/addEventListener()
at tfm::MainTimeline()
. Sorry for not being completely clear at first, but I have a button in my stage, and I'm trying to have it execute the function, begin()
whenever clicked. Currently, that error is returned and begin()
is executed without any interaction.
Update II.
I've eliminated the last error by adding event:Event
in begin(event:Event){...
. Everything seems to be running smoothly. I'm left with an error though; it's not affecting anything, but I would still like to rid of it: ReferenceError: Error #1065: Variable init is not defined.
at tfm::MainTimeline/__setProp_init_Scene1_Layer1_0()
at tfm::MainTimeline()
- What is this?
getChildByName
. - ocodo