flash实例教程装载xml文件
stop();
this._lockroot=true;
import flash.filters.*;
import caurina.transitions.Tweener;
var spacing:Number = 4;
function setup(){
var main = my_xml.firstChild.childNodes;
var len = main.length;
var mc_listener:Object = new Object();
var main_loader:MovieClipLoader = new MovieClipLoader();
var sub_loader:MovieClipLoader = new MovieClipLoader();
var link_array:Array = new Array();
mc_loader.addListener(mc_listener);
mc_listener.onLoadInit = function(target:MovieClip){
};
for(var i:Number = 0; i<len; i++){
var sub_obj:Object = new Object();
sub_obj.finalPos = 300;
sub_obj.initPos = 290;
var main_obj:Object = new Object();
main_obj.finalPos = 0;
main_obj.initPos = 10;
sub_obj.mc = _root.createEmptyMovieClip("sub_mc"+i, this.getNextHighestDepth());
sub_obj.mc.main = sub_obj.mc.createEmptyMovieClip("main_mc", sub_obj.mc.getNextHighestDepth());
sub_obj.mc.main._x = 17 + ((90 + spacing)*i);
sub_obj.mc.main._y = 290;
sub_obj.mc.main._yscale *= -1;
main_obj.mc = _root.createEmptyMovieClip("main_mc"+i, this.getNextHighestDepth());
main_obj.mc.main = main_obj.mc.createEmptyMovieClip("main_mc", main_obj.mc.getNextHighestDepth());
main_obj.mc.main._x = 17 + ((90 + spacing)*i);
main_obj.mc.main._y = 10;
sub_loader.loadClip(main.attributes.url,sub_obj.mc.main);
main_loader.loadClip(main.attributes.url, main_obj.mc.main);
main_obj.mc.sub = sub_obj.mc.main;
main_obj.mc.onRollOver = function(){
Tweener.addTween(this.main, {_y:main_obj.finalPos, time:.5, transition:"easeOutExpo"});
Tweener.addTween(this.sub, {_y:sub_obj.finalPos, time:.5, transition:"easeOutExpo"});
};
main_obj.mc.onRollOut = function(){
Tweener.addTween(this.main, {_y:main_obj.initPos, time:.5, transition:"easeOutBounce"});
Tweener.addTween(this.sub, {_y:sub_obj.initPos, time:.5, transition:"easeOutbounce"});
};
main_obj.mc.link = link_array;
link_array = main.attributes.link;
main_obj.mc.onRelease = main_obj.mc.onReleaseOutside = function(){
//trace(this.link);
getURL(this.link,"_blank");
};
};
};
var my_xml:XML = new XML();
my_xml.ignoreWhite = true;
my_xml.onLoad = function(success){
if(success){
setup();
}else{
trace("Error loading view.xml file");
};
};
my_xml.load("view.xml");
this._lockroot=true;
import flash.filters.*;
import caurina.transitions.Tweener;
var spacing:Number = 4;
function setup(){
var main = my_xml.firstChild.childNodes;
var len = main.length;
var mc_listener:Object = new Object();
var main_loader:MovieClipLoader = new MovieClipLoader();
var sub_loader:MovieClipLoader = new MovieClipLoader();
var link_array:Array = new Array();
mc_loader.addListener(mc_listener);
mc_listener.onLoadInit = function(target:MovieClip){
};
for(var i:Number = 0; i<len; i++){
var sub_obj:Object = new Object();
sub_obj.finalPos = 300;
sub_obj.initPos = 290;
var main_obj:Object = new Object();
main_obj.finalPos = 0;
main_obj.initPos = 10;
sub_obj.mc = _root.createEmptyMovieClip("sub_mc"+i, this.getNextHighestDepth());
sub_obj.mc.main = sub_obj.mc.createEmptyMovieClip("main_mc", sub_obj.mc.getNextHighestDepth());
sub_obj.mc.main._x = 17 + ((90 + spacing)*i);
sub_obj.mc.main._y = 290;
sub_obj.mc.main._yscale *= -1;
main_obj.mc = _root.createEmptyMovieClip("main_mc"+i, this.getNextHighestDepth());
main_obj.mc.main = main_obj.mc.createEmptyMovieClip("main_mc", main_obj.mc.getNextHighestDepth());
main_obj.mc.main._x = 17 + ((90 + spacing)*i);
main_obj.mc.main._y = 10;
sub_loader.loadClip(main.attributes.url,sub_obj.mc.main);
main_loader.loadClip(main.attributes.url, main_obj.mc.main);
main_obj.mc.sub = sub_obj.mc.main;
main_obj.mc.onRollOver = function(){
Tweener.addTween(this.main, {_y:main_obj.finalPos, time:.5, transition:"easeOutExpo"});
Tweener.addTween(this.sub, {_y:sub_obj.finalPos, time:.5, transition:"easeOutExpo"});
};
main_obj.mc.onRollOut = function(){
Tweener.addTween(this.main, {_y:main_obj.initPos, time:.5, transition:"easeOutBounce"});
Tweener.addTween(this.sub, {_y:sub_obj.initPos, time:.5, transition:"easeOutbounce"});
};
main_obj.mc.link = link_array;
link_array = main.attributes.link;
main_obj.mc.onRelease = main_obj.mc.onReleaseOutside = function(){
//trace(this.link);
getURL(this.link,"_blank");
};
};
};
var my_xml:XML = new XML();
my_xml.ignoreWhite = true;
my_xml.onLoad = function(success){
if(success){
setup();
}else{
trace("Error loading view.xml file");
};
};
my_xml.load("view.xml");
补充:flash教程,动画技术