|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
ActionScript 3 - Problems with export for runtime sharing
When I want to export a flash project to use this from another flash project I'm getting an error when I want to create a new instance from the external library. This is when i have export for runtime sharing checked.
When I do the exact same thing with in the external library export for runtime sharing unchecked, everything works like a charm. But need them to be able to export for runtime sharing because i don't want to include them in my library that my current project uses. I just want to be able to access them externaly. The code of the base project on frame1: Code:
import Hair;
var _hair:Hair = new Hair;
_hair.setTypeOf("Hair_Male_001");
this.addChild(_hair);
The code of Hair.as: Code:
package
{
import flash.display.MovieClip;
import flash.utils.getDefinitionByName;
import Hair_Male_001;
public class Hair extends MovieClip
{
private var _hair:MovieClip;
public function Hair()
{
}
public function setTypeOf(hairType:String)
{
_hair = new(getDefinitionByName(hairType))
this.addChild(_hair);
}
}
}
The Error: 1172: Definition Hair_Male_001 could not be found. import Hair_Male_001 Here are my Files: http://storage.purevision.be/Flash_...ash_Problem.rar Thanks in advance for your help Greetings |
|
#2
|
|||
|
|||
|
Hi, you have to do a bit of voodoo to get this to work. The first step is to create what I call a linker clip.
Code:
// Linker.as
package
{
import flash.display.MovieClip;
public class Linker extends MovieClip
{
public function Linker()
{
}
}
}
For each library item you want to use in the other file set the linkage options to be "Export for ActionScript" and "Export in first frame", leave "Export for runtime sharing" unticked. I let it auto-generate the class file for these items. That's all for the object library, save and publish but remember to leave the file open in Flash.
Code:
import Hair;
// Added the braces at the end
var _hair:Hair = new Hair();
_hair.setTypeOf("Hair_Male_001");
this.addChild(_hair);
The class then looks like: Code:
package
{
import flash.display.MovieClip;
import flash.display.DisplayObject;
import flash.utils.getDefinitionByName;
public class Hair extends MovieClip
{
public function Hair()
{
}
public function setTypeOf(hairType:String):void
{
var dynamic_class:Class = Class(getDefinitionByName(hairType));
var new_hair = new dynamic_class();
this.addChild(DisplayObject(new_hair));
}
}
}
|
|
#3
|
|||
|
|||
|
If i keep my library opened and want to import the external library into my project i get the error that the file is allready opened.
|
|
#4
|
|||
|
|||
|
You don't use the import option, you do as I described wherein you just drag n drop the linkage clip from the object library onto your main files stage. That will auto-add the linkage item to your main files library. The import external library option serves another purpose.
|
|
#5
|
|||
|
|||
|
Ah great this works perfectly. Also with libraryies in subdirectories.
|
![]() |
| Viewing: Dev Shed Forums > Web Design > Flash Help > ActionScript 3 - Problems with export for runtime sharing |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|