dcsimg
A Flash Developer Resource Site

Results 1 to 13 of 13

Thread: [RESOLVED] Help with hiding elements!

  1. #1
    Junior Member
    Join Date
    May 2010
    Posts
    15

    resolved [RESOLVED] Help with hiding elements!

    I'm working on an online portfolio of design work. I've set the jpegs up to load dynamically into movie clips so I don't have to keep them in my .fla file.

    To see the issue: please open "help_.fla" and 3 jpegs (same folder as the .fla file). Run the flash movie. Click on the "NVIDIA" in the top navigation, then on CBS Cable. When the first page of CBS Cable appears, click on the right arrow to see the next CBS page. Then, click again on "NVIDIA" in the top navigation bar.

    1. How can I hide the left or right arrows depending on which CBS page I'm on? When I'm on the first page, for example, the back arrows should be hidden. 2. When I'm back in the NVIDIA page again, how can I hide the arrows still showing from the CBS Cable pages?

    Finally, what's up with the brief flashing of the NVIDIA screen when I click on the right or left arrows of the CBS pages?

    Here's the code I'm using to call up the images dynamically into movie clips. Thanks so much for any advice.

    stop();
    var curLocation = '';

    if(i){
    this.removeChild(i);
    }

    var i =new Loader();
    i.load(new URLRequest('cbs1.jpg'));
    this.addChild(i);

    i.x = 68;
    i.y = 0;

    var numOfPages = 2;

    curLocation = '1';

    more.addEventListener(MouseEvent.CLICK, clickSection);
    back.addEventListener(MouseEvent.CLICK, clickSection);

    function clickSection(evtObj:MouseEvent) {
    switch(evtObj.target.name){
    case 'more':
    if(curLocation == numOfPages){
    curLocation = 1;
    }else{
    curLocation++;
    }
    break;
    case 'back':
    if(curLocation == 1){
    curLocation = numOfPages;
    }else{
    curLocation--;
    }
    break;
    }

    gotoAndStop('page'+curLocation);
    }
    Attached Images Attached Images
    Attached Files Attached Files

  2. #2
    :
    Join Date
    Dec 2002
    Posts
    3,518
    ...
    Last edited by dawsonk; 06-03-2010 at 05:43 PM. Reason: Updated code below...

  3. #3
    Junior Member
    Join Date
    May 2010
    Posts
    15
    dawsonk, you rock so hard. Thank you so much!

  4. #4
    Junior Member
    Join Date
    May 2010
    Posts
    15
    The only thing I can't figure out right now is that the CBS page doesn't fade in anymore (like the Nvidia page). I've been over the code looking for cut&paste errors on my part, but I've found nothing so far. Any ideas?

  5. #5
    :
    Join Date
    Dec 2002
    Posts
    3,518
    Post your code?

    Code:
    stop();
    import fl.transitions.Tween;
    import fl.transitions.easing.*;
    
    var mainX:int=4;
    var mainY:int=96;
    var loaded:DisplayObject;
    
    nvidia.addEventListener(MouseEvent.CLICK, clickSectionnvidia);
    
    function clickSectionnvidia(evtObj:MouseEvent) {
    	//trace shows what's happening in output window
    	trace("The "+evtObj.target.name+" button was clicked!");
    	//go to the section clicked on
    	gotoAndStop(evtObj.target.name);
    	if (loaded!=null) {
    		this.removeChild(loaded);
    	}
    	var mcnvidiaclip:nvidiaclip = new nvidiaclip();
    	loaded=mcnvidiaclip;
    	mcnvidiaclip.x=mainX;
    	mcnvidiaclip.y=mainY;
    	mcnvidiaclip.alpha=0;
    	this.addChild(mcnvidiaclip);
    	var nvidiaTween:Tween=new Tween(mcnvidiaclip,'alpha',Strong.easeIn,0,1,1.5,true);
    }
    
    cbs1.addEventListener(MouseEvent.CLICK, clickSectioncbs);
    
    function clickSectioncbs(evtObj:MouseEvent) {
    	//trace shows what's happening in output window
    	trace("The "+evtObj.target.name+" button was clicked!");
    	//go to the section clicked on
    	gotoAndStop(evtObj.target.name);
    	if (loaded!=null) {
    		this.removeChild(loaded);
    	}
    	var mccbsclip:cbsclip = new cbsclip();
    	loaded=mccbsclip;
    	mccbsclip.x=mainX;
    	mccbsclip.y=mainY;
    	mccbsclip.alpha=0;
    	this.addChild(mccbsclip);
    	var cbsTween:Tween=new Tween(mccbsclip,'alpha',Strong.easeIn,0,1,1.5,true);
    }
    Code:
    stop();
    var curLocation='1';
    var numOfPages=2;
    
    if (i) {
    	this.removeChild(i);
    }
    
    var i =new Loader();
    i.load(new URLRequest('cbs1.jpg'));
    i.x=68;
    i.y=0;
    this.addChild(i);
    
    more.addEventListener(MouseEvent.CLICK, clickSection);
    back.addEventListener(MouseEvent.CLICK, clickSection);
    
    function clickSection(evtObj:MouseEvent=null) {
    	if (evtObj!=null) {
    		switch (evtObj.target.name) {
    			case 'more' :
    				if (curLocation==numOfPages) {
    					curLocation=1;
    				} else {
    					curLocation++;
    				}
    				break;
    			case 'back' :
    				if (curLocation==1) {
    					curLocation=numOfPages;
    				} else {
    					curLocation--;
    				}
    				break;
    		}
    		gotoAndStop('page'+curLocation);
    	}
    	more.visible=true;
    	back.visible=true;
    	if (Number(curLocation)==numOfPages) {
    		more.visible=false;
    	}
    	if (Number(curLocation)==1) {
    		back.visible=false;
    	}
    }
    clickSection();

  6. #6
    Junior Member
    Join Date
    May 2010
    Posts
    15
    My code:

    stop();
    import fl.transitions.Tween;
    import fl.transitions.easing.*;

    var mainX:int=4;
    var mainY:int=96;
    var loadedisplayObject;

    nvidia.addEventListener(MouseEvent.CLICK, clickSectionnvidia);

    function clickSectionnvidia(evtObj:MouseEvent) {
    //trace shows what's happening in output window
    trace("The "+evtObj.target.name+" button was clicked!");
    //go to the section clicked on
    gotoAndStop(evtObj.target.name);
    if (loaded!=null) {
    this.removeChild(loaded);
    }
    var mcnvidiaclip:nvidiaclip = new nvidiaclip();
    loaded=mcnvidiaclip;
    mcnvidiaclip.x=mainX;
    mcnvidiaclip.y=mainY;
    mcnvidiaclip.alpha=0;
    this.addChild(mcnvidiaclip);
    var nvidiaTween:Tween=new Tween(mcnvidiaclip,'alpha',Strong.easeIn,0,1,1.5,t rue);
    }

    cbs1.addEventListener(MouseEvent.CLICK, clickSectioncbs);

    function clickSectioncbs(evtObj:MouseEvent) {
    //trace shows what's happening in output window
    trace("The "+evtObj.target.name+" button was clicked!");
    //go to the section clicked on
    gotoAndStop(evtObj.target.name);
    if (loaded!=null) {
    this.removeChild(loaded);
    }
    var mccbsclip:cbsclip = new cbsclip();
    loaded=mccbsclip;
    mccbsclip.x=mainX;
    mccbsclip.y=mainY;
    mccbsclip.alpha=0;
    this.addChild(mccbsclip);
    var cbsTween:Tween=new Tween(mccbsclip,'alpha',Strong.easeIn,0,1,1.5,true );
    }

    And the cbsclip code:

    stop();
    var curLocation='1';
    var numOfPages=2;

    if (i) {
    this.removeChild(i);
    }

    var i =new Loader();
    i.load(new URLRequest('cbs1.jpg'));
    i.x=68;
    i.y=0;
    this.addChild(i);

    more.addEventListener(MouseEvent.CLICK, clickSection);
    back.addEventListener(MouseEvent.CLICK, clickSection);

    function clickSection(evtObj:MouseEvent=null) {
    if (evtObj!=null) {
    switch (evtObj.target.name) {
    case 'more' :
    if (curLocation==numOfPages) {
    curLocation=1;
    } else {
    curLocation++;
    }
    break;
    case 'back' :
    if (curLocation==1) {
    curLocation=numOfPages;
    } else {
    curLocation--;
    }
    break;
    }
    gotoAndStop('page'+curLocation);
    }
    more.visible=true;
    back.visible=true;
    if (Number(curLocation)==numOfPages) {
    more.visible=false;
    }
    if (Number(curLocation)==1) {
    back.visible=false;
    }
    }
    clickSection();

  7. #7
    Junior Member
    Join Date
    May 2010
    Posts
    15
    Weird. That smiley face should be a "".

    I'm going to paste that again ad see it the smiley face comes back:
    var loadedisplayObject;

  8. #8
    Junior Member
    Join Date
    May 2010
    Posts
    15
    what's up with the blasted smiley faces? lol

  9. #9
    Junior Member
    Join Date
    May 2010
    Posts
    15
    That line of code, in my flash file, reads (without the spaces):

    var loaded : DisplayObject;

  10. #10
    Junior Member
    Join Date
    May 2010
    Posts
    15
    I figured it out. It's because I still had the crazy timeline sections with images in them. Duh.

  11. #11
    Junior Member
    Join Date
    May 2010
    Posts
    15
    OK, one more question. If a section has more than two pages (which some do), the back arrows on the last page are jumping directly to the first page in the series. They should page back from, say, page3 to page2 to page1. But right now, they're going from page3 right to page1. What code should I add to make it work one page at a time?

    Current code:

    stop();
    var curLocation='1';
    var numOfPages=3;

    if (i) {
    this.removeChild(i);
    }

    var i =new Loader();
    i.load(new URLRequest('asc1.jpg'));
    i.x=68;
    i.y=0;
    this.addChild(i);

    more.addEventListener(MouseEvent.CLICK, clickSection);
    back.addEventListener(MouseEvent.CLICK, clickSection);

    function clickSection(evtObj:MouseEvent=null) {
    if (evtObj!=null) {
    switch (evtObj.target.name) {
    case 'more' :
    if (curLocation==numOfPages) {
    curLocation=1;
    } else {
    curLocation++;
    }
    break;

    case 'back' :
    if (curLocation==1) {
    curLocation=numOfPages;
    } else {
    curLocation--;
    }
    break;

    }
    gotoAndStop('page'+curLocation);
    }
    more.visible=true;
    back.visible=true;
    if (Number(curLocation)==numOfPages) {
    more.visible=false;
    }
    if (Number(curLocation)==1) {
    back.visible=false;
    }
    }
    clickSection();

  12. #12
    :
    Join Date
    Dec 2002
    Posts
    3,518
    Make sure you updated the variables on the 'page' frames.

    Code:
    stop();
    
    curLocation='2';
    
    this.removeChild(i);
    i.load(new URLRequest('cbs2.jpg'));
    this.addChild(i);
    Code:
    stop();
    
    curLocation='3';
    
    this.removeChild(i);
    i.load(new URLRequest('cbs3.jpg'));
    this.addChild(i);

  13. #13
    Junior Member
    Join Date
    May 2010
    Posts
    15
    And again I say unto you: "Duh."

    Thank you so much! You totally rock.

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