View Full Version : Loading a Dynamic Image
kippwinger
12-17-2002, 02:41 PM
I am creating an ad dynamically... It will have 3 pictures and 3 text fields. So far, I call the text from external text files. I am trying to call the pictures the same way. I realize you can't load pictures into dynamic text fields. I have tried other ways.
This has been a big pain. If anyone could help me that would be fantastic.
Here is what I have so far:
http://www.primordialworld.com/pm/temp/ad-beta2.html
I included the source file....
Welcome to FlashMove kippwinger,
You idea is completely possible. Here how you want to go about it.
Create a MovieClip containing a Dynamic TextField and a empty MovieClip.
Name the TextField "content"
Name the MovieClip "image_targ" (which stands for 'Image Target')
Now this is the simpliest explanation... so I won't try to take this over board.
If possible compile all the External Text Files to one Text File. So that we can work with one LoadVars Object. Use an uncommon markup or seperator to seperate the three seperate ads. (XML would be generally better in this case)
&ad_data=buy me~http://yourserver.com/image/image1.jpg|no buy me~http://yourserver.com/image/image2.jpg|buy me and I'll be your bestfriend~http://yourserver.com/image/image3.jpg
Now the ActionScript...
ad_space._visible = 0; // Hide Orginal Space
ad_load = new LoadVars();
ad_load.onLoad = function (success) {
if(success) {
this.ad_data = this.ad_data.split("|"); // Break out Flat Data
for (var i=0; i<this.ad_data.length; i++) { // Loop through Data Array
this.ad_data[i] = this.ad_data[i].split("~"); // Break to Multidemonsional Array
duplicateMovieClip("ad_space", "ad_space"+i, i+400); // Create a new from the Orginal
trace(_root["ad_space"+i]._name);
_root["ad_space"+i]._x = /* Starting Position - */0 +
/* Loop Sequence Postion - */i *
/* Set Next Postion - */(_root["ad_space"+i]._width+10);
_root["ad_space"+i].content.text = this.ad_data[i][0]; // Set Content Text
_root["ad_space"+i].content.wordWrap = true; // Enable Word Wrap
_root["ad_space"+i].content.autoSize = "left"; // Enable TextField Auto Size
_root["ad_space"+i].image_targ.loadMovie(this.ad_data[i][1]);
}
}
}
ad_load.load("ad_data.txt"); // Load Text File
kippwinger
12-18-2002, 09:03 PM
Thank you, Thank you, Thank you.... It took explaining it like I'm a newbie for me to get it. I have posted this question on several Message Boards and finally I get it...
Thanks again
vBulletin v3.5, Copyright ©2000-2010, Jelsoft Enterprises Ltd.