React

React
Fundamental of React Js

Tuesday, December 25, 2007

Dynamic Remove Image

Dynamic Remove Image
Load the image via XML file
Make the action script enable the first Child
Then, load the images to the movie
Get the loops statement count the no. of image and place holder to the
Movie clip Container.
After the make all movie clip to link as button and perform the operation
to remove the images from the container.
Here the code….
var myxml:XML = new XML();
myxml.ignoreWhite = true;
myxml.load('list.xml');
myxml.onLoad = function(success) {
////trace(this+newline+'successful loaded the Xml file');
loadimage();
};
// Create a function loadimage
function loadimage()
{
var pic_array:Array = new Array();
//pic_array.sort()
for (var x in myxml.idMap)
{
var xmlnode = myxml.idMap[x];
pic_array.push({id:x,link:xmlnode.attributes.link,captiontext:xmlnode.attributes.captiontext});
}
////trace(newline+pic_array + newline+ '** Array vlaue ' );
////trace(newline+' Array length : ' + pic_array.length )
for(var i=0;i
{
this.createEmptyMovieClip('s'+i,i);
this['s'+i].createEmptyMovieClip('s1',1)
this['s'+i].createTextField('txt',2,8,55,50,25)
this['s'+i].txt.text=pic_array[i].id;
temp.push(this['s'+i])
//this['s'+i].x = i*60
//this['s'+i].y = i*i
var stgwid = this._width
////trace(newline + ' stage width : '+ stgwid)
var imagewid = 50
var gap = 5
var locate = (stgwid /(imagewid + gap))
this['s'+i].pos= (i%25)
////trace(this['s'+i].pos + ' position value')
////trace(locate + ' : locate value of position ' )
this.mc0 = 10
this.mc1 = 10
this.mc2 = 10
this.mc3 = 10
this.mc4 = 10
this.mc5 = 10
this.mc6 = 10
this.mc7 = 10
this.mc8 = 10
this.mc9 = 10
this.mc10 = 10
this.mc11 = 10
this.mc12 = 10
this.mc13 = 10
this.mc14 = 10
this.mc15 = 10
this.mc16 = 10
this.mc17 = 10
this.mc18 = 10
this.mc19 = 10
this.mc20 = 10
this.mc21 = 10
this.mc22 = 10
this.mc23 = 10
this.mc24 = 10
var mcloader:MovieClipLoader = new MovieClipLoader()
var listner:Object = new Object()
listner.onLoadInit =function(target:MovieClip)
{
////trace(target + newline + ' Target listed ' )
target._width = 50
target._height = 50
target._x = 5
target._y = 5
//locate = target._parent.pos
switch(target._parent.pos)
{
case 0:
target._parent._x=370;
target._parent._y=80;
target._parent._y+=60
break;
case 1:
target._parent._x = 310;
target._parent._y = 80
target._parent._y+=60
break;
case 2:
target._parent._x = 250
target._parent._y = 80
target._parent._y+=60
break;
case 3:
target._parent._x =190
target._parent._y = 80
target._parent._y+=60
break
case 4:
target._parent._x = 130
target._parent._y = 140
_parent._parent._y+=60
break
case 5:
target._parent._x = 70
target._parent._y = 80
target._parent._y+=60
break
case 6:
target._parent._x = 10
target._parent._y = 80
target._parent._y+=60
break
case 7:
target._parent._x = 490
target._parent._y = 15
target._parent._y+=60
break
case 8:
target._parent._x = 430
target._parent._y = 15
target._parent._y+=60
break
case 9:
target._parent._x = 370
target._parent._y = 15
target._parent._y+=60
break
case 10:
target._parent._x = 310
target._parent._y = 15
target._parent._y+=60
break
case 11:
target._parent._x =250
target._parent._y =15
target._parent._y+=60
break
case 12:
target._parent._x =190
target._parent._y =15
target._parent._y+=60
break
case 13:
target._parent._x = 130
target._parent._y = 15
target._parent._y+=60
break
case 14:
target._parent._x =70
target._parent._y =15
target._parent._y+=60
break
case 15:
target._parent._x = 10
target._parent._y = 15
target._parent._y+=60
break
case 16:
target._parent._x = 490
target._parent._y = target._parent._parent.mc16
target._parent._parent.mc16+=60
break
case 17:
target._parent._x = 430
target._parent._y = target._parent._parent.mc17
target._parent._parent.mc17+=60
break
case 18:
target._parent._x = 370
target._parent._y = target._parent._parent.mc18
target._parent._parent.mc18+=60
break
case 19:
target._parent._x = 310
target._parent._y = target._parent._parent.mc19
_parent._parent.mc19+=60
break
case 20:
target._parent._x = 250
target._parent._y = target._parent._parent.mc20
_parent._parent.mc20+=60
break
case 21:
target._parent._x = 190
target._parent._y = target._parent._parent.mc21
target._parent._parent.mc21+=60
break
case 22:
target._parent._x = 130
target._parent._y = target._parent._parent.mc22
target._parent._parent.mc22+=60
break
case 23:
target._parent._x = 70
target._parent._y = target._parent._parent.mc23
target._parent._parent.mc23+=60
break
case 24:
//trace(' Enter the 1st Image'+ newline )
target._parent._x = 10
target._parent._y = target._parent._parent.mc24
target._parent._parent.mc24+=60
break;
}
target._parent.onPress=function(){
this.removeMovieClip();
_root.position_clips(this._parent)
}
}
//trace('id : ' +pic_array[i].id );
mcloader.addListener(listner)
//trace(pic_array[i]+newline + 'image loaded ')
mcloader.loadClip(pic_array[i].link.toString(),this['s'+i].s1)
}
}
function position_clips(_mov:MovieClip){
var posx=0
var posy=0
var count:Number=0;
for(var i in _root){
if(_root[i] instanceof MovieClip){
if(count!=0){
posx+=_root[i]._width+10
}
count++
if((Stage.width-50)-posx<0 o:p="">
posy+=60
posx=0
}
_root[i]._x=posx;
_root[i]._y=posy;
}
}
}
function deleteImage(mc:MovieClip,wid:Number,hei:Number,posx:Number,poxy:Number)
{
mc._width = wid
mc._height = hei
mc.onRelease = function()
{
var pos = this._width - this.wid
}
}
Here the o/p:





0 comments: