Flash Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsWeb DesignFlash Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old July 9th, 2008, 02:47 AM
Ontani Ontani is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2008
Posts: 20 Ontani User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 h 13 m 41 sec
Reputation Power: 0
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

Reply With Quote
  #2  
Old July 9th, 2008, 06:54 AM
Tann San Tann San is offline
Gotta get to the next screen..
Dev Shed Demi-God (4500 - 4999 posts)
 
Join Date: Nov 2003
Location: Legion of Dynamic Discord
Posts: 4,715 Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)  Folding Points: 11109 Folding Title: Novice Folder
Time spent in forums: 3 Weeks 1 Day 11 h 50 m 46 sec
Reputation Power: 580
Facebook MySpace
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.
  • Create a blank MovieClip in your object library, I call mine Linker.
  • In it's linkage popup tick "Export for ActionScript", "Export for runtime sharing" and "Export in first frame".
  • The "URL" box should have the relative path of the published file. Say your object library when published is called object_lib.swf, that's what you should see in the url box.
I manually create a class for this clip which is also called Linker, that tends to look like this:
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.
  • Now we move over to the main file. Open the library and then in the drop down at the top choose object_lib.fla (if that's what you called it).
  • Drag an instance of the Linker clip onto the Stage and give it an instance name. I just give it an instance name for the sake of it.
  • Switch the library back to the one for the current file. Right click the Linker clip that is now in there and confirm it is configured correctly.
  • It should have Linker as it's class i.e. the same as what it said in the object library file and the only tick should be "Import for runtime sharing" with the URL set to the object library.
  • I'll note that I've only tried this when the two swf files are in the same directory, I'm not sure how it will react with them in different locations.
Now we're onto the fun part, using it.
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));
               }
         }
   }
__________________
-Tann

-Vote for your favorite ActionScript editor here.

Reply With Quote
  #3  
Old July 9th, 2008, 02:28 PM
Ontani Ontani is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2008
Posts: 20 Ontani User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 h 13 m 41 sec
Reputation Power: 0
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.

Reply With Quote
  #4  
Old July 9th, 2008, 02:42 PM
Tann San Tann San is offline
Gotta get to the next screen..
Dev Shed Demi-God (4500 - 4999 posts)
 
Join Date: Nov 2003
Location: Legion of Dynamic Discord
Posts: 4,715 Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)  Folding Points: 11109 Folding Title: Novice Folder
Time spent in forums: 3 Weeks 1 Day 11 h 50 m 46 sec
Reputation Power: 580
Facebook MySpace
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.

Reply With Quote
  #5  
Old July 13th, 2008, 04:51 AM
Ontani Ontani is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2008
Posts: 20 Ontani User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 h 13 m 41 sec
Reputation Power: 0
Ah great this works perfectly. Also with libraryies in subdirectories.

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignFlash Help > ActionScript 3 - Problems with export for runtime sharing


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT