1
votes

I am stuck on a Movie Clip which i make on rollover effect then put link inside in this movie clip now the problem is that onrollover work but on release not any solution ??

code m using

on(release){
getURL("name.html")
}

sample file link

http://escribir.biz/nb1/sample.fla

http://escribir.biz/nb1/sample.swf

the main box have on rollover and on rollout effect and link is in this movie on layer 2 and box in layer 1 in actual movie there are many boxes like this which have links but when rollover work link on release not work

Thanks a lot for help

2
any solution for this ???? - Danish Iqbal

2 Answers

1
votes

1st try to create a simple class for your movieclip and put your controls there.

for example:

class YourMovieClipClassName extends MovieClip
{
    function YourMovieClipClassName() { super(); }
    function onLoad()
    {
        this.ControlMyMC();
    }
    function ControlMyMC()
    {
        this.onRollOver = function()
        {
            //Do on some
        }
        this.onRollOut = function()
        {
            //Do on some
        }
        this.onPress = function()
        {
            //Do on some
        }
        this.onRelease = function()
        {
            this.getURL("name.html");
        }
    }
}
1
votes
  1. Create a MovieClip and give it a name "button1"
  2. Dublicate that MovieClip as many Buttons you want and give names as "button2" "button3" etc
  3. Create another MovieClip and give it the name "main" put it in your Layer 1 and add "Main" as an instanceName
  4. Inside the "Main" MovieClip add the two Buttons and add "Button1" and "Button2" as an Instancename each
  5. Create a Class file for main MovieClip
  6. Copy paste the following code as class

or download the examples.zip to see it http://www.comvos.net/downloads/examples.zip

    class main extends MovieClip
    {
        function main() { super(); }
        function onLoad()
        {
            this.ControlMyMC();
        }
        function ControlMyMC()
        {
            //Turn OFF the HandCursor of Main MC
            this.useHandCursor = false;

            this.onRollOver = function()
            {
                this["AnimatedBG"].gotoAndPlay(2);
                trace("RollOver Main MC");
            }

            this.onRollOut = function()
            {
                this["AnimatedBG"].gotoAndPlay(21);
                trace("RollOut Main MC");
            }

            var ButtonInstanceNames:Array = [
                                    "Button1",
                                    "Button2"
                                    ];


            for(var i:Number = 0; i < ButtonInstanceNames.length; i++)
            {

                this[ButtonInstanceNames[i]].onEnterFrame = function()
                {
                    if (this.hitTest(_root._xmouse, _root._ymouse, true))
                    {
                        //ROLL OVER BUTTON
                        if (!this.isRollOver) 
                        { 
                            this.isRollOver = true; 
                            trace("RollOver " + _name);
                        }
                    }
                    else
                    {
                        //ROLL OUT BUTTON
                        if (this.isRollOver) 
                        { 
                            this.isRollOver = false; 
                            trace("RollOut " + _name);
                        }
                    }
                }


                //ON RELEASE ---(if you want to use onPress .... just replace the onMouseUp wit onMouseDown
                this[ButtonInstanceNames[i]].onMouseUp = function()
                {
                    if (this.hitTest(_root._xmouse, _root._ymouse, true))
                    {
                        switch (_name)
                        {
                            case "Button1": trace("You Clicked on Button 1 ... replace me with --->   this.getURL(\"page1.html\");"); break;
                            case "Button2": trace("You Clicked on Button 2 ... replace me with --->   this.getURL(\"page2.html\");"); break;

                            //example
                            case "Button3": this.getURL("name.html"); break;
                            default: trace("aa"); break;
                        }
                    }
                }               
            }
        }
    }