查看: 1419|回复: 22
|
谁来救救我。。。dynamic image (xml generate path)
[复制链接]
|
|
有谁知道怎么写 --〉
我有一些图片再server,需要用xml call出来,然后再排好,就好像friendster得小图片,一个一个的排成几排
谢谢
[ 本帖最后由 xiao_yee 于 28-3-2007 06:47 PM 编辑 ] |
|
|
|
|
|
|
|
发表于 15-3-2007 10:13 PM
|
显示全部楼层
你應該嘗試自己去翻翻寫寫, 或搜索一些之前的帖子.
不成功的話才把你的代碼貼出來, 而不是不勞而獲的伸手要 |
|
|
|
|
|
|
|

楼主 |
发表于 16-3-2007 09:41 AM
|
显示全部楼层
被骂了
其实是有script的,没贴上来而已
var distanceX:Number = 5;
var distanceY:Number = 5;
var minimumDist:Number = 50;
var reduce:Number = 80;
var augment:Number = 100;
var vel:Number = 3;
var distance:Number = minimumDist-80
var indexThumb:String = "http://192.168.123.86/test/slideshow/images/80/
(这个是直接连接去那个server,但是如先连接去xml就不能走了)
thumbPic = 10;
//////////////////////////////////////////////////////////////////////////////////////////////
var r:Number;
var percent:Number;
var diff:Number;
///////////////////////////////////////////////////////
MovieClip.prototype.elastic = function(x_ini, y_ini,profonditaIniziale,locate) {
this.onEnterFrame = function() {
var x_mouse:Number = _xmouse;
var y_mouse:Number = _ymouse;
r = Math.sqrt(Math.pow((x_mouse-x_ini), 2)+Math.pow((y_mouse-y_ini), 2));
if (r<minimumDist) {
percent = (100*r)/minimumDist;
diff = augment-percent;
this._xscale = reduce+diff;
this._yscale = reduce+diff;
if (r<distance){
this.swapDepths (100);
}
} else {
this._xscale += (reduce-this._xscale)/vel;
this._yscale += (reduce-this._yscale)/vel;
this.swapDepths (profonditaIniziale)
}
};
};
//////////////////////////////////////////////////////////////////////////////////////////////
var loadImage:MovieClipLoader = new MovieClipLoader;
for (i=0; i<=thumbPic; i++) {
picture.duplicateMovieClip("picture"+i, i);
}
locate = 1;
var riposX:Number = (picture._width*reduce)/100;
var riposY:Number = (picture._height*reduce)/100;
distanceX += riposX;
distanceY += riposY;
for (x=0; x<=18; x++) {
for (y=0; y<=1; y++) {
this["picture"+locate]._x = (riposX+x*distanceX);
this["picture"+locate]._y = (riposY+y*distanceY);
this["picture"+locate].elastic(this["picture"+locate]._x, this["picture"+locate]._y,this["picture"+locate].getDepth(),locate);
loadImage.loadClip(indexThumb + locate + ".jpg",this["picture"+locate].sost);
locate += 1;
}
}
picture._visible = false; |
|
|
|
|
|
|
|
发表于 16-3-2007 10:31 PM
|
显示全部楼层
你的程式碼沒什麼大問題, 只是你要確定圖片路徑是否存在啊.
"http://192.168.123.86/test/slideshow/images/80/"
而且你說的xml文件沒看到有讀取?
再來就是儘量優化你的elastricity寫法, 不要在沒event的時候也執行onEnterFrame, 改用onRollOver和onRollOut去觸發.
var indexThumb:String = "http://192.168.123.86/test/slideshow/images/80/";
var thumbPic:Number = 10;
var row:Number = 5; //num pic per row
var kerning:Number = 5;
var locateX:Number = 1;
var locateY:Number = 1;
var maxScale:Number = 150;
var minScale:Number = 100;
var speed:Number = .3;
//////////////////////////////////////////////////////////////////////////////////////////////
var loadImage:MovieClipLoader = new MovieClipLoader();
MovieClip.prototype.elastricity = function(num:Boolean) {
this.onEnterFrame = function() {
if(num) {
this._xscale += (maxScale - this._xscale) * speed;
this._yscale += (maxScale - this._yscale) * speed;
if(this._xscale == maxScale)
delete this.onEnterFrame;
} else {
this._xscale += (minScale - this._xscale) * speed;
this._yscale += (minScale - this._yscale) * speed;
if(this._xscale == minScale)
delete this.onEnterFrame;
}
}
}
for (i=1; i<=thumbPic; i++) {
picture.duplicateMovieClip("picture"+i, i);
this["picture"+i]._x = (picture._width+kerning)* locateX;
this["picture"+i]._y = (picture._height+kerning)* locateY;
this["picture"+i].depth = i;
this["picture"+i].onRollOver = function() {
this.swapDepths(1000);
this.elastricity(1);
}
this["picture"+i].onRollOut = function() {
this.swapDepths(this.depth);
this.elastricity(0);
}
if(i % row == 0) {
locateX = 0;
locateY ++;
}
locateX ++;
//loadImage.loadClip(indexThumb+i+".jpg", this["picture"+locate].sost);
}
picture._visible = false;
忘記付上例子
http://www.super-tomato.net/test/elastricity.swf
[ 本帖最后由 super-tomato 于 16-3-2007 11:27 PM 编辑 ] |
|
|
|
|
|
|
|

楼主 |
发表于 19-3-2007 06:58 PM
|
显示全部楼层
|
|
|
|
|
|
|
发表于 20-3-2007 07:32 AM
|
显示全部楼层
可否給我你的xml文件和fla? 因為直接看的話只能確定有些函數沒有列出來, 如firstimage等, 所以不太能夠確定你的寫法. 以下是大略寫法
var thumbPic:Number;
var row:Number = 4; //num pic per row
var kerning:Number = 5;
var locateX:Number = 1;
var locateY:Number = 1;
var maxScale:Number = 120;
var minScale:Number = 100;
var speed:Number = .5;
///////////////////////////////////////////////////////////////////////////////////////////
MovieClip.prototype.elastricity = function(num:Boolean) {
this.onEnterFrame = function() {
if (num) {
this._xscale += (maxScale-this._xscale)*speed;
this._yscale += (maxScale-this._yscale)*speed;
if (this._xscale == maxScale) {
delete this.onEnterFrame;
}
} else {
this._xscale += (minScale-this._xscale)*speed;
this._yscale += (minScale-this._yscale)*speed;
if (this._xscale == minScale) {
delete this.onEnterFrame;
}
}
};
};
MovieClip.prototype.loadImage = function() {
var MCLoader:MovieClipLoader = new MovieClipLoader();
MCLoader.loadClip(this.thumb, this);
}
function startImages() {
thumbPic = xmlData.firstChild.childNodes.length;
for (i=1; i<thumbPic; i++) {
picture.duplicateMovieClip("picture"+i, i);
var node = xmlData.firstChild.childNodes;
//這裡直接把xml節點的資料儲存在各自的mc中,就不用每次讀取資料了
this["picture"+i].image = node.childNodes[0].firstChild.nodeValue;
this["picture"+i].thumb = node.childNodes[1].firstChild.nodeValue;
this["picture"+i].desc = node.childNodes[2].firstChild.nodeValue;
this["picture"+i]._x = (picture._width+kerning)*locateX;
this["picture"+i]._y = (picture._height+kerning)*locateY;
this["picture"+i].depth = i;
this["picture"+i].onRollOver = function() {
this.swapDepths(1000);
this.elastricity(1);
desc_txt.text = description[0];
};
this["picture"+i].onRollOut = function() {
this.swapDepths(this.depth);
this.elastricity(0);
};
if (i%row == 0) {
locateX = 0;
locateY++;
}
locateX++;
this["picture"+i].loadImage();
}
picture._visible = false;
};
//////////////////////////////////////////////////////////////////////////////////////////////
var xmlData:XML = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = function(loaded) {
if (loaded) {
startImages();
}
};
xmlData.load("images.xml");
stop();
[ 本帖最后由 super-tomato 于 20-3-2007 08:58 AM 编辑 ] |
|
|
|
|
|
|
|

楼主 |
发表于 20-3-2007 10:21 AM
|
显示全部楼层
|
|
|
|
|
|
|

楼主 |
发表于 20-3-2007 10:09 PM
|
显示全部楼层
|
|
|
|
|
|
|
发表于 20-3-2007 11:24 PM
|
显示全部楼层
看不到任何问题,在flash 8 里,解释执行后,顺利的读取到xml的资料。
主要的问题是,不能够对Movieclip 直接飞跃式的宣告一个变量。MovieClip不能通过这种方法接受数值。
接着截取xml数据的方法错误。所以没有数据返回。
var node =xmlData.firstChild.childNodes;
//這裡直接把xml節點的資料儲存在各自的mc中,就不用每次讀取資料了
this["picture"+i].image = node.childNodes[0].firstChild.nodeValue;
......
.....
红色的句式应该改成:
xmlData.firstChild.childNodes[j].childNodes[1].nodeValue;
[ 本帖最后由 donynam 于 21-3-2007 11:46 AM 编辑 ] |
|
|
|
|
|
|
|

楼主 |
发表于 21-3-2007 10:12 AM
|
显示全部楼层
还是不行的,惨了,当我对着 var, array, xml, +i ...头脑打结 |
|
|
|
|
|
|
|
发表于 21-3-2007 11:49 AM
|
显示全部楼层
原帖由 xiao_yee 于 21-3-2007 10:12 AM 发表
还是不行的,惨了,当我对着 var, array, xml, +i ...头脑打结
看回我之前的帖子。论坛的解释器将我的 【 i 】转换成加斜字符号,所以没有显示出来。我现在用[j],表示。 |
|
|
|
|
|
|
|

楼主 |
发表于 21-3-2007 01:11 PM
|
显示全部楼层
不屈不挠,再试试  |
|
|
|
|
|
|
|

楼主 |
发表于 21-3-2007 03:15 PM
|
显示全部楼层
|
|
|
|
|
|
|
发表于 22-3-2007 11:14 AM
|
显示全部楼层
謝謝, donyname.因同樣的問題, 所有的 [ i ] 都變成論壇的斜線, 因而看不到.
var thumbPic:Number;
var row:Number = 4; //num pic per row
var kerning:Number = 5;
var locateX:Number = 1;
var locateY:Number = 1;
var maxScale:Number = 120;
var minScale:Number = 100;
var speed:Number = .5;
///////////////////////////////////////////////////////////////////////////////////////////
MovieClip.prototype.elastricity = function(num:Boolean) {
this.onEnterFrame = function() {
if (num) {
this._xscale += (maxScale-this._xscale)*speed;
this._yscale += (maxScale-this._yscale)*speed;
if (this._xscale == maxScale) {
delete this.onEnterFrame;
}
} else {
this._xscale += (minScale-this._xscale)*speed;
this._yscale += (minScale-this._yscale)*speed;
if (this._xscale == minScale) {
delete this.onEnterFrame;
}
}
};
};
MovieClip.prototype.loadImage = function() {
var MCLoader:MovieClipLoader = new MovieClipLoader();
trace(this.image);
MCLoader.loadClip(this.image, this);
}
function startImages() {
thumbPic = xmlData.firstChild.childNodes.length;
for (i=1; i<=thumbPic; i++) {
picture.duplicateMovieClip("picture"+i, i);
var node = xmlData.firstChild.childNodes;
//這裡直接把xml節點的資料儲存在各自的mc中,就不用每次讀取資料了
this["picture"+i].image = node[ i ].childNodes[0].firstChild.nodeValue;
this["picture"+i].thumb = node[ i ].childNodes[1].firstChild.nodeValue;
this["picture"+i].desc = node[ i ].childNodes[2].firstChild.nodeValue;
this["picture"+i]._x = (picture._width+kerning)*locateX;
this["picture"+i]._y = (picture._height+kerning)*locateY;
this["picture"+i].depth = i;
this["picture"+i].onRollOver = function() {
this.swapDepths(1000);
this.elastricity(1);
desc_txt.text = description[0];
};
this["picture"+i].onRollOut = function() {
this.swapDepths(this.depth);
this.elastricity(0);
};
this["picture"+i].onRelease = function() {
//trigger events here;
}
if (i%row == 0) {
locateX = 0;
locateY++;
}
locateX++;
//this["picture"+i].loadImage();
}
picture._visible = false;
};
//////////////////////////////////////////////////////////////////////////////////////////////
var xmlData:XML = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = function(loaded) {
if (loaded) {
startImages();
}
};
xmlData.load("images.xml");
stop();
[ 本帖最后由 super-tomato 于 22-3-2007 11:15 AM 编辑 ] |
|
|
|
|
|
|
|

楼主 |
发表于 22-3-2007 06:19 PM
|
显示全部楼层
function startImages() {
thumbPic = xmlData.firstChild.childNodes.length;
for (i=1; i<=thumbPic; i++) {
picture.duplicateMovieClip("picture"+i, i);
var node = xmlData.firstChild.childNodes;
为什么这个放i=0时,我第一张图片会在上面?如放1,我server里的第一张图并不会出现 |
|
|
|
|
|
|
|

楼主 |
发表于 26-3-2007 12:47 PM
|
显示全部楼层
|
|
|
|
|
|
|

楼主 |
发表于 27-3-2007 04:52 PM
|
显示全部楼层
如何call xml之后,再读里面的php
我只看到有独立的xml 和 php
php 会call xml 然后排成以上的effect |
|
|
|
|
|
|
|
发表于 27-3-2007 05:45 PM
|
显示全部楼层
原帖由 xiao_yee 于 27-3-2007 04:52 PM 发表
如何call xml之后,再读里面的php
我只看到有独立的xml 和 php
php 会call xml 然后排成以上的effect
那你必须去阅读php的文献。http://www.php.net |
|
|
|
|
|
|
|

楼主 |
发表于 28-3-2007 06:50 PM
|
显示全部楼层
好了
var my_xml = new XML();
my_xml.onLoad = function(success){
if (success){
var family = my_xml.firstChild.firstChild.firstChild;
var id = family.childNodes;
for (var i=0; i<id.length; i++){
currId = id[ i ];
images[ i ].firstChild.firstChild;
trace("ID "+currId); // trace each id
checkURL = myDomain+"picture.php?id="+currId+"&size="+size;
trace("ImgURL: "+checkURL);
}
}
}
my_xml.load(myDomain+"images.xml");
[ 本帖最后由 xiao_yee 于 28-3-2007 06:52 PM 编辑 ] |
|
|
|
|
|
|
|

楼主 |
发表于 28-3-2007 07:04 PM
|
显示全部楼层
为什么我的图画不会出现?
var thumbPic:Number;
var row:Number = 7; //num pic per row
var kerning:Number = 5;
var locateX:Number = 1;
var locateY:Number = 1;
var maxScale:Number = 200;
var minScale:Number = 100;
var speed:Number = .5;
///////////////////////////////////////////////////////////////////////////////////////////
MovieClip.prototype.elastricity = function(num:Boolean) {
this.onEnterFrame = function() {
if (num) {
this._xscale += (maxScale-this._xscale)*speed;
this._yscale += (maxScale-this._yscale)*speed;
if (this._xscale == maxScale) {
delete this.onEnterFrame;
}
} else {
this._xscale += (minScale-this._xscale)*speed;
this._yscale += (minScale-this._yscale)*speed;
if (this._xscale == minScale) {
delete this.onEnterFrame;
}
}
};
};
MovieClip.prototype.loadImage = function() {
var MCLoader:MovieClipLoader = new MovieClipLoader();
MCLoader.loadClip(this.thumb, this);
}
//////////////////////////////////////////////////////////////////////////////////////////////
var my_xml:XML = new XML();
my_xml.ignoreWhite = true;
my_xml.load(myDomain+"images.xml");
my_xml.onLoad = function(success) {
if (success) {
//trace(my_xml);
var picNode = my_xml.firstChild.firstChild;
var numPic = picNode.parentNode.childNodes.length;
var numNodeInPic = picNode.childNodes.length;
var myRec = new Array(numPic);
for (var aNode:XMLNode = picNode, j = 0; aNode != null; aNode=aNode.nextSibling, j++) {
//trace("ANode \n"+ aNode.childNodes[1]);
myRec[j] = new Array(numNodeInPic);
for (var i = 0; i<numNodeInPic-1; i++) {
//trace("childNode "+i+" \n"+ aNode.childNodes[ i].firstChild.nodeValue);
myRec[j][ i] = (aNode.childNodes[ i].firstChild.nodeValue != null) ? aNode.childNodes[ i].firstChild.nodeValue : null;
}
// Tags Record
for (var bNode:XMLNode = aNode.childNodes[numNodeInPic-1]; bNode != null; bNode=bNode.nextSibling) {
//trace(bNode);
var numTags = aNode.childNodes[numNodeInPic-1].childNodes.length;
//trace(numTags);
myRec[j][numNodeInPic-1] = new Array(numTags);
for (var k = 0; k<numTags; k++) {
// trace("childNode "+k+" :"+bNode.childNodes[k].firstChild.nodeValue);
myRec[j][numNodeInPic-1][k] = (bNode.childNodes[k].firstChild.nodeValue != null) ? bNode.childNodes[k].firstChild.nodeValue : null;
}
}
}
//trace(myRec[1][8][9]+"\n");
for (var i = 0; i<numPic; i++) {
//trace("Record "+i+" : "+myRec[ i]+"\n");
picture.duplicateMovieClip("picture"+i, i);
//trace(myRec[ i][0]);
currId = myRec[ i][0];
getId = myDomain+"picture.php?id="+currId+"&size="+size;
trace (getId);
trace(picture.sost);
picture.sost.loadClip(myDomain+"picture.php?id="+currId+"&size="+size);
this["picture"+i].sost .loadClip(myDomain+"picture.php?id="+currId+"&size="+size);
this["picture"+i]._x = (picture._width+kerning)*locateX;
this["picture"+i]._y = (picture._height+kerning)*locateY;
this["picture"+i].depth = i;
this["picture"+i].onRollOver = function() {
this.swapDepths(1000);
this.elastricity(1);
//desc_txt.text = desc[0];
};
this["picture"+i].onRollOut = function() {
this.swapDepths(this.depth);
this.elastricity(0);
};
}
}
};
[ 本帖最后由 xiao_yee 于 28-3-2007 10:47 PM 编辑 ] |
|
|
|
|
|
|
| |
本周最热论坛帖子
|