A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Please help with a simple conditional statement

  1. #1
    Junior Member
    Join Date
    May 2006
    Posts
    4

    Please help with a simple conditional statement

    Horizontal scroll menu keeps falling off the stage when cursor is on right side. I really need some help!

    I have attached the file and below is the code. Thank you in advance!

    var myShape:Shape = new Shape()
    myShape.graphics.beginFill(0x7E00E3);
    myShape.graphics.drawRect(50,10,450, 100)

    addChild(myShape)
    menu_mc.mask=myShape

    stage.addEventListener(Event.ENTER_FRAME, movemenu);
    function movemenu(myevent:Event):void {
    menu_mc.x = menu_mc.x + (0.5 * myShape.width - mouseX) / 10;
    if (menu_mc.x>300) {
    menu_mc.x=300;
    }


    }
    Attached Files Attached Files

  2. #2
    FK Romeo martiansam's Avatar
    Join Date
    Oct 2001
    Location
    Bombay, India
    Posts
    223
    I have attached the updated .fla

    Had to change your symbol so that registration is from 0 for x (since we are moving horizontally).

    The code change was as given below:

    Code:
    var myShape:Shape = new Shape()
    myShape.graphics.beginFill(0x7E00E3);
    myShape.graphics.drawRect(50,10,450, 100)
    
    addChild(myShape)
    menu_mc.mask=myShape
    
    stage.addEventListener(Event.ENTER_FRAME, movemenu);
    function movemenu(myevent:Event):void {
    	menu_mc.x = menu_mc.x + (0.5 * myShape.width - mouseX) / 10;
    	if (menu_mc.x>0) {
    		trace("came in here")
    		menu_mc.x=0;
    	}
    	
    	if(menu_mc.x < -((menu_mc.width - myShape.width) - 50))		// 50 is because myShape starts from 50...you might want to take this into a variable
    	{
    		menu_mc.x = -((menu_mc.width - myShape.width) - 50)
    	}
    
    
    }
    Attached Files Attached Files
    sameer rao

    there...you see!!

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