Copy link to clipboard
Copied
Hello, I have question and asking for help.
My script:
function A(){
// doooo somthing...
stage.addEventListener(Event.ENTER_FRAME, B);;
function B(event: Event): void {
// do something
}
}
function C(){
stage.addEventListener(Event.ENTER _ FRAME, B);
}
ERROR: 1120: Access of undefined property B.
Copy link to clipboard
Copied
Hi.
The easiest way for you will be to define the function B outside function A.
Is it possible?
Regards,
JC
Copy link to clipboard
Copied
Its posible but then I have to define others 9 functions and do changes in theese... But I want to call for that EventListener and thats all job done. I want to know how I can do that
Copy link to clipboard
Copied
I want to have one function ant that funcion does almost most job, And others just helping in some situations. Thats why I have functions inside function and now im in situation what I dont want same functions copy paste for doing the same job.
Copy link to clipboard
Copied
What kind of interactivity do you want to achieve?
Because I can hardly think of a situation that would require so much duplicate code.
Copy link to clipboard
Copied
Event listeners add some keyboard functions, and its goes like this
when ends something do something
when again do something
add some movie clips
and add event listener if some of them exists, if not add event listener for keyboard, if exists add event listenerss ENTER FRAME
when call some functions
and again when function ends add veent listener.
I just want to call ONE function from outside thats all I want
Copy link to clipboard
Copied
I don't know if I understand it, but apparently the "C" function must execute the "B" function, so for that, you could create one more function, maybe it will solve:
// Test Example:
function A() {
trace("A");
// doooo somthing...
function D() {
trace("D - doooo somthing...");
stage.addEventListener(Event.ENTER_FRAME, B);
function B(event: Event): void {
trace("do something");
}
}
D();
}
function C() {
trace("C");
A();
}
C();
Copy link to clipboard
Copied
In this case How I can call function B ?
if I call B();
1180: Call to a possibly undefined method B.
Copy link to clipboard
Copied
function A(){
//do something
}
function B(){
//do something
}
function C(){
//do something
}
function D(){
//do something
}
In this case I can call A(), B(), C(), D() then ever I want and it works.
function A(){
//do something
function B(){
//do something
}
}
function C(){
//do something
}
function D(){
//do something
}
In this case dunction B is inside the function A. So if I call B();
1180: Call to a possibly undefined method B.