A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: Using mouseover to display information using flash actionscript 2.0

  1. #1
    Registered User
    Join Date
    Jan 2013
    Posts
    6

    Using mouseover to display information using flash actionscript 2.0

    below code : rotate by mouse

    onEnterFrame = function(){


    hero._rotation=getmouse(hero);

    }

    getmouse = function (mc:MovieClip):Number{


    dy=_ymouse-mc._y;
    dx=_xmouse-mc._x;
    rad =Math.atan2(dy, dx);

    rotate= rad*180/Math.PI;
    return rotate;
    }

  2. #2
    Senior Wabbit
    Join Date
    Jul 2008
    Location
    Winchester, Uk
    Posts
    215
    I don't understand what you wish to achieve to be honest.
    You say you want to display information on a mouseover

    But your code, has nothing to do with displaying information.

    So my question is: What is it you wish to achieve?
    a) Display information on a mouseover mc? (If this option what information, ie string, mc or other)
    b) Rotation of mc? (What type so the mc rotates to face the mouse or so the mc rotates all the time, just depending where the mouse is what speed and direction)
    Also if option 1 of a, in the same direction all the time or the shortest direction to rotate in.
    Or do you which to achieve both a and b?

    Just need more information.

    Trust my code, and not my english.

  3. #3
    Registered User
    Join Date
    Jan 2013
    Posts
    6

    dynamic content creation from an object using actionscript

    Hi Wabbit,

    i have attached my project screen shot, and i have to display dynamic text for when i click the object. globeimage.jpg

    Thanks for your support.



    You say you want to display information on a mouseover

    But your code, has nothing to do with displaying information.

    So my question is: What is it you wish to achieve?
    a) Display information on a mouseover mc? (If this option what information, ie string, mc or other)
    b) Rotation of mc? (What type so the mc rotates to face the mouse or so the mc rotates all the time, just depending where the mouse is what speed and direction)
    Also if option 1 of a, in the same direction all the time or the shortest direction to rotate in.
    Or do you which to achieve both a and b?

    Just need more information.[/QUOTE]

  4. #4
    Senior Wabbit
    Join Date
    Jul 2008
    Location
    Winchester, Uk
    Posts
    215
    The easiest way would be to use the ._name function.
    The issue with this is it will call what ever the rollover is set on which would be the holding mc in 99% of cases.
    Creating a rollover for each individual item would be impractical.
    This mean you have 2 option create a listener for onRollOver of the movie clips, or create a loop and have all the names within an array.

    Personally I would go for option 2 as it gives you the most flexibility and it will work.

    The example has been tested in CS3 AS2, working 100%, just place the code in the _root timeline actions.
    I have commented so you know what is going on.
    I have a holding mc called holder, and all the item inside I which to have the rollover text has an instance of B[i], aka, B1, B2, B3, B4

    Code:
    Item = "";
    //Contains the item number to pull from the array
    tempItem = ""; 
    //Contains the instance name you rollover Ie: B1
    var naming:Array = new Array("square", "circle", "pentagon", "triange");
    //List of the names you which to appear in your text, Starting with item B1
    onEnterFrame = function(){
    //Function is check constantly at the frame rate from the moment you enter the frame
    	for (i=1; i<=naming.length; i++) {
    //Loop for the rollover items. i = Starting instance number, i<= The length of your array, ie number of items
    		holder["B"+i].onRollOver = function () {
    //Holder is the holding mc, the child mc's refering to B + i, the item length, when mouse goes over start the check process
    			tempItem = this._name;
    //Set Temp item as the instance name you rolledOver
    			Item = tempItem.substring(1);
    //Remove the starting letter from the instance
    			trace(naming[Item-1]);
    //THIS IS A TRACE IT IS NOT REQUIRED
    //Though this will trace the name of the item from the array, arrays start at 0 hence item-1
    		}
    	}
    }
    All you need to do is refer your dynamic text to the trace which you will want to replace with
    Code:
    var = naming[Item-1];
    Where var is the name your dynamic text is looking for

    Lastly you will want to add a function to clear the dynamic text when nothing is selected as a guess
    Also guessing you will want to get the text item to follow the mouse.
    Both are fairly simple, I wish you the best of luck.
    If all is good pls Mark as Resolved

    Thanks
    Mr Wabbit

    P.s I almost forget if you want something more powerful, I advise goggle, AS2 ToolTip.
    Last edited by Mr Wabbit; 02-01-2013 at 01:49 PM.

    Trust my code, and not my english.

  5. #5
    Registered User
    Join Date
    Jan 2013
    Posts
    6

  6. #6
    Senior Wabbit
    Join Date
    Jul 2008
    Location
    Winchester, Uk
    Posts
    215
    From your other posts you said you had all the movieclips on another layer.
    Give each item an instance name of Bn where n is a number ie, B1, B2, B3

    You have a total of 6 items boxed, in your image so select each item and give it that as its instance name.

    Code:
    var naming:Array = new Array("square", "circle", "pentagon", "triange");
    Place the names of your items, ie the text you want to appear here.

    Change holder["B"+i].onRollOver = function () { to
    Code:
    ["B"+i].onRollOver = function () {
    Not really much more I can explain, I have written what every bit of code means.
    I have also explained what I did in detail.

    From the sounds of it your new to actionscript 2.0, it might be worth you learning the basics, if you are still have issues understanding.

    Trust my code, and not my english.

Tags for this Thread

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