A Flash Developer Resource Site

Results 1 to 1 of 1

Thread: 5 state button from xml (active/nonactive) + movieclip attachment

  1. #1
    Junior Member
    Join Date
    Jul 2008
    Posts
    8

    5 state button from xml (active/nonactive) + movieclip attachment

    Hi all,

    Im loading a certain amount of images which are intepretated as buttons from an xml file. These buttons all have the same click, mouseover and mouseout states. I want them, when pressed turn into an active state (tintchange, increase scale, whatever doesn't matter). And put the rest in nonactive state, default up state. Onclick should do 2 things, parse a var to a function and attach a movieclip to the button

    Code:
    function completeHandler(event:Event):void
    		{
    		   imgArray.push(event.currentTarget.loader);
    		   if(imgArray.length==sitemap.link.length()){
    			  for(var n:int=0;n<sitemap.link.length();n++){
    				 
    				 var sUp:Bitmap = new Bitmap(event.target.content.bitmapData);
    				 var sBtn:SimpleButton = new SimpleButton();
    				 sBtn.upState = sBtn.hitTestState = sBtn.downState = sBtn.overState = sUp;
    				
    				mapcontainer.addChild(sBtn);
    				
    				
    				 sBtn.x= sitemap.link.locx[n].text();
    				 sBtn.y = sitemap.link.locy[n].text();
    				 sBtn.name = sitemap.link.loc[n].text();
    				 
    				 //Setup Listeners
    				 sBtn.addEventListener(MouseEvent.CLICK, doSomething);
    				 sBtn.addEventListener(MouseEvent.MOUSE_OVER, mouseListener);
    				 sBtn.addEventListener(MouseEvent.MOUSE_OUT, mouseListener); 
    				 }
    				 
    		   }
    		 }
    
    function doSomething(evt:event)
    {
    var loader:Loader=new Loader();   
    loader.contentLoaderInfo.addEventListener(Event.COMPLETE,Loadexternal);
    loader.load(new URLRequest("images/"+ evt.currentTarget.name +".png"));
    
    //Set color of clicked item to red
    //Set color of unclicked items to blue
    //Attach rotating image to the clicked button
    }
    How can I
    attach a movieclip to the clicked button on the clicked button and set it active while setting the rest of the buttons in inactive state. Setting the color of the clicked item to red is easy, but I don't know how to deactivate it when something else is pressed.
    Last edited by Jareish; 07-09-2008 at 04:14 AM.

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