A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: AS3 Help?????

  1. #1
    Junior Member
    Join Date
    Sep 2010
    Posts
    2

    AS3 Help?????

    K i've been struggling for 2days now.. please anyone help!

    this is the script i use,
    function initapp():void{
    urlbuttonit.addEventListener(MouseEvent.CLICK, buttonClicked);
    urlbuttonp.addEventListener(MouseEvent.CLICK, buttonClicked);
    urlbuttonl.addEventListener(MouseEvent.CLICK, buttonClicked);
    urlbuttoni.addEventListener(MouseEvent.CLICK, buttonClicked);
    urlbuttons.addEventListener(MouseEvent.CLICK, buttonClicked);
    }

    function buttonClicked(event:Event):void
    {
    if(event.currentTarget == urlbuttonit)
    {
    navigateToURL(new URLRequest("mywebsite.com:string=null");
    }
    if(event.currentTarget == urlbuttonp)
    {
    navigateToURL(new URLRequest("mywebsite.com:string=null");
    }
    if(event.currentTarget == urlbuttonl)
    {
    navigateToURL(new URLRequest("mywebsite.com:string=null");
    }
    if(event.currentTarget== urlbuttoni)
    {
    navigateToURL(new URLRequest("mywebsite.com:string=null");
    }
    if(event.currentTarget == urlbuttons)
    {
    navigateToURL(new URLRequest("mywebsite.com:string=null");
    }
    }


    And it doesn't work.
    it give me a syntax error.. i fixed all the other bugs but the last one remains
    i am not big in flash but how the hell can i get this to work?

  2. #2
    :
    Join Date
    Dec 2002
    Posts
    3,518
    Code:
    function initapp():void {
    	urlbuttonit.addEventListener(MouseEvent.CLICK, buttonClicked);
    	urlbuttonp.addEventListener(MouseEvent.CLICK, buttonClicked);
    	urlbuttonl.addEventListener(MouseEvent.CLICK, buttonClicked);
    	urlbuttoni.addEventListener(MouseEvent.CLICK, buttonClicked);
    	urlbuttons.addEventListener(MouseEvent.CLICK, buttonClicked);
    }
    
    function buttonClicked(event:Event):void {
    	switch (event.currentTarget) {
    		case urlbuttonit :
    			navigateToURL(new URLRequest("mywebsite.com"));
    			break;
    		case urlbuttonp :
    			navigateToURL(new URLRequest("mywebsite.com"));
    			break;
    		case urlbuttonl :
    			navigateToURL(new URLRequest("mywebsite.com"));
    			break;
    		case urlbuttoni :
    			navigateToURL(new URLRequest("mywebsite.com"));
    			break;
    		case urlbuttons :
    			navigateToURL(new URLRequest("mywebsite.com"));
    			break;
    		default :
    			break;
    	}
    }

  3. #3
    Junior Member
    Join Date
    Sep 2010
    Posts
    2

    AS3 NOT WORKING ! please help..

    i tried this but my when i export the clip it goes super crazy!

    it just keeps running in a loop.. my buttons not working

  4. #4
    :
    Join Date
    Dec 2002
    Posts
    3,518
    Can you post your fla here?
    Last edited by dawsonk; 11-08-2010 at 12:06 PM.

  5. #5
    Flash/Flex Developer samac1068's Avatar
    Join Date
    Apr 2007
    Location
    Here, no there
    Posts
    1,813
    Maybe you can try using the IS conditional. Try this out. If it doesn't work, can you post the error you are getting.

    Actionscript Code:
    function buttonClicked(event:Event):void
    {
        if(event.currentTarget is urlbuttonit)
        {
            navigateToURL(new URLRequest("mywebsite.com:string=null");
        }
       
        if(event.currentTarget is urlbuttonp)
        {
            navigateToURL(new URLRequest("mywebsite.com:string=null");
        }
       
        if(event.currentTarget is urlbuttonl)
        {
            navigateToURL(new URLRequest("mywebsite.com:string=null");
        }
       
        if(event.currentTarget is urlbuttoni)
        {
            navigateToURL(new URLRequest("mywebsite.com:string=null");
        }
       
        if(event.currentTarget is urlbuttons)
        {
            navigateToURL(new URLRequest("mywebsite.com:string=null");
        }
    }
    Some people are like Slinkies, not really good for anything, but they bring a smile to your face when pushed down the stairs.

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