تعيين حيوي مصدر الصورة في عنصر العارض لا يعمل في فليكس / AS3

StackOverflow https://stackoverflow.com/questions/1613784

سؤال

ولدي العارض البند المخصص الذي يعرض الصور:

<mx:DataGrid dataProvider="{friends.friend}" id="friendsGrid" width="240" 
        rowCount="3" variableRowHeight="true" headerHeight="0" 
        horizontalCenter="true" backgroundAlpha="0" borderThickness="0"
        useRollOver="false" selectable="false">
        <mx:columns>

            <mx:DataGridColumn width="80" paddingLeft="20">
                <mx:itemRenderer>
                    <mx:Component>
                        <mx:HBox height="50" horizontalAlign="center" 
                            verticalAlign="middle" horizontalScrollPolicy="off" verticalScrollPolicy="off">
                            <mx:Image  source="{outerDocument.getProfilePic(data)}"/>
                        </mx:HBox>
                    </mx:Component>
                </mx:itemRenderer>
            </mx:DataGridColumn>

        </mx:columns>
    </mx:DataGrid>

وعلى getProfilePic وظيفة:

public function getProfilePic(data:Object):String{
                if(String( data.image_path.text() ) == ""){
                    return "../assets/no_profile_pic.png";
                }else{
                    return data.image_path;
                }
            }

والمسألة هي أنني عندما تعيين "لا يوجد ملف تعريف الموافقة المسبقة عن علم" صورة، فإنه لا تظهر. أحصل على أن مضحك تبحث "صورة لا يمكن العثور على" الرمز في المكان. إذا كنت تضع صورة في ../assets في خدمة بلدي، وصورة يوضح ما يصل. التضمين هو أكثر مثالية. لذا فإن السؤال هو ... كيف يمكنني تضمين صورة في هذه الحالة؟

هل كانت مفيدة؟

المحلول

وربما حاول هذا:

<mx:itemRenderer>
    <mx:Component>
        <mx:HBox height="50" horizontalAlign="center" verticalAlign="middle" horizontalScrollPolicy="off" verticalScrollPolicy="off">
            <mx:Script>
                <![CDATA[
                    override public function set data(value:Object):void
                    {
                        super.data = value;

                        if(String(data.image_path.text()) == ""){
                            profileImage.load("../assets/no_profile_pic.png");
                        }
                        else{
                            profileImage.load(data.image_path);
                        }
                    }
                ]]>
            </mx:Script>

            <mx:Image id="profileImage" />
        </mx:HBox>
    </mx:Component>
</mx:itemRenderer>
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top