Go Back   Dynamic Drive Forums > General Coding > Flash
Search Dynamic Drive Forums:

Reply
 
Thread Tools Search this Thread
  #1  
Old 11-06-2008, 07:01 PM
evan's Avatar
evan evan is offline
Regular Coders
 
Join Date: Jan 2008
Location: Near Chicago
Posts: 237
Thanks: 103
Thanked 1 Time in 1 Post
Default It's time to start using external code

OK I have gone to school and learned about :

Inheritance, Encapsulation & Polymorphism

but to put it into practice I NEED to know some BASICS in how to structur, name and link .as files to .fla files correctly.

The tutorials I find talk about oop and I practice exples and my code does nothing.



so I started from scratch with the most barebones example:

1)create test.fla
2)create test.as
3) make sure test .as targets test.fla in the top right corner
4) in test.as I plug in these lines:


Quote:
package
{

public class test
{
public function test():void
{trace ("hello");
}

test();

}

}

5) I save everthything and run test.fla or publish test.swf and nothing happens.

Last edited by evan; 11-10-2008 at 09:32 PM. Reason: update
Reply With Quote
  #2  
Old 11-08-2008, 03:13 PM
Medyman's Avatar
Medyman Medyman is offline
Elite Coders
 
Join Date: Mar 2007
Location: Currently: New York/Philadelphia
Posts: 2,731
Thanks: 3
Thanked 519 Times in 507 Posts
Default

I'm not exactly sure what you're doing. Are you setting this as the Document class? Or are you attaching it to an object?
Reply With Quote
The Following User Says Thank You to Medyman For This Useful Post:
evan (11-10-2008)
  #3  
Old 11-08-2008, 08:00 PM
BLiZZaRD's Avatar
BLiZZaRD BLiZZaRD is offline
Elite Coders
 
Join Date: Aug 2005
Location: Other Side of My Monitor
Posts: 3,158
Thanks: 1
Thanked 62 Times in 62 Posts
Default

You have to call the .as files from the .fla.. in frame 1 actions layer put this:

Code:
#include "test.as"
save, publish, upload.
Reply With Quote
The Following User Says Thank You to BLiZZaRD For This Useful Post:
evan (11-10-2008)
  #4  
Old 11-09-2008, 02:19 AM
Medyman's Avatar
Medyman Medyman is offline
Elite Coders
 
Join Date: Mar 2007
Location: Currently: New York/Philadelphia
Posts: 2,731
Thanks: 3
Thanked 519 Times in 507 Posts
Default

Quote:
Originally Posted by BLiZZaRD View Post
You have to call the .as files from the .fla.. in frame 1 actions layer put this:

Code:
#include "test.as"
save, publish, upload.
Blizz, that would be true for AS2. I'm pretty sure Evan is using AS3 and CS3's OOP techniques.
Reply With Quote
The Following User Says Thank You to Medyman For This Useful Post:
evan (11-10-2008)
  #5  
Old 11-10-2008, 11:40 AM
evan's Avatar
evan evan is offline
Regular Coders
 
Join Date: Jan 2008
Location: Near Chicago
Posts: 237
Thanks: 103
Thanked 1 Time in 1 Post
Default

I think this would be a document class as in this would not be in a folder but reside in the same folder as the fla.

How is it different? I know partly because I have worked with other scripts but not on my own from scratch. if it's in a folder I think ithe file/class and folder need to be named the same.

In this case I name the .as the same as the .fla and ensure they are linked via the upper right hand corner selector.
Reply With Quote
  #6  
Old 11-10-2008, 02:08 PM
Medyman's Avatar
Medyman Medyman is offline
Elite Coders
 
Join Date: Mar 2007
Location: Currently: New York/Philadelphia
Posts: 2,731
Thanks: 3
Thanked 519 Times in 507 Posts
Default

I'm not sure what you're referring to in terms of the "upper right hand corner selector". You could have workspace configured than I have mine, but I don't see anything related to relating AS classes in the upper right hand corner of my screen.

The Document class is set in the Properties panel.

If you haven't already, watch the following tutorials by Lee Brimelow. I think they'll give you a better idea of using OOP techniques with AS.

Introduction to OOP (AS2)
Using the Document Class
Object Oriented Scrollbar 1
Object Oriented Scrollbar 2

Edit: Are you using CS4 now?
Reply With Quote
The Following User Says Thank You to Medyman For This Useful Post:
evan (11-10-2008)
  #7  
Old 11-10-2008, 05:07 PM
evan's Avatar
evan evan is offline
Regular Coders
 
Join Date: Jan 2008
Location: Near Chicago
Posts: 237
Thanks: 103
Thanked 1 Time in 1 Post
Default How do I create more than one script and appy it to an fla?

I did catch something I missed from the document class tutorial in the properties I forgot to set up the script in the Document class window. It figures it would be something dumb like that.

How do I create more than one script and appy it to an fla?

Last edited by evan; 11-10-2008 at 09:31 PM. Reason: update
Reply With Quote
  #8  
Old 11-11-2008, 02:32 PM
BLiZZaRD's Avatar
BLiZZaRD BLiZZaRD is offline
Elite Coders
 
Join Date: Aug 2005
Location: Other Side of My Monitor
Posts: 3,158
Thanks: 1
Thanked 62 Times in 62 Posts
Default

Quote:
Originally Posted by Medyman View Post
Blizz, that would be true for AS2. I'm pretty sure Evan is using AS3 and CS3's OOP techniques.
So attaching an external .as file is different in AS3? Or am I missing the actual question?
Reply With Quote
  #9  
Old 11-11-2008, 04:57 PM
Medyman's Avatar
Medyman Medyman is offline
Elite Coders
 
Join Date: Mar 2007
Location: Currently: New York/Philadelphia
Posts: 2,731
Thanks: 3
Thanked 519 Times in 507 Posts
Default

Quote:
Originally Posted by BLiZZaRD View Post
So attaching an external .as file is different in AS3? Or am I missing the actual question?
Yup, it's different and it really depends on what you want to do. You can "include" external ActionScript using the include directive.

AS3 gets rid of the the # in front though. So, to include regular AS3, you might do something like:

Code:
include "myactionscript.as"
However, these included bits should really not be classes. If you're creating a Document class, you can attach it via the properties panel. Or, if you're attaching classes to objects, you can set it in the object's linkage properties.
Reply With Quote
  #10  
Old 11-11-2008, 04:59 PM
BLiZZaRD's Avatar
BLiZZaRD BLiZZaRD is offline
Elite Coders
 
Join Date: Aug 2005
Location: Other Side of My Monitor
Posts: 3,158
Thanks: 1
Thanked 62 Times in 62 Posts
Default

hmmm... interesting. In 3 versions of Flash we went from not using .as at all to relying on them completely.. funny.
Reply With Quote
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 10:40 PM.

Home - Contact Us - Archives - Link to DD - Top 

Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.