-
1. Re: How to cause a word appear when mouse click a object I created.
Peter Celuch Nov 16, 2011 1:02 PM (in response to a45williams)1 person found this helpfulYour "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;
-
2. Re: Re: How to cause a word appear when mouse click a object I created.
a45williams Nov 17, 2011 6:03 AM (in response to Peter Celuch)1 person found this helpfulPeter,
First of all, thank you for your email. Bare with me please I tried what you instructed me. What I did is use the word for the 'TextField' is called 'Process'. I replaced it with the word you used pc_word. I tested the scene and it didn't work and there were no compiler errors. Below is the action script of what I typed:
stop();
function playMovie(event:MouseEvent):void
{
play();
}
startButton.addEventListener(MouseEvent.CLICK,playMovie);
Process.visible=false;
Process.visible=true;
What am I doing wrong? If you have Skype my address is a45williams in Douala, Cameroon (Africa). Or if you have Yahoo the address is the same except the it is Yahoo IM. May be we can chat?
Thanks.
-
3. Re: Re: How to cause a word appear when mouse click a object I created.
Peter Celuch Nov 17, 2011 6:18 AM (in response to a45williams)1 person found this helpfulIf 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; }
-
4. Re: Re: How to cause a word appear when mouse click a object I created.
a45williams Nov 17, 2011 6:36 AM (in response to Peter Celuch)Peter,
I have 10 different fields that will have to have a new word including 'Process.' I could be my mistake that I grouped all of the 10 and I inserted a layer for that group. Do I have to change it?
The way you typed the action script looks different as far as the order, does that matter?
Alan
-
5. Re: Re: How to cause a word appear when mouse click a object I created.
Peter Celuch Nov 17, 2011 6:54 AM (in response 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.
-
6. Re: Re: How to cause a word appear when mouse click a object I created.
a45williams Nov 17, 2011 9:19 AM (in response to Peter Celuch)Peter,
Your a champ! It worked. Now I fully understand what you were trying to relay to me previous. I did get a error message from the 'Output', this is what it said "TypeError: Error #1034: Type Coercion failed: cannot convert flash.display::MovieClip@2c9ad81 to flash.text.TextField.
Debug session terminated."
I'm not using any movie clip for any of my buttons or text, I'm using dynamic text. Do you think I should just ignore it? I went and looked it up to see what the Adobe library to find some info, no avail.
Below is my action script:
stop();
function playMovie(event:MouseEvent):void
{
play();
}
startButton.addEventListener(MouseEvent.CLICK,playMovie);
import flash.events.Event;
btn_show.addEventListener(MouseEvent.CLICK, showText);
btn_hide.addEventListener(MouseEvent.CLICK, hideText);
function showText(event:Event):void {
Process.visible = true;
}
function hideText(event:Event):void {
Process.visible = false;
}
I hope I'm not invading your time, you've been a great help! :)
Alan
-
7. Re: Re: How to cause a word appear when mouse click a object I created.
Peter Celuch Nov 17, 2011 9:41 AM (in response 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.
-
8. Re: Re: How to cause a word appear when mouse click a object I created.
a45williams Nov 17, 2011 10:40 AM (in response to Peter Celuch)Peter,
I did what you instructed; enable debugging, then select 'OK' then I 'Published'. The error 1034 is still there. Also, when I start the scene with the button I created to (start movie), my text disappears. Then when the scene finishes, the text comes back. I would prefer that the text doesn't appear until I select btn_show. Does this have to do with layers, do I have to create one for each word? Will that complex things?
Thx.
-
9. Re: Re: How to cause a word appear when mouse click a object I created.
Peter Celuch Nov 17, 2011 10:43 AM (in response 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.
-
10. Re: Re: How to cause a word appear when mouse click a object I created.
a45williams Nov 17, 2011 11:00 AM (in response to Peter Celuch)Here it is,
TypeError: Error #1034: Type Coercion failed: cannot convert flash.display::MovieClip@28bea561 to flash.text.TextField.
I fixed the problem of the disappearance of the text and the buttons. I had to add layers to them (I should have known better). Above is the only error I receive from the output. However, when I play the scene all btns work, but when the scene is finished, the show and hide btns won't work unless I close the scene and start again.
Your right about the debugging after I enable it.
-
11. Re: Re: How to cause a word appear when mouse click a object I created.
Peter Celuch Nov 17, 2011 11:02 AM (in response 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.
-
12. Re: Re: How to cause a word appear when mouse click a object I created.
a45williams Nov 17, 2011 11:31 AM (in response to Peter Celuch)I check the whole text field in the output box, it keeps giving me the same error, until I select btn_hide then It generated this msg:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at Kairos2_Scene1_fla::MainTimeline/hideText()[Kairos2_Scene1_fla.MainTimeline::frame1:13]
I hoped that helped. It appears that the 'timeline' doesn't like something in the layers maybe?
-
13. Re: Re: How to cause a word appear when mouse click a object I created.
Peter Celuch Nov 17, 2011 11:37 AM (in response 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.
-
14. Re: Re: How to cause a word appear when mouse click a object I created.
a45williams Nov 18, 2011 4:16 AM (in response to Peter Celuch)Peter,
Good morning! I looked carefully as you instructed to look at your example. The 'Instance Name' is called Process, It has that name there in the properties. I'm stuck can you look at the program? See attachment. I'll keep working on it to see where I missed it.
Best,
Alan
-
15. Re: Re: How to cause a word appear when mouse click a object I created.
a45williams Nov 18, 2011 4:38 AM (in response to Peter Celuch)Pete,
I did notice last night that your btn_hide/show is a 'movie clip' type. I tried to change mine from button to movie clip and that didn't work either.
Best,
Alan
-
16. Re: Re: How to cause a word appear when mouse click a object I created.
Peter Celuch Nov 18, 2011 4:56 AM (in response 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.
-
17. Re: Re: How to cause a word appear when mouse click a object I created.
a45williams Nov 18, 2011 5:13 AM (in response to Peter Celuch)Your up early, at work right, I'm at least 7 or 8 hours ahead (not sure your time line).
I'm not sure what happened to the attachment, my nephew saw me upload it and sent it. O well, I'll try again.
Best
-
18. Re: Re: How to cause a word appear when mouse click a object I created.
a45williams Nov 18, 2011 6:24 AM (in response to Peter Celuch)Peter,
This is my first time to do share a file, with this type of method. It proves that I'm still 'behind-the-times'. lol :D
Here is the link, http://www.sendspace.com/file/bsunc2
I hope it'll work!
est,
Alan
-
19. Re: Re: How to cause a word appear when mouse click a object I created.
a45williams Nov 18, 2011 7:13 AM (in response to Peter Celuch)Peter,
I wasn't sure if you receive my link via Adobe forum that I replied back to you. Did you get it?
Alan
-
20. Re: Re: How to cause a word appear when mouse click a object I created.
Peter Celuch Nov 18, 2011 7:16 AM (in response 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
-
21. Re: Re: How to cause a word appear when mouse click a object I created.
a45williams Nov 18, 2011 7:46 AM (in response to Peter Celuch)Peter,
Thanks a bunch! No errors.
Forgive me for not being clearer enough, I want to have full control when I want the name to appear (that means when I'm ready to select the 'show' btn, then it will appear. Can I have control of the word to appear if I select the start btn or not (scene activated of course)? Right now it seems that both btn's doesn't work, while scene is activated. Any suggestions?
Best,
Alan
-
22. Re: Re: How to cause a word appear when mouse click a object I created.
a45williams Nov 18, 2011 8:12 AM (in response to Peter Celuch)Pete,
Never mind, I just took out the */ out of the action. Not it works exactly what I want. Thanks!!!
-
23. Re: Re: How to cause a word appear when mouse click a object I created.
Peter Celuch Nov 18, 2011 8:22 AM (in response to a45williams)You're welcome.
-
24. Re: Re: How to cause a word appear when mouse click a object I created.
a45williams Nov 18, 2011 8:37 AM (in response to Peter Celuch)Peter,
One more thing please... Once I start the scene, the word process appears without me selecting the show btn. What can I do to change that? I want to have full control of the word only when I select it regardless if I start the scene or not.
Best,
Alan
-
25. Re: Re: How to cause a word appear when mouse click a object I created.
Peter Celuch Nov 18, 2011 8:39 AM (in response to a45williams)Just put this code in the first frame:
Process.visible = false;
-
26. Re: Re: How to cause a word appear when mouse click a object I created.
a45williams Nov 18, 2011 9:35 AM (in response to Peter Celuch)Peter,
Thanks that worked. What is the program to implement a stop command buy using the same button of the start?
Best,
Alan
-
27. Re: Re: How to cause a word appear when mouse click a object I created.
Peter Celuch Nov 18, 2011 9:44 AM (in response 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; } }
-
28. Re: Re: How to cause a word appear when mouse click a object I created.
a45williams Nov 18, 2011 10:23 AM (in response to Peter Celuch)Pete,
Boolean seems it might do the trick. However something is mission, take a look at the error:
1087: Syntax error: extra characters found after end of program.
Here is what I put into the action:
Process.visible = false;
stop();
function playMovie(event:MouseEvent):void
{
play();
}
startButton.addEventListener(MouseEvent.CLICK,playMovie);
}
var paused:Boolean = false;
var myPauseFunction():void {
if(paused) {
play();
paused = false;
}
else {
stop();
paused = true;
}
}
import flash.events.Event;
btn_show.addEventListener(MouseEvent.CLICK, showText);
btn_hide.addEventListener(MouseEvent.CLICK, hideText);
function showText(event:Event):void {
Process.visible = true;
}
function hideText(event:Event):void {
Process.visible = false;
}
What's missing?
Alan
-
29. Re: Re: How to cause a word appear when mouse click a object I created.
Peter Celuch Nov 18, 2011 11:06 AM (in response 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?
-
30. Re: Re: How to cause a word appear when mouse click a object I created.
a45williams Nov 18, 2011 11:30 AM (in response to Peter Celuch)Peter, it didn't work, I sent you a link of the program for your view if that is OK. It is 'Kairos' not 'Kairos2'
http://www.sendspace.com/file/uxktud
Thanks.
Alan
-
31. Re: Re: How to cause a word appear when mouse click a object I created.
a45williams Nov 18, 2011 11:52 AM (in response to Peter Celuch)Peter,
I found the problem, it was line 10 in the action. I had '}' there, I took it out and it worked.
One more thing, now I'm working on a new work for the second gear (or circle). This is going to be very critical. In the action, I know I have to type every about the same for the process word, i.e.,
import flash.events.Event;
btn_show.addEventListener(MouseEvent.CLICK, showText);
btn_hide.addEventListener(MouseEvent.CLICK, hideText);
The question is do I have to add additional line called 'import flash.events.Event;' ? My next word will be called 'Cycles.'
I don't want to create a monster, if you know what I mean. lol.
Alan
-
32. Re: Re: How to cause a word appear when mouse click a object I created.
a45williams Nov 18, 2011 11:59 AM (in response to Peter Celuch)False alarm, it still didn't stop when I select the start button.