CodingForums.com

CodingForums.com (http://www.codingforums.com/index.php)
-   Adobe Flex (http://www.codingforums.com/forumdisplay.php?f=63)
-   -   Inherit a class from an object? (http://www.codingforums.com/showthread.php?t=269586)

tinfanide 08-05-2012 06:59 AM

Inherit a class from an object?
 
Code:


<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" minWidth="955" minHeight="600" creationComplete="init();">
       
        <mx:Script>
                <![CDATA[
                       
                       
                        public function init():void
                        {
                               
                                // how to inherit a known class from the Canvas "box0"?
                                var obj:Canvas = new Canvas();
                               
                                obj.x = box0.x;
                                obj.y = box0.y;
                                obj.width = box0.width;
                                obj.height = box0.height;
                                obj.setStyle("backgroundColor",box0.getStyle("backgroundColor"));
                                Classroom.addChild(obj);
                               
                        }
                ]]>
        </mx:Script>
        <mx:HBox id="Panel" x="0" y="0" horizontalGap="100" width="100%" height="200">
                <mx:Canvas id="box0" width="200" height="100" backgroundColor="Red"/>                               
        </mx:HBox>
        <mx:HBox id="Classroom" x="0" y="100" width="100%" height="90%" backgroundColor="white">
               
        </mx:HBox>
</mx:Application>

If I already know the class of box0 (Canvas), how can obj inherit it from box0?
Like obj.x,
I do not type the exact value of box0.x. Instead, I use box0.x.
How can I do the same in class?


All times are GMT +1. The time now is 08:42 PM.

Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.