A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: [RESOLVED] Two Exact Functions Are Not Working (long)

  1. #1

    resolved [RESOLVED] Two Exact Functions Are Not Working (long)

    I am making a portfolio website. The way I have structured my code is that I have an action layer that takes care of global actions such as how the user would navigate through the website. For each page of the website, I would have a seperate layer that would load the content of that page onto the screen. The content would be added as a movie clip which is attached to a scroll pane component.

    I am having trouble calling one of my functions. What I am trying to do is that when the user navigates to 'My Work' section of my website, they can select from one of the examples of my works. Doing so will pop-up a movie clip which will display photographs and provide an explanation for my work. The problem I am trying to fix is that when the user tries to navigate to another page on my portfolio, the pop-up will not remove itself. I have created a function which is attached to the close button so if the user presses it, they can manually close the pop-up movie clip. I have also tried using this closing function with the main navigation buttons of my website so that when the user tries to go to another secion of the website with the pop-up open, the pop-up will automatically close itself, however, it is not constantly working. My 'works' page is seperated into several catagories (web, graphics...). This auto close function is only working on one of the five catagories and I do not understand why. I have copied everything exactly for one catagory to the second catagory, but Flash keeps on giving me the error that "Error #1009: Cannot access a property or method of a null object reference".

    My flash files can be downloaded here. Once downloaded, you would want to open up website14.fla. I know my coding is not exactly organized, and I am sorry as this is my first time I have really used a lot of ActionScript at once. I'll try my best to walk you guys through my coding to my error.

    To navigate through my website, you would click on the sink, toilet, or shower handles X amount of times. 1 time would bring you to 'about me', 2 for 'resume', 3 for 'contact', and 4 for 'work'. Once on the work page (press 4 times), click on the 'web' catagory and select one of the thumbnails. A pop-up window will appear. Don't close the pop-up window, and instead navigate to another page by pressing one of the handes a few times. Notice that the pop-up window automatically closes itself. Now navigate back to the 'work' page, click on the 'graphics' catagory and select a thumbnail. Now navigate to another page by pressing the handles a few times. Notice how Flash produces the error 'Error #1009: Cannot access a property or method of a null object reference'. In addition, notice how the pop-up window doesn't dissapear, and the new page is layed overtop.

    To navigate in the Flash file to my error, I'll try to guide you there. In the root timeline, scroll over to Frame 1 Layer 'Action' and look at the actions panel. On line 72, I have two If statements checking for frames 30 and 31. These two frames are where my work is displayed. I have also used a try/catch statement to check for errors. Now going to frames 30 and 31 and clicking on the workContent layer and looking into the actions panel, I am bringing my movie clip onto the stage by using the function createScrollPane. The function createScrollPane is located in frame 1 in the Action layer on line 13. This function just takes the movie clip and wraps the scroll pane component around it. Going to frame 31 on the main timeline, select the workContent layer and pull up the actions panel to see the code. you will see that I am loading workGraphics_content movie clip onto the page. Find it in the library (content/content/workGraphics_content) and open it by double clicking on it. There you will see another movie clip (workGraphics_content2) fading from alpha0 to alpha1. Double click on it and look at the action script in frame one layer 'action'. On line 93, I have the function external_workFrame_exit which is called whenever the user navigates from the 'work' page to another page on the website. For some reason, Flash keeps on giving me an error whenever that function is called. Oddly enough if you scroll up to line 78 you will see the function workFrame_exit which is none the less exactly the same as external_workFrame_exit. workFrame_exit is called when the user manually clicks the closing X button on the pop-up window to close it. If you want, you can open up another movie clip (content/content/workWeb_content) and double click on that movie clip to open up workWeb_content2 and take a look at its action. Looking on line 86, I have the external_workFrame_exit function and this one is the exact same one as the external_workFrame_exit function (which works fine) found in workGraphics_content2.

    What I am confused about is how I have two exact functions being called in pretty much exact same situations in the exact same way, and one of them fails to work. Is there a solution to my problem? Feel free to ask any questions if any of my explanations were difficult to follow.

    Again, the flash files can be downloaded here. Once downloaded, you would want to open up website14.fla.
    ~~~~~jOn waZ hErE~~~~~

  2. #2
    Sorry about the long post. I just thought that I would include all the details. To sum things up:

    You navigate through my website by clicking the sink, toilet, and shower handle X amount of times. By clicking it 4 times you will end up on my 'work' page. My 'work' page has several categories. Select the 'graphics' category, click on one of the thumb nails and a pop-up will appear. Now navigate to another page without closing the pop-up by clicking on the handles. Notice how the pop-up doesn't go away, and the new content is displayed over top? Now if you go back to my 'works' page and click on one of the thumb nails under the 'web' category, then navigate to another page, notice how this pop-up goes away.

    I am using the exact same functions to make both the 'graphics' category and the 'web' category to go away, but for some reason the 'graphics' one is not working.

    Again, you can download my files from here.
    ~~~~~jOn waZ hErE~~~~~

  3. #3
    lemon juice hurts your eyes florianvanthuyn's Avatar
    Join Date
    Jul 2005
    Location
    Merelbeke, Belgium
    Posts
    546
    I haven't looked at your file since I'm going to bed in a few minutes, but I wanted to give you a way you could handle this.

    Basically, you will have to make a variable which stores the pop-up (if there is one) and later use that to remove it if it exists:
    PHP Code:
    // so declare this somewhere you can access it from everywhere inside of your
    // work page
    var pop:MovieClip;

    // when a pop up is placed on the stage use the variable to create a reference
    pop aPopUpName;

    // then when switching page, check the variable
    // if it exists (read: is referencing to some MovieClip)
    if(popsomeParent.removeChild(pop); // remove it from somewhere
    pop null// clear the variable 
    I'm not sure you can build this into your project as I don't know how it looks like, but if this doesn't seem to help you I'll open up your file
    Florian Vanthuyne

    WAR AGAINST SOLVED THREADS
    mark yours as Resolved under Thread Tools!

  4. #4
    I just want to say that the problem has been solved. The problem was on frame 31, layer workContent. I have the code:

    Code:
    createScrollPane(workGraphics_content, 100, 427, 349, 193);
    whereas it should have read

    Code:
    createScrollPane(workGraphics_content3, 100, 427, 349, 193);
    ~~~~~jOn waZ hErE~~~~~

  5. #5
    Born Again Flasher
    Join Date
    Sep 2000
    Location
    Oahu, Hawaii
    Posts
    58
    Ouch I hate when you miss just one little number or character somewhere

    I'm glad you found a solution. If you get a chance, go to Thread Tools and mark this one as resolved

  6. #6
    Me too. It was a silly mistake on my part that cost me several days of debugging.
    ~~~~~jOn waZ hErE~~~~~

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center