TasteNoEvil Posted February 1, 2014 Report Share Posted February 1, 2014 Hello, Im trying to make a banner 970 x 90 a standard slider size. What I would like to do and what all I can retain at this point seems to be overwhelming at times. I simply want 3 buttons to all act the same and don't see in my code where they do, my third buttons alpha doesn't get affected by a rollover. I need the first button to display an image that when mouse over will spin. This image is in my library, how do I designate it as a mc from only actionscript and when doing so make it interactive so that the image (myLogo.rotation = 90 degrees). I would also like to make another image fade in with a tween. image = PsLogo with tween alpha until solid image. Like a fade in. The third button I would like to redirect someone to a page via a URL link. I will take any advice, Im not just looking for the correct code but to understand what ive done wrong and haven't done. I am a student and have an A grade in the 4th week but found myself a couple weeks behind on understanding all the readings. thanks for reading this far here is my code import flash.display.Sprite; import flash.text.TextFormat; import flash.text.TextField; import flash.display.Sprite; import flash.events.MouseEvent; //container var container:Sprite = new Sprite () addChild(container); for (var i:int = 0; i<3; i++) { //create the background shape for our buttons var btnBg:Shape = new Shape(); //use the lineStyle method to set the line thickness and color //we are also setting an alpha of 50% and turning pixel hinting on btnBg.graphics.lineStyle(3, 0xf0ff00, .5, true); //use the beginFill method to fill the shape with the specified color btnBg.graphics.beginFill(0x000000); //use the drawRoundRect method to draw a rounded rectangle which has //six parameters, listed in order of appearance: x, y, width, height, //ellipse width, and ellipse height (for the rounded corners) btnBg.graphics.drawRoundRect(300,80, 70, 30, 10, 10); //use the endFill method to end the fill of the shape btnBg.graphics.endFill(); //create our new font object var btnFont = new Font1(); //Create a new TextField object; var titleTxt:TextField = new TextField ; //create a new TextFormat object var btnFormat:TextFormat = new TextFormat(); //set the font objects as the font for our TextFormat object btnFormat.font = btnFont.fontName; //set the properties for the text format object btnFormat.size = 10; btnFormat.align = "center"; btnFormat.color = 0xf0ff00; //create a new TextField object var btnTxt:TextField = new TextField; //set our TextFormat objects as the format for our TextField btnTxt.defaultTextFormat = btnFormat; btnTxt.embedFonts = true; //set the text field properties btnTxt.width = 65; btnTxt.height = 20; btnTxt.y = 85; btnTxt.x = 300; //create a new instance of our button each time the loops runs //the buttons will be encased in a sprite display object container var myBtn:Sprite = new Sprite(); //create an array to hold our button labels var btnLabels:Array = ["Azakel", "Pandemic", "Medium"]; //create an array to hold our buttons which we will create in the following loop var btnArray:Array = new Array(); //set the sprite to act like a button myBtn.buttonMode = true; //make sure the children of the sprite are not actively listening for events myBtn.mouseChildren = false; //add our new button to th display list addChild(myBtn); //position the button in a horizontal line myBtn.y = 100; myBtn.x = 25 + (i*85); //add the background shape to the button display container object myBtn.addChild(btnBg); //populate the button's text field with the new name btnTxt.text = btnLabels; //add our TextField to the display list myBtn.addChild(btnTxt); //add event listeners to our buttons myBtn.addEventListener(MouseEvent.CLICK, btnHandler); myBtn.addEventListener(MouseEvent.ROLL_OVER, btnHandler); myBtn.addEventListener(MouseEvent.ROLL_OUT, btnHandler); btnArray.push(myBtn); } //multiple event function for our buttons function btnHandler(event:MouseEvent):void { //check to see if this is a mouse click event if (event.type == MouseEvent.CLICK) { var j:int=container.numChildren; //remove the page contents each time a menu button is pressed while (j--) { trace('before: '+container.numChildren); container.removeChildAt(j); trace('after :'+container.numChildren); } } if(event.target==btnArray[0]) {//if first button in the array } else if (event.target == btnArray[1]){//else if second button }else if (event.target == btnArray[2]) { //else if third //check to see if this is a roll over event }else if (event.type == MouseEvent.ROLL_OVER) { //change the alpha of the button to create a roll over effect event.target.alpha = .7; } //check to see if this is a roll out event else if (event.type == MouseEvent.ROLL_OUT) { //change the alpha of the button back to its original state event.target.alpha = 1; } } notes: once I press a button I would like what that button shows to stay and not be removed. thanks Kelly Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.