FORUMS: list search recent posts

Load images into MC

COW Forums : Adobe Flash

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
RustyMC
Load images into MC
on Jan 29, 2006 at 12:25:16 am

Hello, I


Return to posts index

lajoiet
Re: Load images into MC’s with XML ??
on Jan 29, 2006 at 2:41:47 am

Do you already have the 10 different movie clips on your timeline and you just want to load the images into them? If so that's rather easy to explain. Assuming that they are called "holder1" "holder2" "holder3"... "holder10" and you are using Lee's XML Slideshow code more or less, just modify the x.onLoad function as such:

x.onLoad = function() {
var photos:Array = this.firstChild.childNodes;
for (i=0;i urls.push(photos[i].attributes.url);
target_MC = "holder" + i;
target_MC.loadMovie(urls[i]);
}
}


Now this requires that you be able to increment the name of the holder movie clip, and I assumed that you weren't using the caption field as in Lee's tutorial. If you didn't have the holder movie clips already on the stage, it would even be easier to dynamically create the empty movie clips for holders within the for loop, but you would then also need to set their positons in the loop also, and if it were me doing it I would also create fields in the XML that held the coordinates for the positions you wanted each image to be in.


Return to posts index

RustyMC
Re: Load images into MC
on Jan 29, 2006 at 9:57:33 pm

Ok wow


Return to posts index


lajoiet
Re: Load images into MC’s with XML ??
on Jan 30, 2006 at 1:33:58 am

Ooops. the line:

target_MC = "holder" + i;

should have been:

target_MC = eval("holder" + i);

If you can get the target_MC working, and expand it to include the scale function from Drag/Slide/Fade, you should be able to reduce the amount of repetitive code:

import com.dragslidefade.*;

var x:XML = new XML();
x.ignoreWhite = true;

var urls:Array = new Array();

x.load("top10images.xml");

x.onLoad = function() {
var photos:Array = this.firstChild.childNodes;
for (i=0;i(lessthan)photos.length;i++) { //note - replace (lessthan) with proper symbol, won't display here
urls.push(photos[i].attributes.url);
id_num = i+1; // this is so you get 1-10 rather than 0-9 added to "holder"
target_MC = eval("holder" + id_num);
target_S = eval("s" + id_num);
target_MC.loadMovie(urls[i]);
var target_S:Scale = new Scale(target_MC,1);

target_MC.onRollOver = function() {
target_S.scaleClipTo(110,5);
}

target_MC.onRollOut = function() {
target_S.scaleClipTo(100,5);
}

target_MC.onRelease = function() {
video.videoListMC.videoList.selectedIndex = i;
video.videoPlayer.ns.play(video.videoListMC.videoList.getItemAt(video.videoListMC.videoList.selectedIndex).data);
}

}
}


Return to posts index

RustyMC
Re: Load images into MC
on Jan 30, 2006 at 3:48:25 am

Good new is I totally understand what the code should be doing!

Bad news is it's a beast to debug :(

It looks like the target_MC is working; all the images get loaded into the MC on the timeline. However the target_S is not doing what I think is should. I traced target_S and I get this in the output window [object Object]

Also if I put the trace any other place other that under the var target_S:Scale = new Scale(target_MC,1); it returns undefined in the output window which I find weird also.




Return to posts index

lajoiet
Re: Load images into MC’s with XML ??
on Jan 30, 2006 at 5:34:57 pm

Yea, I'm not totally clear on the whole concept of creating code in the for loop, I've only ever done it using the attachMovie method where you create the onRollover/etc when you attach the movie. Here is the code from that, and I know it works. This would eliminate your need to have the holders already on your stage, since they are created dynamically, you just need to have 1 movie clip (named "b" in my example, in the library but not on the stage) with a holder box in it (named "img" in my example) and you would have to set their positions when they are created also. In my case I was adding a series of thumbnails that were all 100px square, so it was a simple matter of incrementing the _x value by 105 in each loop. The onRelease function loads the full size image into a holder movie clip already on the stage called "holder":

var thumbX:Number = 0;
for (i=1;i<143;i++) {
var t = panel.attachMovie("b","b"+i,i);
t.img.loadMovie("thumbnails/thumb"+i+".jpg", buttonHolderMC);
t._y = 0;
t._x = thumbX;
t.imageID = "images/image"+i+".jpg";
t._alpha = 75;
thumbX += 105;
t.onRollOver = function () {
this._alpha = 100;
}
t.onRollOut = function () {
this._alpha = 75;
}
t.onPress = function () {
this._rotation += 3;
this._x += 3;
this._y -= 3;
}
t.onReleaseOutside = function () {
this._rotation -= 3;
this._x -= 3;
this._y += 3;
this._alpha = 75;
}
t.onRelease = function () {
this._rotation -= 3;
this._x -= 3;
this._y += 3;
this._alpha = 75;
holder.loadMovie(this.imageID);
}
}

You can see it working here:

http://home.comcast.net/~tlajoie/bognoho/bognoho.html


Return to posts index


RustyMC
Re: Load images into MC
on Feb 4, 2006 at 10:04:48 pm

Nice! That's cool, the only problem I have is my images aren


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 CreativeCOW.net All Rights Reserved
[TOP]