here is my code:

 

import flash.net. URLRequest;
import flash.display.Shape;
import flash.text.TextFormat;
import flash.text.TextField;
import flash.display.Sprite;
import flash.events.MouseEvent;

 

//create a new URLRequest
var myRequest:URLRequest = new URLRequest(“http://www.google.com“);

 

//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(1, 0xcccfff, .5, true);

 

//use the beginFill method to fill the shape with the specified color
btnBg.graphics.beginFill(0xFF6600);

 

//use the drawRect method to draw a rounded rectangle with 5 parameters
//x. y, width, height, and corner radius, in that order
btnBg.graphics.drawRoundRect(0, 0, 100, 30, 10);

 

//use the endFill method to end the fill of the shape
btnBg.graphics.endFill();

 

 

 

//create our new font object
var btnFont = new Tahoma();
//create a new TextFormat object
var btnFormat: TextFormat = new TextFormat();
//set the font object as the font for our TextFormat object
btnFormat.font = btnFont.fontName;

 

//set the properties for the text format object
btnFormat.size = 14;
btnFormat.align = “center”;
btnFormat.color = 0xFFFFcc;
//create a new TextField object
var btnTxt:TextField = new TextField;

 

//set our TextFormat object as the format for our TextField
btnTxt.defaultTextFormat = btnFormat;

 

//set the text field properties
btnTxt.width = 100;
btnTxt.height = 20;
btnTxt.y = 5;

 

//populate the button’s text field
btnTxt.text = “GOOGLE”;

 

//create a sprite to hold our button
var googleBtn:Sprite = new Sprite();

 

//set the sprite to act like a button
googleBtn.buttonMode = false;
//make sure the children of the sprite are not listening for events
googleBtn.mouseChildren = false;

 

//add our new button to the display list
addChild(googleBtn);

 

//position the button in a horizontal line
googleBtn.y = 100;
googleBtn.x = 225;

 

//add the background shape to the button display container object
googleBtn.addChild(btnTxt);

 

 

 

 

 

//add event listeners tou our button
googleBtn.addEventListener(MouseEvent.CLICK, btnHandler);
googleBtn.addEventListener(MouseEvent.ROLL_OVER, btnHandler);
googleBtn.addEventListener(MouseEvent.ROLL_OUT, btnHandler);

 

//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)
{
    //navigate to the URL
    navigateToURL(myRequest)
}
        //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 event
        event.target.alpha = .7;
        }
   
    //check to see if this is a roll out event
    else if (event.type == MouseEvent.ROLL_OUT)
    {
        //put the a[pha back to 100% when we roll out
        event.target.alpha = 1;
       
    }
   
}

|||

If you want to show the button background you need to add it to the display list, i.e.

googleBtn.addChild(btnBg);
googleBtn.addChild(btnTxt);

(if this is what you’re talking about at all )

|||

actually I posted the wrong code! Here it is:

 

import com.greensock.*;
import com.greensock.easing.*;
import flash.display.Sprite;
import flash.display.Shape;
import flash.events.MouseEvent;
import flash.display.Loader;
import flash.net.URLRequest;
import caurina.transitions.Tweener;

 

//container to hold images- makes them easier to remove
var container: Sprite = new Sprite;
//create arrays for buttons and images
var btnMenu: Array = new Array();
var images:Array = ["images/image1.jpg","images/image2.jpg","images/image3.jpg", "images/image4.jpg", "images/image5", "images/image6.jpg", "images/image7.jpg"];

 

//nav bar is grey and position is on bottom
var menuBg:Shape = new Shape();
menuBg.graphics.beginFill(0×999999, .5);
menuBg.graphics.drawRect(0, 350, 550, 30);
menuBg.graphics.endFill();

 

// image container
addChild(container);
// menu bar to the display list
addChild(menuBg);

 

//variables for counting
var totalLinks: int = 7;
for (var i:int = 0; i<totalLinks; i++)
// not sure I understand above prob createing the loop

 

{   
    //create the background shape of button
    var btnBg:Shape = new Shape();
    btnBg.graphics.lineStyle(1, 0×000000, .7,true);//black outline
    btnBg.graphics.beginFill(0xE1E1D6, .5);
    btnBg.graphics.drawCircle(0, 0, 7);
    btnBg.graphics.endFill();
}
var myBtn:Sprite=new Sprite();
myBtn.name=”image”+(i+1).toString();
myBtn.buttonMode=true;
addChild(myBtn);

 

myBtn.y=365;
myBtn.x=200+(i*10);
myBtn.addChild(btnBg);

 

myBtn.addEventListener(MouseEvent.CLICK, btnHandler);
myBtn.addEventListener(MouseEvent.ROLL_OVER, btnHandler);
myBtn.addEventListener(MouseEvent.ROLL_OUT, btnHandler);

 

btnMenu.push(myBtn);
//add button handler
function btnHandler(event:MouseEvent):void {
    if (event.type==MouseEvent.CLICK) {
        for (var i:int=0; i<totalLinks; i++) {
            if (event.target==btnMenu[i]) {
                var loader:Loader= new Loader();
                loader.alpha=0;
                loader.x=550;

 

//add loader for external photos

 

    loader.load(new URLRequest(“images/image1.jpg”));
    container.addChild(loader);
   
    TweenLite.to(loader,1.5,{alpha:1, x:0, ease:Bounce.easeOut});
    TweenMax.to(loader, 0, {blurFilter:{blurX:60}});
    TweenMax.to(loader, 2, {blurFilter:{blurX:0}});
            }
        }

 

trace(event.target.name +” was clicked”);
    }
else if (event.type == MouseEvent.ROLL_OVER){
    event.target.alpha = .7;
}
else if (event.type == MouseEvent.ROLL_OUT){
    event.target.alpha=1;
}
}

|||

actually, I posted the wrong code! Here is the code I need help with:

 

import com.greensock.*;
import com.greensock.easing.*;
import flash.display.Sprite;
import flash.display.Shape;
import flash.events.MouseEvent;
import flash.display.Loader;
import flash.net.URLRequest;
import caurina.transitions.Tweener;

 

//container to hold images- makes them easier to remove
var container: Sprite = new Sprite;
//create arrays for buttons and images
var btnMenu: Array = new Array();
var images:Array = ["images/image1.jpg","images/image2.jpg","images/image3.jpg", "images/image4.jpg", "images/image5", "images/image6.jpg", "images/image7.jpg"];

 

//nav bar is grey and position is on bottom
var menuBg:Shape = new Shape();
menuBg.graphics.beginFill(0×999999, .5);
menuBg.graphics.drawRect(0, 350, 550, 30);
menuBg.graphics.endFill();

 

// image container
addChild(container);
// menu bar to the display list
addChild(menuBg);

 

//variables for counting
var totalLinks: int = 7;
for (var i:int = 0; i<totalLinks; i++)
// not sure I understand above prob createing the loop

 

{   
    //create the background shape of button
    var btnBg:Shape = new Shape();
    btnBg.graphics.lineStyle(1, 0×000000, .7,true);//black outline
    btnBg.graphics.beginFill(0xE1E1D6, .5);
    btnBg.graphics.drawCircle(0, 0, 7);
    btnBg.graphics.endFill();
}
var myBtn:Sprite=new Sprite();
myBtn.name=”image”+(i+1).toString();
myBtn.buttonMode=true;
addChild(myBtn);

 

myBtn.y=365;
myBtn.x=200+(i*10);
myBtn.addChild(btnBg);

 

myBtn.addEventListener(MouseEvent.CLICK, btnHandler);
myBtn.addEventListener(MouseEvent.ROLL_OVER, btnHandler);
myBtn.addEventListener(MouseEvent.ROLL_OUT, btnHandler);

 

btnMenu.push(myBtn);
//add button handler
function btnHandler(event:MouseEvent):void {
    if (event.type==MouseEvent.CLICK) {
        for (var i:int=0; i<totalLinks; i++) {
            if (event.target==btnMenu[i]) {
                var loader:Loader= new Loader();
                loader.alpha=0;
                loader.x=550;

 

//add loader for external photos

 

    loader.load(new URLRequest(“images/image1.jpg”));
    container.addChild(loader);
   
    TweenLite.to(loader,1.5,{alpha:1, x:0, ease:Bounce.easeOut});
    TweenMax.to(loader, 0, {blurFilter:{blurX:60}});
    TweenMax.to(loader, 2, {blurFilter:{blurX:0}});
            }
        }

 

trace(event.target.name +” was clicked”);
    }
else if (event.type == MouseEvent.ROLL_OVER){
    event.target.alpha = .7;
}
else if (event.type == MouseEvent.ROLL_OUT){
    event.target.alpha=1;
}
}

|||

At a quick glance:

 

• Your button creation code (“myButton”) needs to go inside the loop

• You don’t need to name your button

• It should be loader.load(new URLRequest(images[i]));

• When you do the tweens your image is not yet loaded and the Loader is empty so you don’t see any effects – apply tweens on load completion

 

    There are other issues too but these should get you started hopefully

    Related posts:

    1. Datagrid colum item renderer HELP!!!!!
    2. problem with white space around movie
    3. Microhpone work in swf but not projector(exe)
    4. listener on URLLoader vs Loader problem
    5. URL request / loader issues

    Related posts brought to you by Yet Another Related Posts Plugin.

     Leave a Reply

    (required)

    (required)

    You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

       
    © 2012 free icons download Suffusion theme by Sayontan Sinha

    Featuring Recent Posts WordPress Widget development by YD