1
votes

I'm getting this error when I press a button in a flash/air app that used to work in the AIR 3.2 SDK - now upgraded to the AIR 3.5 SDK. Any help much appreciated.

TypeError: Error #1009: Cannot access a property or method of a null object reference.
    at seed_template_fla::MainTimeline/frame7()[seed_template_fla.MainTimeline::frame7:31]
    at flash.display::MovieClip/gotoAndPlay()
    at seed_template_fla::MainTimeline/gotoPage()    [seed_template_fla.MainTimeline::frame1:20]
    at seed_template_fla::MainTimeline/gotoRepro()    [seed_template_fla.MainTimeline::frame1:12]

I'm creating an app for iPhone using Flash CS6 on Mac and exporting using the Air 3.5 SDK. I also have the AIR 3.5 runtime installed.

The app is very simple at the moment. It basically moves from frame to frame when you press a button using the gotoAndPlay(frameNr) function. There are some hexes on the frames that update an array of numbers when clicked. They are also toggled visible/not visible.

This used to work perfectly using the AIR 3.2 SDK, but I recently downloaded the AIR 3.5 SDK from adobe and added it through flash (Help>Manage Air SDK) and set it as the build target in File>Publish Settings>Target.

When I switch back to AIR 3.2 SDK, the app works perfectly again.

Also, when I upload the app to my iPhone 4S running IOS 5.1 using AIR 3.5 SDK, I just see a black screen with 5 loading dots flashing. This also works fine with AIR 3.2 SDK.

This is the code for frame 7 The last line is line 31.

stop();
techtitle.text = "Select Trait";
techdesc.text = "Spend points to change core stats and other special abilities";
points.visible = false;
techpoints.visible=false;
pointsbalance.text = myPoints.toString();
btn_tech.visible = false;
curTechSelected = null;

trace("set hexes invisible");
for (var j:int = 0; j <= 67; j++) {
    if (hexStatusb[j] == 1) {
        this["btn_hex_"+j+"b"].visible = false;
    }
}

function onBtnHex37bClick(event:MouseEvent):void
{
    techtitle.text = "tech1";
    techdesc.text = "tech1 description"
    techpoints.text = "-2";
points.visible = true;
techpoints.visible=true;
btn_tech.visible = true;
curTechSelected = btn_hex_37b;
curTechSelectedNr = 37;
curTechPoints = 2;
}

trace(this["btn_hex_37b"]);
btn_hex_37b.addEventListener(MouseEvent.CLICK, onBtnHex37bClick);
4

4 Answers

1
votes

OK - so, after trying out lots of things, I figured out why this is happening.

Solution: get rid of all TFL text objects when running AIR 3.5 SDK

It seems that the TFL Text library wasn't being loaded properly at runtime. Something crucial that I neglected to mention was that I was getting this warning message (similar here http://forums.adobe.com/thread/825637) Content will not stream... The runtime shared libraries being preloaded are textLayout_1.0.0.05... TFLText

and this warning message in the output

Warning: Ignoring 'secure' attribute in policy file from http://fpdownload.adobe.com/pub/swz/crossdomain.xml. The 'secure' attribute is only permitted in HTTPS and socket policy files.

Simply removing all TFLText objects and changing them to classic text makes the app work fine again.

1
votes

@csomakk Great news. I have found the answer. You can publish in 3.5 and 3.6 and have your TLF Text too. I posted a write-up on my blog that shows exactly how to do it.

0
votes

To get started: the error message states that something is null.. it means, that the program doesn't know, where to look for it. It can happen, when you didn't create the object (btn_hex_37b = new MovieClip()); or you haven't even created a variable for it.

on the given line (btn_hex_37b.addEventListener(MouseEvent.CLICK, onBtnHex37bClick);) only btn_hex_37b can be null, because onBtnHex37bClick exists, and if it wouldn't, the program wouldn't compile.

The reason it came up when switching to AIR 3.5 is probably that it calls some creation functions in different order. Go to the line where you define the btn_hex_37b variable. Search for that functions calling.. Make sure, that btn_hex_37b is created before going to frame7.

Also, if its not a vital, to have onBtn_hex_37bClick, you can do the following:

if(btn_hex_37b){
    btn_hex_37b.addEventListener(MouseEvent.CLICK, onBtnHex37bClick);
}

the if will check if btn_hex_37b is not null. On the else method, you can give a timeouted method(but that is ugly), or give the eventlistener right after the creation of the object.

Hope this helped.

0
votes

For Flash CS6, copy this swc: /Applications/Adobe Flash CS6/Common/Configuration/ActionScript 3.0/libs/flash.swc

Into my Flash Builder project using these steps: http://interactivesection.files.wordpress.com/2009/06/include_fl_packages_in_flex_builder-1.jpg

and then use this link http://curtismorley.com/2013/03/05/app-used-to-work-with-air-3-2-or-3-4-doesnt-work-with-air-3-5-or-3-6/#comment-241102