English 中文(简体)
闪S3:基于图像高度的镜头的固定图像
原标题:Flash AS3: position loaded images from loop based on image height

I m试图通过Xml文档积极打碎图像。 下面是我干的,它几乎行之有效。 问题在于,这似乎只是把活动完全放在最后一项功能上,而不是让所有人参加。 是否有办法让它走到晚上。 每个形象的完整功能?

function aboutfileLoaded(event:Event):void {
    aboutXML = new XML(aboutTextLoader.data);
for(var l:int = 0; l < aboutXML.aboutimages.image.length(); l++)
    {
            imageLoader = new Loader();
            imageSource = aboutXML.aboutimages.image[l];

            if (imageSource != "") {
                    this.imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, aboutimageLoaded);
                    this.imageLoader.load(new URLRequest(imageSource));

                    //aboutBox.aboutContent.addChild(imageLoader);
                    //imageLoader.y = imageYpos;
                    //imageYpos = imageYpos + 50;
            }

    }
}

function aboutimageLoaded(event:Event):void {
            aboutBox.aboutContent.addChild(imageLoader);
            this.imageLoader.y = imageYpos;
            imageYpos = imageYpos + this.imageLoader.height;
}
问题回答

我用一个简单的图像类别书写了所有图像。

public function loadImages(xml:XML):void {
    for each(var img:XML in xml.images) {
        var i:Image = new Image(img.src, img.width, img.height);

        i.loader.contentLoaderInfo.addEventListener(Event.COMPLETE, positionImage);
    }
}

/**/

private function positionImage(e:Event):void {
    var i:Image = e.target;
    gallery.addChild(i);
    // Do the positioning.
}

在你前面的法典中,你可以永远只是改变你们的悲观。 替代职能:

// In aboutfileLoaded() change all "this.imageLoader" to just "imageLoader"

function aboutimageLoader(event:Event):void {
    aboutBox.aboutContent.addChild(event.target);
    event.target.y = imageYpos;
}

每一名Lerader人只能同时从事一项工作,因此,你要么想要打工,把工作排在另一个岗位上:

//Global vars
loadIndex:int = 0; 
imageLoader = new Loader();
imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, aboutimageLoaded);
loadImage();

private function loadimage(){
    if(aboutXML.aboutimages.image[loadIndex] != null){
        imageSource = aboutXML.aboutimages.image[loadIndex];
        if (imageSource != "") {
            imageLoader.load(new URLRequest(imageSource));
        }
    }
}

function aboutimageLoaded(event:Event):void {
    var holder = (ev.content as Bitmap).clone();
    aboutBox.aboutContent.addChild(holder);
    holder .y = imageYpos;
    imageYpos = imageYpos + holder.height;
    loadIndex ++;
    loadimage();
}

或多例Loaders,每例:

for(var l:int = 0; l < aboutXML.aboutimages.image.length(); l++)
    {
            var imageLoaderTemp = new Loader();
            imageSource = aboutXML.aboutimages.image[l];

            if (imageSource != "") {
                    imageLoaderTemp.contentLoaderInfo.addEventListener(Event.COMPLETE, aboutimageLoaded);
                    imageLoaderTemp.load(new URLRequest(imageSource));
            }
    }
}

function aboutimageLoaded(event:Event):void {
            aboutBox.aboutContent.addChild(event.target);
            event.target.y = imageYpos;
            imageYpos = imageYpos + event.target.height;
}




相关问题
Attaching a property to an event in Flex/AS3

I have a parameter that needs to be passed along with an event. After unsuccessful attempts to place it on the type by extending the class, I ve been advised in another SO question to write a custom ...

Sorting twodimensional Array in AS3

So, i have a two-dimensional Array of ID s and vote count - voteArray[i][0] = ID, voteArray[i][1] = vote count I want the top 3 voted items to be displayed in different colors, so i have a 2nd Array -...

Virtual Tour using sketch up, ajax, flash technologies

I want to know if there are existing technology that make your 3d models in sketch into virtual tours, using either Ajax or Flash for web presentation. If there s none, which will be a good approach ...

What s a good way of deserializing data into mock objects?

I m writing a mock backend service for my flex application. Because I will likely need to add/edit/modify the mock data over time, I d prefer not to generate the data in code like this: var mockData =...

AS3 try/catch out of memory

I m loading a few huge images on my flex/as3 app, but I can t manage to catch the error when the flash player runs out of memory. Here is the what I was thinking might work (I use ???? because i dont ...

热门标签