A Flash Developer Resource Site

Results 1 to 10 of 10

Thread: Slinding content window effect: How to?

  1. #1
    Junior Member
    Join Date
    Jun 2008
    Posts
    7

    Slinding content window effect: How to?

    Hi.

    I creating my first flash (actionscript 3.0) website but I'm stuck with a visual effect I want to create.
    I have a window on my website called contentWindow. Every time you click a button this window is supposed to leave the stage, load the requested content and return to the stage.
    The sliding window is a movie clip with 83 frames, 21 to enter the stage, 21 to leave the stage again, 20 for nothing (its just to simulate the loading time) and 21 to return to the stage.

    Now my goal is, when the user clicks on a navigation button, the window exits the stage, loads an external SWF with the content, and then returns to the stage.

    I've the "window" movie clip with an instance name of "contentWindow". Inside there is another movie clip with an instance name of "contentLoader". The content that the user requested should appear inside the "contentLoader".

    So far this is what I've done:

    Code:
    //stops playback after the intro
    stop();
    
    //loads a loader with the "inicio.swf" file
    var navLoader:Loader = new Loader();
    var inicio_url:URLRequest = new URLRequest("inicio.swf");
    
    //event listeners for the buttons
    inicio_btn.addEventListener(MouseEvent.CLICK, navInicio);
    wdesign_btn.addEventListener(MouseEvent.CLICK, navWDesign);
    foto_btn.addEventListener(MouseEvent.CLICK, navFoto);
    model_btn.addEventListener(MouseEvent.CLICK, navModel);
    servicos_btn.addEventListener(MouseEvent.CLICK, navServ);
    contactos_btn.addEventListener(MouseEvent.CLICK, navCont);
    
    //functions to every button where the navLoader variable is defined
    function navInicio(event:MouseEvent):void
    {
    	navLoader.load(inicio_url);
    	contentWindow.play();
    	addEventListener(Event.ENTER_FRAME, trigger);
    }
    
    function navWDesign(event:MouseEvent):void
    {
    	contentWindow.play();
    	addEventListener(Event.ENTER_FRAME, trigger);
    }
    
    function navFoto(event:MouseEvent):void
    {
    	contentWindow.play();
    	addEventListener(Event.ENTER_FRAME, trigger);
    }
    
    function navModel(event:MouseEvent):void
    {
    	contentWindow.play();
    	addEventListener(Event.ENTER_FRAME, trigger);
    }
    
    function navServ(event:MouseEvent):void
    {
    	contentWindow.play();
    	addEventListener(Event.ENTER_FRAME, trigger);
    }
    
    function navCont(event:MouseEvent):void
    {
    	contentWindow.play();
    	addEventListener(Event.ENTER_FRAME, trigger);
    }
    
    //the function that triggers when the contentWindow leaves the stage
    function trigger(event:Event):void
    {
    	if (contentWindow.currentFrame == 43)
    	{
    		contentWindow.gotoAndPlay(44);
    		contentWindow.contentLoader.addChild(navLoader);
    		removeEventListener(Event.ENTER_FRAME, trigger);
    	}
    }
    Now, when the contentWindow leaves the stage, I get this error message:

    [/quote]TypeError: Error #1009: Cannot access a property or method of a null object reference.
    at rwd_fla::MainTimeline/trigger()[/quote]

    What I'm I doing wrong?

  2. #2
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    It is probably this line, which is causing you trouble
    contentWindow.contentLoader.addChild(navLoader);
    Check if any of those objects is null by tracing.
    - The right of the People to create Flash movies shall not be infringed. -

  3. #3
    Junior Member
    Join Date
    Jun 2008
    Posts
    7
    Yes, the problem is indeed that line. If I remove contentLoader it works just fine: contentWindow.addChild(navLoader);

    The contentLoader is a simple square converted to a Movie Clip inside the contentWindow movie clip. I created it so I can add a motion tween. Without this, the external SWF is loaded into x=0 and y=0 of the contentWindow and doesn't move together with the window, it holds still while the window slides out and in to the stage.

  4. #4
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    Try
    MovieClip(contentWindow.getChildByName("contentLoa der")).addChild(navLoader);
    - The right of the People to create Flash movies shall not be infringed. -

  5. #5
    Junior Member
    Join Date
    Jun 2008
    Posts
    7
    Tried it and I still get the same error.

  6. #6
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    Actually your original line should have been working and so should mine. I would look if the name of the MovieClip is correct.
    - The right of the People to create Flash movies shall not be infringed. -

  7. #7
    Junior Member
    Join Date
    Jun 2008
    Posts
    7
    Yes, all the instances names are correct. I'm going nuts with this thing.

  8. #8
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    post the fla.
    - The right of the People to create Flash movies shall not be infringed. -

  9. #9

  10. #10
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    Check the content movieclip - line as - frame 63. You have the contentLoader twice, which screws up your movie. Delete that instance.
    - The right of the People to create Flash movies shall not be infringed. -

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