-
Hi,
I have two movie clips in my movie. One named Greenland and other named canada. In the Object Actions of each of this clip I have written code like below
onClipEvent (mouseDown) {
setProperty("_root.showdetails",_visible,true);
_root.showdetails.countryname = "Greenland"
}
and
onClipEvent (mouseDown) {
setProperty ("_root.showdetails", _visible, true);
_root.showdetails.countryname = "Canada";
_root.showdetails._y = _root.canada._y + 10;
}
respectively for greenland and canada.
There is also another movie clip called showdetails in the movie.
The problem is no matter what I click, both Greenland and Canada only shows canada. Is there something wrong in where I wrote these above codes?? Please help.
Thanks in advance
-r-
-
Hi...with "onClipEvent(mouseDown)" it detects a mouseclick anywhere on the stage.....so, you need to use "hitTest()" to designate a certain area.....
Code:
onClipEvent (mouseDown) {
if (hitTest(_root._xmouse, _root._ymouse)) {
_root.showdetails._visible = true;
_root.showdetails.countryname = "Greenland";
}
}
...setProperty is Flash4 syntax, but is still perfectly acceptable....above is another way to say the same thing using Flash5 dot syntax.....and if you want to save some typing you could also say it like this....
Code:
onClipEvent (mouseDown) {
if (hitTest(_root._xmouse, _root._ymouse)) {
with (_root.showdetails) {
_visible = true;
countryname = "Canada";
_y = _root.canada._y + 10;
}
}
}
...you also mentioned you had another mc named "showdetails"...you should always give your movieClips unique instance names....naming them the same will inevitably lead to problems....
-pigghost-
-
Hi,
Great code of hitTest. But I have a problem while implementing. I put the code of hitTest in both movie clips. Out of that only the second one works. When I take out the second, the code in the first code of movie clips works!! what shall i do??
Thanks
-r-
-
Hmmm...well, not sure...I tested the code with two mc's and it worked fine.....I would probably need to see your .fla to tell you for sure what is wrong....
If it's not terribly huge, you can send it to me and I'll take a look.....
pigghost@hotgreen3.com
-pigghost-
-
Hi.....I got your .fla...but when I tried sending it back it came back undelivered...a couple of times...not sure what's going on with that...but I think I can talk you through it.....
Anyway, if you're planning on this for every country, this code will save you alot of typing....put this on your main timeline.....
Code:
MovieClip.prototype.nameCountry = function(arg) {
if (hitTest(_root._xmouse, _root._ymouse, true)) {
_root.showdetails._visible = true;
_root.showdetails.countryname = arg;
}
}
...this could be more dynamic but I'm not totally sure what your overall plan is.....so for now this will allow you to show the names easily.....
Now on your movieClips, you just need to put this.....on the 'canada' movieClip put this...
Code:
onClipEvent (mouseDown) {
nameCountry("Canada");
}
...on the 'greenland' clip you would have this...
Code:
onClipEvent (mouseDown) {
nameCountry("Greenland");
}
...on the 'australia' clip...
Code:
onClipEvent (mouseDown) {
nameCountry("Australia");
}
...and so on...so you just have to pass the name of the country to the prototype function....
That's it....
hope this helps...
-pigghost-
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|