nk94555
asked on
Creating and attaching dynamic movieclip to scrollpane
Hi,
I am trying to create movie clip on fly at run time and load it in a scrollpane. I have a basic movieclip "nk" which consists of an image area and text field. After getting the data from DB, I want to create a main blank movie clip which will have duplicate movie instances of "nk" (it is in library) with different images and text. After creating the main movie clips, I want to attach it to scrollpane. here is the sample code which I am using:
========
_root.createEmptyMovieClip ("myscroll ",0);
for (i=0; i<5; i++){
myMovie = "myMovie" + (i);
_root.myscroll.createEmpty MovieClip( myMovie,i) ;
var x = i + 5;
var mc = _root.myscroll[myMovie].at tachMovie( "nk", "NK", i);
mc._y = 100 * (i+1) + 20 * i;
// mc._x = 135;
}
myScrollPane.setScrollCont ent(_root. myscroll);
myScrollPane.refreshPane() ;
====================
After attaching "myscroll" to scrollpane, it shows image only for the first nested clip. It shows the text for all clips but text goes out of bound of scrollpane. It appears the images are not visible except the first one. I want:
1. To display image for all the clips and
2. to keep the text within the component which should appear on scrolling.
Thanx in advance for your help.
NK
I am trying to create movie clip on fly at run time and load it in a scrollpane. I have a basic movieclip "nk" which consists of an image area and text field. After getting the data from DB, I want to create a main blank movie clip which will have duplicate movie instances of "nk" (it is in library) with different images and text. After creating the main movie clips, I want to attach it to scrollpane. here is the sample code which I am using:
========
_root.createEmptyMovieClip
for (i=0; i<5; i++){
myMovie = "myMovie" + (i);
_root.myscroll.createEmpty
var x = i + 5;
var mc = _root.myscroll[myMovie].at
mc._y = 100 * (i+1) + 20 * i;
// mc._x = 135;
}
myScrollPane.setScrollCont
myScrollPane.refreshPane()
====================
After attaching "myscroll" to scrollpane, it shows image only for the first nested clip. It shows the text for all clips but text goes out of bound of scrollpane. It appears the images are not visible except the first one. I want:
1. To display image for all the clips and
2. to keep the text within the component which should appear on scrolling.
Thanx in advance for your help.
NK
ASKER
Hi,
I tried the similar thing earlier but it has the same effect. I can email you fla file if that helps.
Thanx,
I tried the similar thing earlier but it has the same effect. I can email you fla file if that helps.
Thanx,
it is better if you post it on a public server (due to EE guidelines)
ASKER
Hi,
That is difficult, i don't have access to any public server. email is the best way.
That is difficult, i don't have access to any public server. email is the best way.
ok, try this: http://www.negatyve.com/EE/pane.zip
ASKER
Hi Negatyve,
Thanx for creating the fla. Yes it works fine and I also figured out the problem in my fla. I have defined the textfield "nk" as dynamic field while in your case it is static. If you change it to Dynamic you will see the problem.
I need to keep it dynamic because I will fill these text values from database. One more thing I also need to keep a movie clip area in these clips where I will fill the corresponding images from our server. Project is to get 50 images and corresponding text from server and set them in three columns & rows and attach it to scrollpane. It will be set like 50 boxes containing images and text under the image. Can you please help me to make it work.
Thanx again, I really appreciate it.
NK.
Thanx for creating the fla. Yes it works fine and I also figured out the problem in my fla. I have defined the textfield "nk" as dynamic field while in your case it is static. If you change it to Dynamic you will see the problem.
I need to keep it dynamic because I will fill these text values from database. One more thing I also need to keep a movie clip area in these clips where I will fill the corresponding images from our server. Project is to get 50 images and corresponding text from server and set them in three columns & rows and attach it to scrollpane. It will be set like 50 boxes containing images and text under the image. Can you please help me to make it work.
Thanx again, I really appreciate it.
NK.
I have changed the text to dynamic textfield, with instance name "try_txt", then changed the script to:
myScrollPane.setScrollCont ent("myscr oll");
var sp = myScrollPane.getScrollCont ent();
test = ["pippo", "minnie", "Pluto", "Gamba", "ciccio"]
for (var i = 0; i < 5; i++){
var myMovie = "myMovie" + i;
var nc = sp.createEmptyMovieClip(my Movie, i);
var mc = nc.attachMovie("nk", "NK", i);
mc._y = 100 * (i+1) + 20 * i;
mc.try_txt.autoSize = true;
mc.try_txt.text = test [i];
// mc._x = 135;
}
myScrollPane.refreshPane() ;
it works fine..
myScrollPane.setScrollCont
var sp = myScrollPane.getScrollCont
test = ["pippo", "minnie", "Pluto", "Gamba", "ciccio"]
for (var i = 0; i < 5; i++){
var myMovie = "myMovie" + i;
var nc = sp.createEmptyMovieClip(my
var mc = nc.attachMovie("nk", "NK", i);
mc._y = 100 * (i+1) + 20 * i;
mc.try_txt.autoSize = true;
mc.try_txt.text = test [i];
// mc._x = 135;
}
myScrollPane.refreshPane()
it works fine..
ASKER
Hi,
I tried this but didn't woek. I copied the complete code above. I have found an alternate way of doing this. It goes like this:
=========================
mytextfield = "mytextfield" + (i)
mc.createTextField(mytextf ield,i,-75 ,-5,150,40 );
//THIS IS KEY FIX HERE - THE NEXT LINE
mc[mytextfield].embedFonts = true;
mc[mytextfield].setNewText Format(myT extFormat) ;
mc[mytextfield].textColor = 0x0000FF;
var newtxtformat = mc[mytextfield].getNewText Format();
newtxtformat.size = 10;
newtxtformat.underline = true;
newtxtformat.align = "center";
newtxtformat.html = true;
mc[mytextfield].setNewText Format(new txtformat) ;
mc[mytextfield].Text = "NK" + i;
==================
The key here is the embedFonts set to true works fine the way I want it to work. But your approach looks simple, if it is working fine at your end, then send me your flas and I will give it a try.
One side issue, I want to use property mc[mttextfield].htmlText = "<i>NK</i>"; but it is not working, it displays the plain text instead of HTML. I have set teh html property true in above line. Do you know why it is doing it and how to make it work.
Thanx.
I tried this but didn't woek. I copied the complete code above. I have found an alternate way of doing this. It goes like this:
=========================
mytextfield = "mytextfield" + (i)
mc.createTextField(mytextf
//THIS IS KEY FIX HERE - THE NEXT LINE
mc[mytextfield].embedFonts
mc[mytextfield].setNewText
mc[mytextfield].textColor = 0x0000FF;
var newtxtformat = mc[mytextfield].getNewText
newtxtformat.size = 10;
newtxtformat.underline = true;
newtxtformat.align = "center";
newtxtformat.html = true;
mc[mytextfield].setNewText
mc[mytextfield].Text = "NK" + i;
==================
The key here is the embedFonts set to true works fine the way I want it to work. But your approach looks simple, if it is working fine at your end, then send me your flas and I will give it a try.
One side issue, I want to use property mc[mttextfield].htmlText = "<i>NK</i>"; but it is not working, it displays the plain text instead of HTML. I have set teh html property true in above line. Do you know why it is doing it and how to make it work.
Thanx.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
• create an empty movieclip in the library
• give it a linkage, for example "myscroll"
• change your script to:
====================
myScrollPane.setScrollCont
var sp = myScrollPane.getScrollCont
for (var i = 0; i < 5; i++){
var myMovie = "myMovie" + i;
var nc = sp.createEmptyMovieClip(my
var mc = nc.attachMovie("nk", "NK", i);
mc._y = 100 * (i+1) + 20 * i;
// mc._x = 135;
}
myScrollPane.refreshPane()
====================