#include vs import

I'm trying move towards a more oop approach in my coding but
often wonder how far to go. My sites are entirely in Flash and load
all the initial .swfs in sequence behind a progress bar until the
home page can go active, after that the loading sequence continues
behind the scenes until the whole site is loaded. I've cleaned up
the code for this loading sequence into a set of functions with a
single initiating call and put it in an .as file which I #include.
Having gone that far it would be fairly simple to convert this to a
class but apart from being "the right thing to do", would there be
any advantage? The code runs only once and I easily re-use it on
multiple sites by storing the .as file in a common folder.

Bob,
> Having gone that far it would be fairly simple to
convert
> this to a class but apart from being "the right thing to
do",
> would there be any advantage?
This isn't always true in real life, but in programming,
"the right
thing to do" is a flexible concept. In programming, "the
right thing to do"
is generally whatever works best for your workflow, or the
workflow of your
team. If you don't see the benefit of a certain recommended
best practice,
why go to the trouble?
For example, I like Turkish coffee. The way I prepare it,
the process
takes quite a while. I have to grind my beans into,
essentially, flour. I
add the "flour" to a special conical pot, along with sugar,
cardamom, and
anise, and heat it -- but not to boiling -- until it starts
foaming. That
takes about 20 minutes. It's extra work, but I absolutely
love the stuff.
Totally worth it. And it helps my workflow. ;)
In Flash, when coding on the timeline, I put (most) of my
code in a
layer dedicated to solely to ActionScript. Why? Because I
personally find
it easier to locate my code when it's all in one place. Most
of the
developers I know find this practice equally helpful, so it's
no surprise
that it's a recommended best practice.
I personally prefer the dot notation approach to event
handling in AS2.
To me, the older approach -- on() and onClipEvent() -- is
less powerful and
flexible. (See the link for details.)
http://www.quip.net/blog/2006/flash/museum-pieces-on-and-onclipevent
As it turns out, avoding on() and onClipEvent() is nowadays
considered a
recommended best practice. It's the "right thing to do" ...
but plenty of
folks still use on() and onClipEvent(). At least, they do in
AS2 (it's not
possible in AS3). There are rare occasions when I still use
the old
approach -- for a quick banner ad, say -- and I do so when
that's the most
convenient route.
In your case, there may not be an immediate advantage to
converting your
#include code into a bona fide class. (Of course, there might
be after all!
Only you can determine the answer.) The general reason for
writing
something as a class is to make it portable; that is,
conveniently reusable.
I'm in the middle of a tutorial series at CommunityMX.com
right now that
describes a class for wiggling the characters in a string of
text. I'm sure
you've seen plenty of nifty text animations in Flash ... the
ones where,
say, characters fly in from the side and flip into place.
This sort of
animation requires individual text fields for each character,
so that each
character (each text field) can be animated individually.
http://www.communitymx.com/abstract.cfm?cid=ECBF0
To make this potentially tedious effort reusable, the
routine that
creates all those text fields can be wrapped up in a
function, then called
from any frame after the function's definition (including the
frame in which
it appears). To make things even easier, the function (and
any related
functions) can be wrapped up in a class. This reduces the
amount of code
that appears in the timeline -- which is also true of your
#include code --
and, in the case of the wiggling text, can be as easy to use
as this:
var wt:WiggleText = new WiggleText("Here's the string");
wt.x = 200; // position the wiggle text
wt.y = 300;
The WiggleText class works just like the Date class, or the
Array class,
or any other convenient "building block" in the ActionScript
arsenal.
Writing a class gives you an actual *object* that can be
manipulated like
any of the native objects in Flash. If the concepts behind
your #include
code can be distilled into a reusable object -- something
flexible and
configurable -- then it will probably help your workflow, in
which case
writing it as a class is the right thing to do. If not (but
if you're
interested in writing classes), then you can leave it as
#include for the
time being and experiment with the concept in another venue.
Until it
becomes fluent. When class writing makes sense on a gut level
to you,
you'll know when the practice is worth it in a given usage
scenario.
A chess coach often suggested that I not make a move ...
until I had
thought through all the reasons why moving that particular
piece was a good
idea. Sure, I could study opening moves ... I could memorize
which moves
were among the group of "right things to do," but until I
understood why --
and agreed that reason was right for my game -- ... well, you
get the idea.
David Stiller
Co-author, Foundation Flash CS3 for Designers
http://tinyurl.com/2k29mj
"Luck is the residue of good design."

Similar Messages

  • Accidental delete backup file of my iPhone. It includes very important info. Please help me to recover deleted backup file. Very urgent.

    I accidently delete my backup file of my iphone in my mac with Lion OS. It includes very important contact info. Please kindly provide me the solution to recover my backup. Very very appreciate.

    Well if you manually deleted it from the file system, it might be in the trash? Otherwise, I don't know if there is a way to recover one.

  • When I sync my iphone to be able to import all the photos from a specific photo album onto my iphone.. why do the videos included not import?!

    So I used to have an iPhone 5 with 7000+ photos inc videos. I finally decided to free up some memory by exporting the entire camera roll into a specific folder on my windows pc. In the album are all the photos and videos, matching the content from my camera roll (obviously). Now I have the 5S and would like the entire library of photos back into my photos app. So obviously it was as simple as plugging in my iPhone and clicking the photos tab, then 'Sync Photos from' and choosing that specific folder that I had previous exported my camera roll into. I then ticked the include videos checkbox. After the sync was completed, I then went onto my photo album and found the correct album being listed. However the number of photos on the iphone album did not match the number of photos in the actual album on my windows pc. Then I realised the reason.. the videos have not transferred? I've tried resyncing several times. iTunes identifies the album to exist the correct number of photos/videos as it should do, yet my iphone still has not imported any videos. Is there anything i'm doing wrong?! Thanks in advance for any help.

    Seems that you can no longer hide them on your phone.  Try doing so in iTunes: http://support.apple.com/kb/HT4919.

  • 4.0EA3: File type associations lost - can they be included when importing previous settings please?

    Hi,
    I've just noticed that my file type associations have been lost when upgrading from 3.2 to 4.0EA3
    Can you ensure that these are included in the imported preferences please?
    thanks

    Fixed. The problem for me was my desktop's USB hardware.
    I purchased a USB PCI Express card and the problems went away. I still canno get calendar to sync but I understand that is an apple issue. I had read somewhere that some motherboard chipsets are having problems that become evident with iPhone syncing.
    I also want to thank Lawrance for all his input and support (another post "Why does iTune say my 16 gig 3G iPhone has 4gig capacity")

  • Xsl:include xsl:import and clob

    I can use xslprocessor.processXSL to perform transformation where the XML and XSL are in CLOBs.
    However, is it possible to perform transformation if the XML and XSLs are in CLOBs and the XSL have xsl:include and xsl:import?
    Thanks and Regards,
    Andy

    It will be supported in later release.

  • Images (including stamps) imported as negative.

    For no apparent reason, images (jpeg, tif, pdf, etc) imported into Acrobat 9 are being imported as negatives.  This includes previously define stamps, including the standard ones that came with Acrobat. The images load correctly in Photoshop or any other image display program but load as negatives into an Acrobat document.  Converting a JPEG to PDF by opening with Acrobat, for example, results in a negative image in Acrobat.  This occurred suddenly after many months of working beautifully.  Does anyone know where the setting would be found?  I've looked all over and can't find it, nor can I find a reference to the problem.

    Blotches of color could indicate that the file is corrupted. This is almost always a hardware problem ... camera card, card reader or USB cable, hard disk. Try using other hardware to transfer your photo to a different hard disk. see if that helps.

  • .THM Sidecar Files Not Included When Importing Video Directly From Camera (Canon 7d)

    Lightroom (3.4) has always copied the .THM sidecard files when I have imported video files from my Canon 7d using a card reader.  However I am on a trip and have forgotten my card reader so I have been copying directly from the camera and for some reason Lightroom is not copying the .THM sidecar files and thus I am missing all my valuable metadata such as camera, exposure, focal length, ISO, etc. associated with the video files.  Very frustrating!
    Any ideas?

    Also because I do not have a card reader I cannot grab the .thm files myself.  Mac OS X (and I think Windows) just see the camera as a "device" and offer to import but do not give me direct access to the files.  Maybe if there is an app that will allow me to do that when the camera is connected I can work around this for now.

  • Import Duties Included in Standard Price

    Hi,
    At the time of Creating Cost Estimate we found that system is taking CVD, Ecess & HeCess in calculation of Standard Price..where as in Costing Variant we have defined Valuation Method is from Purchase Info Record.
    We have not included the Import Condition type in PIR.
    Please help me that from where it is picking.
    Br,Vivek

    Hi,
    Please also review note 351835 which deals with valuation with purchasing info records. Please make sure that a valid price can be found as per your valuation strategy for the plant-dependent info record.
    The first step for strategy 'price of inforecord' is to determine the vendor. After this, second step is to read the inforecord for
    this vendor looking for a price against valutaion variant.
    In other words: System do only for this vendor/inforecord a price simulation and interprets for example scales.
    If no price for this vendor/inforecord could be determined, system DO NOT search for an other vendor.
    In this case system searches for the second price strategy against valuation variant.
    Depending on how you want to have your prices and vendors selected, there are two possiblities:
    - The price from the cheapest vendor is picked by default.
    - If you want the system to choose a specfic vendor, you can create a  source list and define the vendor as fixed supply source.
    The system searches for the last document (purchase order or scheduling agreement), which has been defined in the purchasing info record. This is updated if the 'InfoUpdate' indicator is set in the purchase order or scheduling agreement. As a result, however, the conditions which are directly in the info record are not changed. You can check which purchase order or which scheduling agreement is currently defined in the info record by choosing 'Environment -> Last document' in the info record display.
    If you do not want the system to find the price from purchase orders or schedule agreements, there are other options such as condition tables. Via the valuation strategies A or B the material is valuated with the conditions from the condition table (see T-M/08). But the original price has to come from the purchase inforecord. For strategy A, the conditions within the inforecord are taken into account and for strategy B the purchase order is requiered as the last document that updates the inforecord.
    In addition to this, you can assign conditions depending on the origin group (see T-OKYO).
    Alternatively If you want an other behavior you can determine an own price in the userexit of valuation variant (EXIT_SAPLCK21_002).
    regards
    Waman

  • JSP, c:forEach, and import / include(s)

    To any,
    I'm having a bit of a problem. I'm currently working on a webapp which basically translates information in an XML file to a neat webpage, using Spring MVC / JSP / JSTL / the works.
    There's several items in the XML file that are of the same format, which as such use the exact same bit of HTML to represent. So, I figured, let's do it like so and so:
    <c:forEach items="${plugin.executions.execution}" var="execution">
         <jsp:include url="execution.jsp"/>
    </c:forEach> Buut this doesn't work, most likely because execution.jsp is parsed / compiled not at runtime, but at compile time (or whatever), leading to an error (which I can't see by the way) because the 'execution' variable isn't present in execution.jsp.
    Note that I'm not getting any errors (at least, not in the console using Maven, the jetty:run command), just a blank screen with nothing in there.
    What I'm looking for is a solution to this. Basically, I'm looking for an include statement that chucks the html / jsp found in execution.jsp into the forEach loop, then compiles and displays it.
    I've tried <jsp:include>, <c:import>, <%@ page import=""%>, but none of the three works. I've asked for an alternative, but those include creating my own tag library (although I don't think that'll work) or switching to an entirely different view framework (like Wiicket). Seeing that it'll take days to convert the application to a different framework (including AppFuse, I think, which is the app I'm building on top of), I'd rather not.
    The other alternative is copy / pasting a load, which will work (I know it'll work), but making a change will result in making half a dozen changes, one for each copy / paste job. I'd prefer a solution like this.
    Help me plox :(.

    On second thought, nevermind. Re-asked my colleague, and he pointed out the use of tag files
    http://java.sun.com/j2ee/1.4/docs/tutorial/doc/JSPTags5.html
    Which works excellently, imho.

  • Difference Betwen #include statement and Import statement

    What is the Difference between #include and Import statements!

    Why do you need to shout! Are you unware that English has a question mark that is used at the end of a question sentence! Java doesn't have #include! It only has import!
    Import in Java simply tells the compiler that when you say, for example, List, you mean, for example, java.util.List! It does not affect the generated class file in anyway!
    #include in C/C++ causes the body of the reference file to be inserted into the compilation stream! So, unlike Java's import, that file actually gets compiled into the final output!

  • Is XSLT with import/include on database side supported?

    Hi
    I use server side (Oracle 10.2) XSL transformation (in particular DBMS_XSLPROCESSOR package) with source XML and XSLT files stored as XMLType columns. It works Ok. However I did not manage to get it working when importing spreadsheets into XSLT files like this:
    <xsl:import href="generic-elem-to-csv.xslt"/>
    Does Oracle database support Stylesheets with Include and Import to transform XML files on database side?
    Thanks,
    Vlad

    Hi,
    According to your post, my understanding is that you had problems to import the SharePoint SP1 environment site library to SharePoint SP2 environment.
    Alex is right, now we could not import the site from the lower version to the earlier version directly since SharePoint 2010 SP2.
    If you wanted to import the library to the new environment, you should first upgrade the SharePoint environment to the SP2, then export the library.
    Now you can import the library without the issue.
    Thanks,
    Jason
    Forum Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact
    [email protected]
    Jason Guo
    TechNet Community Support

  • Autotype support for xsd import and xsd include statement

    Hi,
    I am using Weblogic 7.0.1. While using autotype for a Schema, I get the error unable to resolve element ref: "qb:WireCenterCLLI. This element exists in an xsd imported in the main XSD which in turn includes a few XSD's. I saw few posts which indicated there were issues with autotype recognising xsd:import and xsd:include statements. Were these issues fixed? If so, what SP were they fixed in?
    My XSD:
    <?xml version = "1.0" encoding = "UTF-8"?>
    <xsd:schema xmlns = "http://www.qwest.com/XMLSchema"
    targetNamespace = "http://www.qwest.com/XMLSchema"
    xmlns:qb = "http://www.qwest.com/XMLSchema/BIM"
    xmlns:xsd = "http://www.w3.org/2001/XMLSchema"
    elementFormDefault = "qualified">
    <xsd:import namespace = "http://www.qwest.com/XMLSchema/BIM" schemaLocation = "/u/skarani/sia_code/xsd/ProjectSpecific/SIA/BIM/AddressValidationInclude_v01_00.xsd"/>
    <xsd:include schemaLocation = "/u/skarani/sia_code/xsd/ProjectSpecific/SIA/Common/AddressValidationCommon_v01_00.xsd"/>
    <xsd:include schemaLocation = "/u/skarani/sia_code/xsd/ProjectSpecific/SIA/Common/RequestMessage_v02_01.xsd"/>
    <xsd:element name = "AddressValidationByServiceIdRequest">
    <xsd:complexType>
    <xsd:complexContent>
    <xsd:extension base = "WebServiceRequestT">
    <xsd:sequence>
    <xsd:element name = "InputData" type = "AddressValidationByServiceIdInputDataT">
    </xsd:element>
    </xsd:sequence>
    </xsd:extension>
    </xsd:complexContent>
    </xsd:complexType>
    </xsd:element>
    <xsd:complexType name = "AddressValidationByServiceIdInputDataT">
    <xsd:sequence>
    <xsd:element ref = "qb:WireCenterCLLI" minOccurs = "0"/>
    <xsd:element ref = "qb:WireCenterPrimaryNPANXX" minOccurs = "0"/>
    <xsd:element ref = "AdministrativeArea" minOccurs = "0"/>
    <xsd:element ref = "qb:PostalCode" minOccurs = "0"/>
    <xsd:element ref = "qb:BTN"/>
    <xsd:element name = "ParsedAddressFlag" type = "xsd:boolean" minOccurs = "0">
    </xsd:element>
    <xsd:element ref = "qb:CCNA" minOccurs = "0"/>
    <xsd:element name = "CompanyCode" type = "xsd:string" minOccurs = "0">
    </xsd:element>
    <xsd:element ref = "AssignedHouseNumberFlag" minOccurs = "0"/>
    <xsd:element ref = "GSGRqmtFlag" minOccurs = "0"/>
    <xsd:element ref = "TNStatus" minOccurs = "0"/>
    </xsd:sequence>
    </xsd:complexType>
    </xsd:schema>
    Thanks
    Shekhar

    Hmmmm.... No answers!!!
    Has anyone had success using autotype with an xsd having include and import statements???
    Thanks
    Shekhar

  • Diferrence between import and include

    can any one pls tell me whts d diferrece between import and include.........thanks in advance.......

    myagi wrote:
    anyway include is not a java keyword,but i need to know d diff between include and import........Well, haven't you just described a difference?

  • Is there a way to create a collection based on the "previous import"?

    is there a way to create a collection based on the "previous import"? that would make it easy to mobile sync the last import to my ipad, and do further picking/rejecting while away from my laptop.

    well, yes, of course i could do it that way. i guess i wasn't specific enough. is there a way to create a smart collection, with the photos in the "previous import" as members of the smart collection.  earlier i mentioned about using this smart collection to mobile sync with my ipad, to do further flagging.
    so my intention, use a smart collection to mobile sync with my ipad, and the smart collection to include the photos from my previous import.
    i guess another way to ask the question, is there a way to create a smart collection, by using some rule or condition in the smart collection, to automatically include previous import photos.
    the documentation says that "previous import" is a collection, even though it shows up in the catalogue side bar section. but i see no way to choose that collection when making a smart collection.
    jd

  • Import statement is not working

    hi everybody,
    I have a directory under which I have a number of sub-directories. Lets call this directory "parent_directory". under this directory I have another directory called "child_1". Under "child_1" I have another subdirectory called "child_2". Now I have a code in child_2 that has the following statement:
    import program_1;
    //this is a program present in the parent directory. lets call it
    //program_1.java
    when I am compiling I am getting an error saying:
    program_2.java:28: '.' expected
    import program_1;
    ^
    1 error
    program_2.java is the program present in child_2 in which I have included the import statement.
    If I change the ";" to "." then again error appears as the import statement only needs the name of the class and doesnot need the extension.
    I will be very grateful to you if you could please suggest me a way around this.

    This questions belongs in the "New to Java" forum ...
    sigh
    Anyways, import works on package names with trailing * or full qualified class names, e.g.import mypackage1.*; // imports all classes in mypackage1
    import mypackage2.MyClass2; // imports MyClass2 from mypackage2So instead of import program_1; you need to do
    1. ensure that program_1 is in some package
    2. ensure that your directory structure mirrors your package structure (same names!)
    3. ensure that your CLASSPATH is either not set at all or points to the parent dir of your topmost package
    Example:
    Directory structure:C:\tmp\java\top\
    C:\tmp\java\top\MyClass1.java
    C:\tmp\java\top\bottom\
    C:\tmp\java\top\bottom\MyClass2.java
    CLASSPATH=".;<java install dir>\jre\lib\rt.jar;C:\tmp\java"Source for MyClass1.java:package top;
    public class MyClass1 {
    }Source for MyClass2.java:package top.bottom;
    import top.MyClass1;
    public class MyClass2 {
      private MyClass1 myClass1;
    }

Maybe you are looking for

  • Windows XP rewrote my Mac.

    Hi, I posted this under intel iMac but it was suggested I come here for help. I've pieced together all the info from that post. My sister was using my computer and wanted to use Windows XP Professional Service Pack 2 in VMWare so booted a CD of Windo

  • How to handle JCO.AbapException on JCO call in ABAP

    Hello Forum, I am implementing an JCO Server scenario. I use dynamic repositories like Example7.java from the JCO documentation. Example7 throws an JCO.AbapException if anything went wrong, e.g. the function is not implemented. My coding is like:    

  • How can I edit a scanned pdf file?

    How can I edit a scanned pdf file? 

  • Consumer missing in R/3

    Hi , I created one Cosumer in Quality system,. crm but the same is not available in r/3 system. I want to know how we can able to check wat can be the problem. Thanks & Regrads prajith P

  • What is the best way to store temporary files on Azure?

    I am using the Google dot net api to import events from a google calendar.  In order to do the google authorization, it normally uses code like this:  private static readonly IAuthorizationCodeFlow flow = new GoogleAuthorizationCodeFlow(new GoogleAut