wyclef
October 25, 2003, 4:55am
1
Hi, how can i have an array of strings but also with mc identifiers in the same array and have it know the difference between object and string?
RIght now i’ve got this array of strings that goes to a textfield, and if i change it to
[AS]
portfolioSection([“section 01”, “section 02”, {linkage: “linkage_id”, x: 530, y: 280}, “section 04”, “section 05”]);
this.attachMovie(portfolioSection[2].linkage)[/AS]
to try and attach an MC instead of text in a textfield i just get [object object] in the text field.
system
October 25, 2003, 1:18pm
2
I’m not quite sure what you’re trying to accomplish, but you need 3 or 4 parameters for attachMovie:
myMovieClip.attachMovie(idName, newName, depth [, initObject] )
What text field are you talking about that gets [object object]?
It’d help a lot if you posted you .fla file so we can see what you’re doing in more detail.
system
October 25, 2003, 3:54pm
3
How can you possibly load a movieclip inside a textfield? :h:
system
October 25, 2003, 6:02pm
4
You’re not loading an MC into a textfield. Look at this fla. Click forward three times in the swf to see the [object Object]. I’m exporting the MC linkage_id as actionscript.
system
October 25, 2003, 6:40pm
5
That’s because you have this line
[AS]
section_txt.text = aSectionTxt[iSectionIndex]
[/AS]
in your setSectionText routine.
When you get to section 3, the third element in aSectionTxt isn’t a String. It’s an object with three properties: linkage, x and y.
A workaround could be to test the type of the current element like this:
[AS]
if (typeof aSectionTxt[iSectionIndex] == “string”) {
section_txt.text = aSectionTxt[iSectionIndex];
}
else {
section_txt.text = aSectionTxt[iSectionIndex].linkage;
}
[/AS]
That’ll test if the element is a string or not. If it’s a string it takes the element and puts it into section_txt. If it isn’t a string it assumes that it’s an object with a ‘linkage’ property and assigns that instead.
Hope that helps.
system
October 25, 2003, 11:10pm
6
So how would that look in this part?
[AS]
setSectionText = function (dir) {
if (dir != undefined) {
iSectionIndex += dir;
}
section_txt.text = aSectionTxt[iSectionIndex];
};
[/AS]
like this?
[AS]
setSectionText = function (dir) {
if (dir != undefined) {
iSectionIndex += dir;
}
if (typeof aSectionTxt[iSectionIndex] == “string”) {
section_txt.text = aSectionTxt[iSectionIndex];
}
else {
section_txt.text = aSectionTxt[iSectionIndex].linkage;
}
[/AS]
system
October 26, 2003, 12:54am
7
That’s the part I was talking about. So yes, that’s how it would look…