A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Another Migration problem! Please help - loading images & buttons

  1. #1
    Flash Developer
    Join Date
    Feb 2006
    Posts
    105

    Unhappy Another Migration problem! Please help - loading images & buttons

    Hi there. Thanks for reading.. I was converting a AS2 project into AS3 and ran into a problem.. This is about loading a sequence of images one by one into a sequence of holders and then using the holders as buttons.

    In AS2, I would just say:

    Code:
    MCLoader.onLoadInit = function(target_mc:MovieClip) {
         loadedNum++;
         // incriment number loaded so we know which one we're on
         // so when the loading of one image completes, we add a function
         // to the holder to make it act like a button...
         MC["holder" + loadedNum].onPress = function() {
               //button code here
         }
    }
    simple enough.. now here's my shot in AS3:

    Code:
    function imageLoaded(event:Event):void {
         loadedNum++;
         // incriment number loaded so we know which one we're on
         // this is the function that is called when one image completes loading
         // so when the loading of one image completes, we add a function
         // to the holder to make it act like a button...
    	MC.getChildByName("holder" + loadedNum).addEventListener(MouseEvent.CLICK, imageClick);
    So this is almost the same, pretty much the only difference is the way you set the function to the holders. Remember, this iterates through several holders, loading images in, until it has loaded all of them.. I'm sure you know this, but I wanted to be as clear as possible, 'cause I know what it's like to read other people's problems and code.

    But here's the problem!!: In the AS2 code, once the first image loads in, you can click and the onPress function will run. But in the AS3 code, the holders are inactive and dead as buttons until all the images in the sequence has loaded. Once the last image to be loaded in completes the load, then all of the holders activate and you can perform the CLICK function.

    Any ideas how to solve this?

    Obviously (to be clear again), I want the holders to be active as buttons as soon as the image for that holder has completed the load.

    Thanks,
    Christian

  2. #2
    Mod cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,448
    I have not encountered this problem. Here is an example:
    http://www.flashscript.biz/flashas3/...slideshow.html
    - The right of the People to create Flash movies shall not be infringed. -
    | www.Flashscript.biz | Flashscript Biz Classes/Components |

  3. #3
    Flash Developer
    Join Date
    Feb 2006
    Posts
    105

    [resolved]

    My mistake, sorry for anyone who took time on this.. For future reference, make sure to set the mouseEnabled property of anything in front of the target to false. :P

    Oh and I couldn't find the button to officially mark this thread as resolved... me being dumb again.. sorry. :s

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center