Recently I started working with adobe flash pro, what is the essence of the problem: the fact is that I made a small banner with blocks of goods, each block has its own button with an assigned link, and blocks of goods changed when moving to the next frame (something like slider ), respectively, links also changed.

It would seem that on the first frame everything works well, but if you make links for the second frame, the compiler knocks me the following error:

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

I hope for your help, I have been struggling for a whole hour with a problem, but to the point of 0.

Here is the code:

 // Первый кадр function fl_ClickToGoToWebPage(event:MouseEvent):void { navigateToURL(new URLRequest("http://site"), "_blank"); } btnlink.addEventListener(MouseEvent.CLICK, fl_ClickToGoToWebPage); function fl_ClickToGoToWebPage_1(event:MouseEvent):void { navigateToURL(new URLRequest("http://site"), "_blank"); } btnlink1.addEventListener(MouseEvent.CLICK, fl_ClickToGoToWebPage_1); function fl_ClickToGoToWebPage_2(event:MouseEvent):void { navigateToURL(new URLRequest("http://site"), "_blank"); } btnlink2.addEventListener(MouseEvent.CLICK, fl_ClickToGoToWebPage_2); // Второй кадр function fl_ClickToGoToWebPage_3(event:MouseEvent):void { navigateToURL(new URLRequest("http://site"), "_blank"); } btnlink3.addEventListener(MouseEvent.CLICK, fl_ClickToGoToWebPage_3); function fl_ClickToGoToWebPage_4(event:MouseEvent):void { navigateToURL(new URLRequest("http://site"), "_blank"); } btnlink4.addEventListener(MouseEvent.CLICK, fl_ClickToGoToWebPage_4); function fl_ClickToGoToWebPage_5(event:MouseEvent):void { navigateToURL(new URLRequest("http://site"), "_blank"); } btnlink5.addEventListener(MouseEvent.CLICK, fl_ClickToGoToWebPage_5); 

Clearly clumsily made. )

    1 answer 1

    The most valuable thing I realized when working with ActionScript and Adobe Flash is to never use the main timeline for navigation, if you don’t know 100% how it works with variables.

    I do not see a problem in your code, but, as I understand it, this is not all the code that is used (at least, where is the code responsible for the transition between frames? Or how do they change?). When moving from one keyframe to another, all variables declared in one frame are no longer visible in another, which is why, most likely, a null link appears.

    If you want to not have many problems, use the MovieClip container, navigate through the key frames in it and start the application from the document class, where you store the necessary information.

    • Thanks for the advice, perhaps you should look in the adobe directory) - andir
    • Thanks for the tip, it really works) - andir