J'ai ces images qui se chargeront lorsque j'écrirai une certaine chaîne de texte mais je ne sais pas comment combiner les fonctions pour en faire une générique travaillera pour toutes les images. Ce sont juste deux et ils sont fondamentalement la même chose sauf que je dois faire chaque fonction (quelque chose) 1 et (quelque chose) 2 pour l'image suivante. J'ai besoin d'aide pour ce faire.Actionscript 3.0 Combinaison de fonctions pour créer une fonction générique qui peut être appliquée à plusieurs images
function onInput(event:TextEvent):void {
if(ti.text.search('a')!=-1) addChild(ottefct);
else if(ti.text.search('b')!=-1) addChild(rnd);
var oeffect:Loader = new Loader();
oeffect.load(new URLRequest("http://i54.tinypic.com/anom5d.png"));
oeffect.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoadingComplete);
var ottefct:Sprite = new Sprite();
function onLoadingComplete(event:Event):void
{
ottefct.addChild(event.currentTarget.loader.content);
ottefct.addEventListener(MouseEvent.MOUSE_DOWN, drag);
ottefct.addEventListener(MouseEvent.MOUSE_UP, drop);
ottefct.doubleClickEnabled = true;
ottefct.addEventListener(MouseEvent.MOUSE_WHEEL, rotate)
ottefct.addEventListener(MouseEvent.DOUBLE_CLICK, unrotate)
ottefct.height=180
ottefct.width=124
}
function drag(event:MouseEvent):void{
ottefct.startDrag()
}
function drop(event:MouseEvent):void{
ottefct.stopDrag()
}
function rotate(event:MouseEvent):void{
ottefct.rotation = 90
}
function unrotate(event:MouseEvent):void{
ottefct.rotation = 0
}
//---------------------------
var rednova:Loader = new Loader();
rednova.load(new URLRequest("http://i53.tinypic.com/2dv7dao.png"));
rednova.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoadingComplete1);
var rnd:Sprite = new Sprite();
function onLoadingComplete1(event:Event):void
{
rnd.addChild(event.currentTarget.loader.content);
rnd.addEventListener(MouseEvent.MOUSE_DOWN, drag1);
rnd.addEventListener(MouseEvent.MOUSE_UP, drop1);
ottefct.addEventListener(MouseEvent.MOUSE_WHEEL, rotate1)
ottefct.addEventListener(MouseEvent.DOUBLE_CLICK, unrotate1)
rnd.height=180
rnd.width=124
}
function drag1(event:MouseEvent):void{
rnd.startDrag()
}
function drop1(event:MouseEvent):void{
rnd.stopDrag()
}
function rotate1(event:MouseEvent):void{
rnd.rotation = 90
}
function unrotate1(event:MouseEvent):void{
rnd.rotation = 0
}