two questions!

  • SvenF
  • Born
  • Born
  • SvenF
  • Posts: 1

Post 3+ Months Ago

Hi,
I have two questions:
1. There is a quick and easy solution to work through the following code using a loop? so I can dynamically control how many event handlers and functions are created?:

Code: [ Select ]
pics[0].addEventListener(MouseEvent.CLICK, changepic1);
pics[1].addEventListener(MouseEvent.CLICK, changepic2);
pics[2].addEventListener(MouseEvent.CLICK, changepic3);
pics[3].add...

function changepic1(parameter:Event):void{
  loader.addEventListener(IOErrorEvent.IO_ERROR, onIOError);
  loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete);
  loader.load( new URLRequest( "Fotos/Bumps/1.jpg" ) );
}
function changepic2(parameter:Event):void{
  loader.addEventListener(IOErrorEvent.IO_ERROR, onIOError);
  loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete);
  loader.load( new URLRequest( "Fotos/Bumps/2.jpg" ) );
}
function changepic3(parameter:Event):void{
  loader.addEventListener(IOErrorEvent.IO_ERROR, onIOError);
  loader.contentLoaderInfo.add...
  1. pics[0].addEventListener(MouseEvent.CLICK, changepic1);
  2. pics[1].addEventListener(MouseEvent.CLICK, changepic2);
  3. pics[2].addEventListener(MouseEvent.CLICK, changepic3);
  4. pics[3].add...
  5. function changepic1(parameter:Event):void{
  6.   loader.addEventListener(IOErrorEvent.IO_ERROR, onIOError);
  7.   loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete);
  8.   loader.load( new URLRequest( "Fotos/Bumps/1.jpg" ) );
  9. }
  10. function changepic2(parameter:Event):void{
  11.   loader.addEventListener(IOErrorEvent.IO_ERROR, onIOError);
  12.   loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete);
  13.   loader.load( new URLRequest( "Fotos/Bumps/2.jpg" ) );
  14. }
  15. function changepic3(parameter:Event):void{
  16.   loader.addEventListener(IOErrorEvent.IO_ERROR, onIOError);
  17.   loader.contentLoaderInfo.add...


With loops since I will not probably come really help you? I am really just on the tube!


2. I invite a number of external images as small thumbs on my stage in each individual movie clips. When you run these clips with the mouse, the images in dependence on the distance of the mouse to the image scaled. This will of course happen simultaneously in all directions, which I have put the registration point in the middle. Since I pictures, however, with actionscript external load and with actionscript generated movie clips lege, so here I also know quite how to proceed nciht:

Code: [ Select ]
function ladeBild(nr:int):void
{
  var slideloader:Loader = new Loader();
  meineLoader.push(slideloader);
  pics[nr].addChild(meineLoader[nr]);
  meineLoader[nr].addEventListener(IOErrorEvent.IO_ERROR, onIOErrorslide);
  meineLoader[nr].contentLoaderInfo.addEventListener(Event.COMPLETE, onCompleteslide);
  meineLoader[nr].load( new URLRequest( "Fotos/Bumps/"+(nr+1)+".jpg" ) );
}

function onCompleteslide(evt:Event):void 

 
  pics[meinZaehler].width = 100.0;
  pics[meinZaehler].height = 66.5;
  pics[meinZaehler].x = 190;
  pics[meinZaehler].y = 40 + posy;
  meineLoader[meinZaehler].x = meineLoader[meinZaehler].x - (pics[meinZaehler].width/2);
  meineLoader[meinZaehler].y = meineLoader[meinZaehler].y - (pics[meinZaehler].height/2);
  trace(meineLoader[meinZaehler].x);
  posy = posy+(pics[meinZaehler].height)+20;
  meineLoader[meinZaehler].removeEventListener(Event.COMPLETE, onCompleteslide);
  meineLoader[meinZaehler].removeEventListener(IOErrorEvent.IO_ERROR, onIOErrorslide);
  meinZaehler ++;
  if(meinZaehler < bilderAnzahl) ladeBild(meinZaehler);
}

function onIOErrorslide(evt:IOErrorEvent):void {
   trace("Es ist ein Fehler aufgetreten");
}

ladeBild(meinZaehler);
  1. function ladeBild(nr:int):void
  2. {
  3.   var slideloader:Loader = new Loader();
  4.   meineLoader.push(slideloader);
  5.   pics[nr].addChild(meineLoader[nr]);
  6.   meineLoader[nr].addEventListener(IOErrorEvent.IO_ERROR, onIOErrorslide);
  7.   meineLoader[nr].contentLoaderInfo.addEventListener(Event.COMPLETE, onCompleteslide);
  8.   meineLoader[nr].load( new URLRequest( "Fotos/Bumps/"+(nr+1)+".jpg" ) );
  9. }
  10. function onCompleteslide(evt:Event):void 
  11.  
  12.   pics[meinZaehler].width = 100.0;
  13.   pics[meinZaehler].height = 66.5;
  14.   pics[meinZaehler].x = 190;
  15.   pics[meinZaehler].y = 40 + posy;
  16.   meineLoader[meinZaehler].x = meineLoader[meinZaehler].x - (pics[meinZaehler].width/2);
  17.   meineLoader[meinZaehler].y = meineLoader[meinZaehler].y - (pics[meinZaehler].height/2);
  18.   trace(meineLoader[meinZaehler].x);
  19.   posy = posy+(pics[meinZaehler].height)+20;
  20.   meineLoader[meinZaehler].removeEventListener(Event.COMPLETE, onCompleteslide);
  21.   meineLoader[meinZaehler].removeEventListener(IOErrorEvent.IO_ERROR, onIOErrorslide);
  22.   meinZaehler ++;
  23.   if(meinZaehler < bilderAnzahl) ladeBild(meinZaehler);
  24. }
  25. function onIOErrorslide(evt:IOErrorEvent):void {
  26.    trace("Es ist ein Fehler aufgetreten");
  27. }
  28. ladeBild(meinZaehler);


That was my first attempt, I thought to myself pics [meinZähler] which is a MovieClip created, is so a kind of container for meineLoader [meinZaehler]. So if I meineLoader [meinZaehler] within pics [meinZähler] so move, that is the registration point of pics [meinZähler] in the middle of the picture, it should work yes...does trace (meineLoader [meinZaehler]. x), gives me scale from -50, but he still made from the top left corner??

I hope I can be helped gif "alt =": D "title =" Very Happy ">
Many thanks in advance!

Post Information

  • Total Posts in this topic: 1 post
  • Users browsing this forum: No registered users and 28 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.