This content has been marked as final. Show 14 replies
I don't know what you mean by
// make sure home,about,... have name property = "home","about",... and use the correct type in the line below
Where do I find the name property. I have the instance names as home, about, services, etc etc.
How do I know what the correct type is?
their instance names will work. if they're movieclips, then use MovieClip as the type.
Excuse the newbie questions however what you wrote is way beyond my knowledge so I am having minor difficultly when reading it.
I receive an error when I compile.
1180: Call to a possibly undefined method getInstanceByName.
Am I supposed to change that to something?
Is that what I am supposed to put as a movieclip?
var getInstanceByName:MovieClip = new MovieClip();
I do have the buttons as MovieClips
The name of the movie clip is buttonMC
I have also changed the instance names instead of homebutton, servicesbutton, etc etc. I changed them to just home, services and removed the word "button". I also changed this in the array in your code to follow suit.
I am still at a loss of what exactly in the code I change to MovieClip. I have attempted to read it multiple times to find out and I am presuming it is where that * is that I change that to MovieClip. Now, do I have to add anything else such as a reference to buttonMC?
oops, my bad. that should be: getChildByName();
p.s. what's the point of creating those sprites?
I received the following error with that code:
1118: Implicit coercion of a value with static type flash.display:DisplayObject to a possibly unrelated type flash.display:MovieClip.
The error is coming from the following line:
var childButton:MovieClip = tl.getChildByName(buttonA );
I think it is because buttonA is a Sprite and not a MC. I should be able to add some line and recast it as a MC or even start it as an MC. I don't know if that will work but I will try it. If you know what is wrong and can point me in the correct direction, that would be wonderful.
In the question is the answer. I am guessing they were not needed. When learning this, you read so many posts and tutorials on the Internet and one of them said to use sprites because this reason and that reason. That is why they were there.
Should they be something else or are they just not needed at all?
you don't need to recast it. just type it as a sprite.
I typed in the following and received the following error:
1118: Implicit coercion of a value with static type flash.display:DisplayObject to a possibly unrelated type flash.display:Sprite.
What did I need to type as a sprite?
that error message wouldn't be generated if childButton were a sprite. how did you create those "sprites" that are on-stage?
I have the fla file posted in another forum that I asked help for and someone asked me to post it but never replied back after I did.
Here is the link. This will probably answer some of your questions better than I can.
The fla file will have my working code in it. I took this same file which has my code in it and replaced it with your code.
Hope that helps.
I also added some more code as well just in case this matters.
I plan on adding a script in there that detects what webpage you are on from FlashVars. I have this working already however it is not in that fla file.
You can see an example here:
Flash Vars Example
I am using a PHP page to detect the webpage. I am storing that into a FlashVar and passing that Flash. I am then using that information to see what webpage we are currently on and placing the corresponding button into a down position.
Here is that PHP and AS3 code as well if you need it. (I don't know that you will but just in case).
you have a typo: service should be services. and you have no need of all that stuff about sprites.
and the flash compiler needs help realizing your display objects are movieclips:
It works however there is a slight error. I will check it out.
Nevermind, the error is on my end. I change the labels and put them on the wrong frame numbers.
That works fantastic.
That is what I thought of originally was a for statment and an array however I didn't know that the array.length would count each array item as 1.
I was asking for a for statement or something that I could work with.
Thank you kglad for all of the help. Your AS3 ability astounds me. Phenomenal!
WOW.. that code is cut down extremely well. I can read everything except for this line:
var childButton:MovieClip = MovieClip(tl.getChildByName(buttonA ));
What does that line mean
We create a variable called childButton. We assign that variable as a MC and then we equal that to (I am lost).