views:

177

answers:

1

My apologies if this has been fully addressed before, but I've read through several other threads and still can't seem to get my file to work.

My actionscript code is at the bottom of this message. I created it using instructions from the Adobe website: http://help.adobe.com/en_US/ActionScript/3.0_ProgrammingAS3/WS5b3ccc516d4fbf351e63e3d118a9b90204-7fd7.html

I believe I have all of my objects set to the correct type of symbol (button) and all of my instances are named appropriately (see screenshot here: www.footprintsfamilyphoto.com/wp-content/themes/Footprints/images/flash_buttonissue.jpg)

Action Script here. Let me know if you have suggestions! (Note: I am very new to Flash):

stop ();


function babieschildren(event:MouseEvent):void 
{ 
    trace("babies children method was called!!!");
    var targetURL:URLRequest = new URLRequest("http://www.footprintsfamilyphoto.com/portfolio/babies-children"); 
    navigateToURL(targetURL, "_self"); 
}

bc_btn1.addEventListener(MouseEvent.CLICK, babieschildren);
bc_btn2.addEventListener(MouseEvent.CLICK, babieschildren);


function families(event:MouseEvent):void 
{ 
    trace("families method was called!!!");
    var targetURL:URLRequest = new URLRequest("http://www.footprintsfamilyphoto.com/portfolio/families"); 
    navigateToURL(targetURL, "_self"); 
}

f_btn1.addEventListener(MouseEvent.CLICK, families);
f_btn2.addEventListener(MouseEvent.CLICK, families);


function couplesweddings(event:MouseEvent):void 
{ 
    trace("couples weddings method was called!!!");
    var targetURL:URLRequest = new URLRequest("http://www.footprintsfamilyphoto.com/portfolio/couples-weddings"); 
    navigateToURL(targetURL, "_self"); 
}

cw_btn1.addEventListener(MouseEvent.CLICK, couplesweddings);
cw_btn2.addEventListener(MouseEvent.CLICK, couplesweddings);

Additional description of Flash file - file is an approx 5 second animation that should stop on the last frame. The last frame contains 6 buttons which should route the user to 3 different pages of the website. Refer to screenshot image link above.


Alright, I tried a couple more things, I changed the "families" function to "fams" since for some reason it was telling me that it was a duplicate function. That resolved the looping issue (the file was looping instead of stopping on the frame where these buttons are located, and I was receiving compilation errors about the families function - "duplicate function definition" and "incompatible override" - I'm fairly confident it's not a duplicate function, as this is the only action script that I have in this entire file...).

Now it stops on the right frame, the compilation errors appear to be resolved, but I don't see the trace statements in the output box when I click on the buttons. I do get an initial error in the output box when I test the movie, it reads:

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

Can anyone let me know what that means?

i've checked and rechecked all the button names (and instance names), they're all there, right in the same frame as the action script (frame 133), so that shouldn't be causing the 1009.

Also just removed each function and addEventListener set one by one and tested the movie, but the 1009 error persisted in all 3 cases. I do not get the 1009 error if I delete all of the code other than "stop ();" and test the movie.


Note: I've opened a new, more specific question regarding the 1009 error here: stackoverflow.com/questions/2948119/flash-buttons-dont-work-typeerror-error-1009-cannot-access-a-property-or-met

+1  A: 

You code looks fine. Add trace statements in the methods to make sure they're indeed called. Also check for any pop-up blockers; when you call navigateToURL without the second parameter, Flash will try to create a new window to open the URL in. Unfortunately for us developers, (and fortunately for users), most of the pop-up blockers will prevent this from happening. Add the second parameter to your calls and see if it works.

navigateToURL(targetURL, "_self"); 

Note that this will cause the new URL to be loaded in the current window/tab, effectively replacing the page that has your SWF

Amarghosh
Thanks for your response - I updated the targetURL with the "_self" parameter.However, my buttons still aren't fundamentally working. With the code above, my test movie fails to stop on the last frame and just continues to loop. I also get error messages saying that the "families" function is a duplicate function (it's not, is it? i haven't used any other a.s. in this file). If I remove everything except the "stop ();" line, my test movie DOES stop on the last frame, and my cursor indicates that the appropriate objects are buttons. but, of course, they don't do anything. Any thoughts?
goldenfeelings
Also - I don't know what you mean by "Add trace statements in the methods to make sure they're indeed called." Could you explain in more detail? (Again, I'm really new to this.)
goldenfeelings
@golden I think the problem is the position of code - you'll have to move the code to first frame or something.
Amarghosh
@golden add `trace("babies children method was called!!!");` as the first line of the `babieschildren` method and so on. Now check the output panel of the CS4 to see if anything is printed when you click on the buttons.
Amarghosh
Thanks for your clarification and suggestions. I moved all of the code underneath the "stop ();" line to the first frame in the actions layer (is that what you meant?), but still the same result - the test movie loops rather than stopping on the last frame, and I'm getting the same error messages regarding my "button" code ("incompatible override" and "duplicate function definition", referring to the "families" function).
goldenfeelings
Attempted a few more things - added info to the initial question post, let me know if that sheds any light on what the issue might be.
goldenfeelings