View Full Version : attachMovie question
vicci
05-11-2004, 10:09 AM
Hi hi again
I have a little question:
I have create a first mc in which i use attachMovie to insert others mc on it. My first mc has action when we press on it. The others clips that i attach have also different actions. But these others clips dont function when i call them by a attachMovie, and i am wondering if it is normal. Can someone explain me? and how can i solve my problem in order to have functionnal mc attached?
avatar
05-11-2004, 10:28 AM
This is probably a pathing problem... Could you post an example of the AS and how you put it on the stage?
vicci
05-11-2004, 10:44 AM
That is the code on the button who attach the others mc to the first mc.
on (press) {
user = SharedObject.getLocal("infos", "/");
liste_xml = new XML();
liste_xml.ignoreWhite = true;
liste_xml.onLoad = function() {
noeuds = this.firstChild.childNodes;
for (var i = 0; i<noeuds.length; i++) {
lien = _root.carte02.carte.attachMovie(noeuds[i].attributes.ico, "mc"+i, i);
lien.ico = noeuds[i].attributes.ico;
lien._x = noeuds[i].attributes.posx;
lien._y = noeuds[i].attributes.posy; lien.adresse = noeuds[i].firstChild.nodeValue;
lien.modle = noeuds[i].attributes.modle;
lien.num = noeuds[i].attributes.num;
lien.onRelease = function() {
user.data.texte = this.num;
this.createEmptyMovieClip("support_mc", 50);
this.support_mc.loadMovie(this.modle);
};
}
};
liste_xml.load("param.xml");
}
I attach some small movieclips which are on my library to my main mc. Then i want that when we clik on it, it create a empty movieclip "support_mc" . But this function dont function becoz i load the small mc in my main mc and it as already a function press.
If it is confused, ask me to explain more or i will put the fla to dl if you need . Thanks a lot
avatar
05-11-2004, 11:11 AM
Let's see if I got the picture ;)
You wanna load an MC_2 into MC_1 by pressing on that MC_1?
Than you wanna be able to click on that MC_2, right?
vicci
05-11-2004, 11:44 AM
hmmm quite that ..;
I wanna load an MC_2 into MC_1 by pressing on that MC_3 ( a button)
Than I wanna be able to click on that MC_2.
The code i put was on the MC_3. when i press MC-3, it loads an MC_2 in MC_1.
But when i do that, i cant clik on the MC_2 and i dunno why..
avatar
05-11-2004, 02:36 PM
Mmm, could you put the code for that MC_2 in the thread please?
It loads correct but you can't click it... Should have something to do with the code on that MC
But this function dont function becoz i load the small mc in my main mc and it as already a function press.
Does this mean that MC_1 also has a press function?
vicci
05-12-2004, 03:06 AM
yes, there is a other press action on that Mc-1 . The code is a code to zoom on it.
on (press) {
myX = _xmouse;
myY = _ymouse;
newXscale = 200;
}
onClipEvent (enterFrame){
//if (_root.carte.width<1000) {
cXscale = this._xscale;
difXscale = cXscale-(newXscale);
setProperty(this, _xscale, cXscale-(difXscale/5));
setProperty(this, _yscale, cXscale-(difXscale/5));
cX = this._x;
cY = this._y;
difX = cX-(-myX*(newXscale/100));
difY = cY-(-myY*(newXscale/100));
setProperty(this, _x, cX-(difX/5));
setProperty(this, _y, cY-(difY/5));
//}
}
onClipEvent (load) {
myX = 0;
myY = 0;
newXscale = 100;
i = 20;
}
onClipEvent (keyUp) {
if (Key.getCode() == Key.UP) {
newXscale += i;
i += 20;
} else if (Key.getCode() == Key.DOWN && newXscale>1000) {
newXscale -= i;
i -= 20;
}
}
avatar
05-12-2004, 03:32 AM
try placing the on(press) in your onClipEvent(enterFrame) so you can add a condition
onClipEvent (enterFrame) {
if (this.your_button.hitTest(_root._xmouse, _root._ymouse, true)) {
this.onPress = function() {
trace("test");
};
} else {
this.onPress = function() {
myX = _xmouse;
myY = _ymouse;
newXscale = 200;
};
}
//if (_root.carte.width<1000) {
cXscale = this._xscale;
difXscale = cXscale-(newXscale);
setProperty(this, _xscale, cXscale-(difXscale/5));
setProperty(this, _yscale, cXscale-(difXscale/5));
cX = this._x;
cY = this._y;
difX = cX-(-myX*(newXscale/100));
difY = cY-(-myY*(newXscale/100));
setProperty(this, _x, cX-(difX/5));
setProperty(this, _y, cY-(difY/5));
//}
}
vicci
05-12-2004, 04:23 AM
Hmm iam trying to change it, but it dont function very well >_<
here is the file, if you can check it, it will be nice.
file (http://src.iut-troyes.univ-reims.fr/~src2e07/attachmovie_vicci.zip)
avatar
05-12-2004, 05:19 AM
check out the zip file...
when you wanna do that for every town this won't be the right solution.
in that case I would suggest to put the MC that triggers the zoom underneath the towns...
vicci
05-12-2004, 06:00 AM
oki thanks avatar.
Condition is a good solution for my pb.
But what iam looking for now is the syntax to tell that the hitTest is about the attached movie i made, coz i attach movie from xml file.
so when i create mc , i use
lien = _root.carte01.carte02.attachMovie(noeuds[i].attributes.ico, "mc"+i, i);
lien.ico = noeuds[i].attributes.ico;
vicci
05-12-2004, 06:07 AM
oki thanks a lot avater ^^
Condition was the good solution. iam trying with it. Iam more designer than programmer, so if you need help one day, ask me ^_-!
avatar
05-12-2004, 06:20 AM
I'am more designer than programmer
Me too ;) But it's just exciting to do a bit of both...
you can target the MC by using _root["String"+var] . Have look at advanced pathing in the tuts on this site...
vicci
05-12-2004, 07:37 AM
ok iam seeking on it, advanced pathing is veryusefull and i diddnt know that before.
So i have write something like that : my variable is called "lien"
onClipEvent (enterFrame) {
if (_root["lien"+i]).hitTest(_root._xmouse, _root._ymouse, true)) {
this.onPress = function() {
trace("test");
};
Iam right?
avatar
05-12-2004, 09:05 AM
Yep should work... in theorie :) but targetting movies can be a pain...
The MC you are checking for the hitTest is called something like : lien1 ?
vicci
05-12-2004, 09:20 AM
ya it is a pain >_< lol
the pb is that the mc i want to target has a name "lien" + i coz i create it like this :
------------as---------------
for (var i = 0; i<noeuds.length; i++) {
lien = _root.carte01.carte02.attachMovie(noeuds[i].attributes.ico, "mc"+i, i);
lien.ico = noeuds[i].attributes.ico;
lien._x = noeuds[i].attributes.posx;
lien._y = noeuds[i].attributes.posy;
etc
-----------
So, iam still seeking how to i can target it coz the code i put in my last post dont function lol
avatar
05-12-2004, 09:47 AM
in this for loop you are constantly replacing your var lien...
can't you use it like this?
for (var i = 0; i<noeuds.length; i++) {
_root.carte01.carte02.attachMovie(noeuds[i].attributes.ico, "mc"+i, i);
_root.carte01.carte02["mc"+i].ico = noeuds[i].attributes.ico;
_root.carte01.carte02["mc"+i]._x = noeuds[i].attributes.posx;
_root.carte01.carte02["mc"+i]._y = noeuds[i].attributes.posy;
}
vicci
05-12-2004, 10:06 AM
ok i will seek on that way, i will tell if i find something new. Thanks a lot for your help anyway ^^
avatar
05-12-2004, 10:29 AM
de rien ;)
|
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.