flash xml button and mouse detection


Content on this page requires a newer version of Adobe Flash Player.

Get Adobe Flash player



Calling flash button from XML i.e. below code
stop();
var xmlLoader:URLLoader = new URLLoader();
xmlLoader.addEventListener(Event.COMPLETE, showXML);
xmlLoader.load(new URLRequest("link.xml"));

function showXML(e:Event):void {
XML.ignoreWhitespace = true;
var songs:XML = new XML(e.target.data);
var number1 = songs.menu.link[0];

removeEventListener(Event.ENTER_FRAME,myFunction);
btn_next.addEventListener(MouseEvent.CLICK, myBtnClicked);

function myBtnClicked(e:MouseEvent):void {
gotoAndPlay(1,"ad2");
trace(number1);
var url:URLRequest = new URLRequest(number1);
navigateToURL(url,"_self");

}

Detect Mouse on stage

getgoing();

function getgoing() {
   
addEventListener(Event.ENTER_FRAME,myFunction);   
}


function myFunction(event:Event) {
   
    if( mouseY < 100){
       
        mc.y = -3;
        mc.x = -14;
        gotoAndPlay("done","ad1");
       
        }   
    else
    {
    mc.y = 100;
    var midPt:uint = 100;
    var diff:int = mouseY - midPt;
    var perc:Number = diff / midPt;
    var maxSpeed:uint = 100;
    mc.y += perc * maxSpeed;
       
    }
}


//1.
stage.addEventListener(MouseEvent.MOUSE_MOVE, mousePosition);

//2.
function mousePosition(event:MouseEvent) {
//trace(String(mouseX));
//xstage_txt.text= String(mouseX);
//ystage_txt.text= "Y Stage: " + String(mouseY);

//xmovie_txt.text= "X MovieClip: " + String(box_mc.mouseX);
//ymovie_txt.text= "Y MovieClip: " + String(box_mc.mouseY);

}

Hide mouse
   
//Mouse.hide();   
//stage.addEventListener (MouseEvent.MOUSE_MOVE, dragCursor);

    function dragCursor (event:MouseEvent):void
    {
    mypointer.x = this.mouseX;
    mypointer.y = this.mouseY;
    }

XML file

0 comments:

Post a Comment