Step 1: Create Movieclip Title which needs to be added dynamically into
Scrollpane. Make sure you have checked “Export for Actionscript”. This will
automatically create Class name “Title”
Step2 : Inside Title Movie clip , insert texttool and an Image. Convert that
image to symbol and give instance name “Ico”
Instance name for TextTool is TxtValue
Step 3: Insert ScrollPane in Scene1 and give instance name MainScroll
Step 4 : Paste the code below in scene1 actionscript panel.
var S:MovieClip=new MovieClip() // Create empty movieClipMainScroll.source=S // Assign empty movieclip to the scrollpane. It is mandatory to assign empty movie clicp to scrollpane before you do anything dynamically with scrollpanefor(var i=0;i<5;i++) // Constructing a loop to create 5 movieclips dynamically { var T:Title=new Title() // Create the MovieClip (Title) and assign it to the variable T T.y=i*30 // Set y axis value for the T function GetID(e:Event) |
Output
Codes Explanation
MainScroll.source=SAssign empty movieclip to the scrollpane. It is mandatory to assign empty movie clicp to scrollpane before you do anything dynamically with scrollpaneMovieClip(MainScroll.content).addChildAt(T,i) addChild will be used when u add anything to the movieclip. So here the scrollpane content needs to be treated as Movieclip , So MovieClip(MainScroll.Content) will be treated as Movieclip |