Search code examples
flashactionscript-3componentsflash-cs3

Flash CS3 Compoenent "import" method and stucture?


hi I had seen one code of the yahoo map component for the flash cs3

like

import com.yahoo.maps.api.YahooMap;

var map:YahooMap = new YahooMap(); 

// include app-id, width and height
map.init("YD-vbXGXH4_JXs3ihv485hjXA--", 550, 400);  

addChild(map);

What i want is to make the import structure is like above "com.yahoo.maps.api.YahooMap;"

i created a small component and imported to flash lib all are working fine. But one problem is there it contains 3 functionality. ie in my component i need to call there sub components from inside my orgianl component.

so i just need to

import mycomponent;
var myC = new mycomponent();
addChild(myC);

But i would like to call with my componentname like

 import com.MYComponen.subcomponent1;
 import com.MYComponen.subcomponent2;
var myC = new subcomponent1();
addChild(myC);

for this how i need to put my class and how can i make this path. Hope you understood. sorry for my bad english :(


Solution

  • You have to put your classes in a directory like :

    /your root of source files/com/MyComponen/subcomponent1.as
    

    and

    /your root of source files/com/MyComponen/subcomponent2.as
    

    And into you both classes declare the package where they belongs:

    for subcomponent1 for example

    package com.MyComponen {
     public class subcomponent1 {
      //...
     }
    }
    

    As a naming convention: Packages names begin with a lower case and Classes with an upper case:

    so your example become: package com.myComponen {...} and public class SubComponent1 {...}