Skip navigation
a45williams
Currently Being Moderated

Re: How to cause a word appear when mouse click a object I created.

Nov 16, 2011 12:56 PM

I'm a new beginner, the software I have is Adobe fl CS4.  I succussfully created a scene with all correct layers including a start button action script.  No errors works great. Now my next challenge is, how do I cause a word to apear?  I created some objects that I want to select and cause a word to appear and color to change, once I hover over the object.  It is like the same method when you create a 'start button.'  Do I create another sub scene in the action script command?

 
Replies
  • Peter Celuch
    505 posts
    Nov 17, 2005
    Currently Being Moderated
    Nov 16, 2011 1:02 PM   in reply to a45williams

    Your "word" should be a TextField on the stage. If you don't need to change its contents during runtime, you can make it Static TextField.

    Select the TextField, press F8 to create a MovieClip symbol.

    Give this symbol on the stage a name, let's say mc_word.

    Then in actionscript, hide it with: mc_word.visible = false;

    And if you wish to show it, in mouse click handler function, write: mc_word.visible = true;

     
    |
    Mark as:
  • Peter Celuch
    505 posts
    Nov 17, 2005
    Currently Being Moderated
    Nov 17, 2011 6:18 AM   in reply to a45williams

    If your textfield on the stage has name "Process", this piece of code should work.

     

    stop();
    Process.visible=false;
     
    startButton.addEventListener(MouseEvent.CLICK,playMovie);
     
    function playMovie(event:MouseEvent):void
    {
         play();
         Process.visible=true;
    }
    
     
    |
    Mark as:
  • Peter Celuch
    505 posts
    Nov 17, 2005
    Currently Being Moderated
    Nov 17, 2011 6:54 AM   in reply to a45williams

    You don't address object in code by "what they contain", you use instance names.

    I created a simple example for you: http://dev.flashlabs.eu/examples/visibility/

    Download the source and take your time to study and understand it.

     
    |
    Mark as:
  • Peter Celuch
    505 posts
    Nov 17, 2005
    Currently Being Moderated
    Nov 17, 2011 9:41 AM   in reply to a45williams

    You should not ignore the error (and also you can't). However, the code you pasted does not contain problematic piece of code that's generating the error.

    To locate the error line, enable Permit debugging in Publish settings.

     
    |
    Mark as:
  • Peter Celuch
    505 posts
    Nov 17, 2005
    Currently Being Moderated
    Nov 17, 2011 10:43 AM   in reply to a45williams

    With an error present, you can't expect flashplayer to execute normally. When you fix all errors, then you fix other behaviour. Permit debugging wasn't supposed to magicaly fix the error, just provide more information about the error so you can fix it. Paste me the whole output with the error.

     
    |
    Mark as:
  • Peter Celuch
    505 posts
    Nov 17, 2005
    Currently Being Moderated
    Nov 17, 2011 11:02 AM   in reply to a45williams

    Underneath this line, there must be more - there's an information which function, which line generated the error. Copy the whole output panel content.

     
    |
    Mark as:
  • Peter Celuch
    505 posts
    Nov 17, 2005
    Currently Being Moderated
    Nov 17, 2011 11:37 AM   in reply to a45williams

    Nice! We're getting somewhere. You told me you get an error 1034 which is code for "Implicit coertion..." - nevermind. Now this error you pasted says that on the main timeline, in 1st frame at line 13, you try to address a property of a reference that is null (points nowhere, doesn't exist).

     

    The line is:

     

    Process.visible = true;
    

     

    This means that there is no item on the stage with instance name Process. Take a look at example I created and look carefully. Read the instructions I wrote for you in the example.

     
    |
    Mark as:
  • Peter Celuch
    505 posts
    Nov 17, 2005
    Currently Being Moderated
    Nov 18, 2011 4:56 AM   in reply to a45williams

    It doesn't matter if the button is movieclip or button type. I don't see any attachment.

    Send me the project file, use some file sharing service.

     
    |
    Mark as:
  • Peter Celuch
    505 posts
    Nov 17, 2005
    Currently Being Moderated
    Nov 18, 2011 7:16 AM   in reply to a45williams

    You had two different objects called Process. Once it was a textfield, which is what you want. The other object was the first gear and it was movieclip. I removed the instance name from the gear.

    Also you just copied my code... and since I worked with my buttons (btn_show, btn_hide), the did no good in your file because you don't have those buttons...

    Anyway, I put the Process.visible = false; into your playMovie method so the textfield hides when your animation starts.

     

    You can download it here: http://files.flashlabs.eu/kairos.zip

     
    |
    Mark as:
  • Peter Celuch
    505 posts
    Nov 17, 2005
    Currently Being Moderated
    Nov 18, 2011 8:22 AM   in reply to a45williams

    You're welcome.

     
    |
    Mark as:
  • Peter Celuch
    505 posts
    Nov 17, 2005
    Currently Being Moderated
    Nov 18, 2011 8:39 AM   in reply to a45williams

    Just put this code in the first frame:

     

    Process.visible = false;
    

     
    |
    Mark as:
  • Peter Celuch
    505 posts
    Nov 17, 2005
    Currently Being Moderated
    Nov 18, 2011 9:44 AM   in reply to a45williams

    You can use the same function by adding a boolean variable:

     

    var paused:Boolean = false;
    var myPauseFunction():void {
         if(paused) {
              play();
              paused = false;
         }
         else {
              stop();
              paused = true;
         }
    }
    
     
    |
    Mark as:
  • Peter Celuch
    505 posts
    Nov 17, 2005
    Currently Being Moderated
    Nov 18, 2011 11:06 AM   in reply to a45williams

    not

     

    var myPauseFunction():void {
    

     

    but

     

    function myPauseFunction():void {
    

     

    also this line

     

    startButton.addEventListener(MouseEvent.CLICK,playMovie);
     
    }
    

     

    should be only

     

    startButton.addEventListener(MouseEvent.CLICK,playMovie);
    

     

    ... and stop just pastnig what I give you and start reading and thinking

    I gave you a sample pause function. instead of just pasting it jou should look at it ant figure that probably you would like to call the function on startbutton click... right?

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points