Flash as3.0 xml 生成按钮
importflash.filters.DisplacementMapFilter;importflash.events.Event;importflash.events...
import flash.filters.DisplacementMapFilter;
import flash.events.Event;
import flash.events.MouseEvent;
var loader:URLLoader = new URLLoader();
var xml:XML;
var xmlList:XMLList = new XMLList();
var imagePath_ar:Array = new Array();
var iconPath_ar:Array = new Array();
var listNum:int = 0;
////////////////////////////////////
var myNumA:int = 0;
var index:uint = 0;
//----------------
var icon_load:Loader;
var icon_req:URLRequest;
var total_icon:Number;
//----------------
var image_load:Loader;
var image_req:URLRequest;
var total_image:Number;
var imgSprite:Sprite=new Sprite();
initPlayer();
//-----------
var currentICON:int = 0;
function initPlayer():void
{
loader.load(new URLRequest("loading/image_list.xml"));
loader.addEventListener(Event.COMPLETE,onComplete);
function onComplete(e:Event):void
{
xml = new XML(e.target.data);
xmlList = xml.image;
total_icon = xml.image.length();
for (var i:int = 0; i<total_icon; i++)
{
imagePath_ar[i] = xmlList[i].image_path;
iconPath_ar[i] = xmlList[i].icon_path;
icon_req = new URLRequest(iconPath_ar[i]);
icon_load=new Loader();
icon_load.load(icon_req);
if ((i%2)==0)
{
icon_load.x = i * 45 + 22.5;
}
else
{
icon_load.x = 0 - (i * 45) - 22.5;
}
icon_load.y = 0;
icon_load.name = "icon_" + i;
icon_load.contentLoaderInfo.addEventListener(Event.COMPLETE,iconCOMPLETE);
icon_load.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS,iconPROGRESS);
icon_load.addEventListener(IOErrorEvent.IO_ERROR,iconERRoR);
icon_mc.addChild(icon_load);
//icon_mc.scaleX=720;
icon_mc.x = 720;
}
}
}
function iconCOMPLETE(e)
{
index++;
if (index==total_icon)
{
iconButton();
imageLoad(0);
}
}
function iconButton()
{//定义按钮监听器
for (var i=0; i<total_icon; i++)
{
icon_mc["icon_" + i].addEventListener(MouseEvent.CLICK,onPress_Btn);
icon_mc["icon_" + i].buttonMode = true;
}
}
function onPress_Btn(e:MouseEvent):void
{//定义按钮事件
var btnName=(e.currentTarget.name);
var btnNumName:String = btnName.substring(5,7);
var aa:int = int(btnNumName);
image_mc.gotoAndPlay(1);
imageLoad(aa);
}
function imageLoad(aa)
{
//trace("aa:"+aa);
//trace("currentICON:"+currentICON);
if (aa<0)
{
aa = total_icon - 1;
}
else if (aa>(total_icon-1))
{
aa = 0;
}
//当(a<10)为真 则返回b的值 假则返回值为16
image_mc.play();
image_load=new Loader();
image_load.load(new URLRequest(imagePath_ar[aa]));
image_load.contentLoaderInfo.addEventListener(Event.COMPLETE,imageCOMPLETE);
image_mc.image_anim_A.addChild(image_load);
currentICON = aa;
}
请问为什么生成按钮无效阿?谢谢 展开
import flash.events.Event;
import flash.events.MouseEvent;
var loader:URLLoader = new URLLoader();
var xml:XML;
var xmlList:XMLList = new XMLList();
var imagePath_ar:Array = new Array();
var iconPath_ar:Array = new Array();
var listNum:int = 0;
////////////////////////////////////
var myNumA:int = 0;
var index:uint = 0;
//----------------
var icon_load:Loader;
var icon_req:URLRequest;
var total_icon:Number;
//----------------
var image_load:Loader;
var image_req:URLRequest;
var total_image:Number;
var imgSprite:Sprite=new Sprite();
initPlayer();
//-----------
var currentICON:int = 0;
function initPlayer():void
{
loader.load(new URLRequest("loading/image_list.xml"));
loader.addEventListener(Event.COMPLETE,onComplete);
function onComplete(e:Event):void
{
xml = new XML(e.target.data);
xmlList = xml.image;
total_icon = xml.image.length();
for (var i:int = 0; i<total_icon; i++)
{
imagePath_ar[i] = xmlList[i].image_path;
iconPath_ar[i] = xmlList[i].icon_path;
icon_req = new URLRequest(iconPath_ar[i]);
icon_load=new Loader();
icon_load.load(icon_req);
if ((i%2)==0)
{
icon_load.x = i * 45 + 22.5;
}
else
{
icon_load.x = 0 - (i * 45) - 22.5;
}
icon_load.y = 0;
icon_load.name = "icon_" + i;
icon_load.contentLoaderInfo.addEventListener(Event.COMPLETE,iconCOMPLETE);
icon_load.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS,iconPROGRESS);
icon_load.addEventListener(IOErrorEvent.IO_ERROR,iconERRoR);
icon_mc.addChild(icon_load);
//icon_mc.scaleX=720;
icon_mc.x = 720;
}
}
}
function iconCOMPLETE(e)
{
index++;
if (index==total_icon)
{
iconButton();
imageLoad(0);
}
}
function iconButton()
{//定义按钮监听器
for (var i=0; i<total_icon; i++)
{
icon_mc["icon_" + i].addEventListener(MouseEvent.CLICK,onPress_Btn);
icon_mc["icon_" + i].buttonMode = true;
}
}
function onPress_Btn(e:MouseEvent):void
{//定义按钮事件
var btnName=(e.currentTarget.name);
var btnNumName:String = btnName.substring(5,7);
var aa:int = int(btnNumName);
image_mc.gotoAndPlay(1);
imageLoad(aa);
}
function imageLoad(aa)
{
//trace("aa:"+aa);
//trace("currentICON:"+currentICON);
if (aa<0)
{
aa = total_icon - 1;
}
else if (aa>(total_icon-1))
{
aa = 0;
}
//当(a<10)为真 则返回b的值 假则返回值为16
image_mc.play();
image_load=new Loader();
image_load.load(new URLRequest(imagePath_ar[aa]));
image_load.contentLoaderInfo.addEventListener(Event.COMPLETE,imageCOMPLETE);
image_mc.image_anim_A.addChild(image_load);
currentICON = aa;
}
请问为什么生成按钮无效阿?谢谢 展开
2个回答
AiPPT
2024-09-19 广告
2024-09-19 广告
随着AI技术的飞速发展,如今市面上涌现了许多实用易操作的AI生成工具1、简介:AiPPT: 这款AI工具智能理解用户输入的主题,提供“AI智能生成”和“导入本地大纲”的选项,生成的PPT内容丰富多样,可自由编辑和添加元素,图表类型包括柱状图...
点击进入详情页
本回答由AiPPT提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询