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?
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;
Peter,
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.
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
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.
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
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.
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.
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.
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.MainTi meline::frame1:13]
I hoped that helped. It appears that the 'timeline' doesn't like something in the layers maybe?
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.
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
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
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
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
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?
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
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
North America
Europe, Middle East and Africa
Asia Pacific