Answer the question
In order to leave comments, you need to log in
How can I access an instance drawn in Flash from ActionScript 3.0 in a document class?
Hello.
I can't do it in my main project. The project starts with a splash animation and stops at frame 178. Buttons are drawn in this frame in Flash. They didn't show up before. I did not complete the execution of the document class constructor. Now I organized the code in such a way that the buttons began to appear, but they do not work. There is a runtime error. The button instance at the time it is accessed is null. The event listener and handler are written in the document class. If their code is written in the frame where playback stops, then it works, but I want to understand how to do it in the main class. Why does not it work? I even made a small project on purpose to practice on it. Basically, it should be clear.
For example, I use the following document class:
package
{
import flash.display.MovieClip;
import flash.events.Event;
import flash.events.MouseEvent;
public class ObjectExample extends MovieClip
{
public function ObjectExample()
{
addEventListener(Event.ADDED_TO_STAGE, addedResponse);
}
private function addedResponse(e:Event)
{
removeEventListener(Event.ADDED_TO_STAGE, addedResponse);
box.addEventListener(MouseEvent.CLICK, clickResponse);
}
private function clickResponse(e:Event)
{
trace("Нажато");
}
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question