include/import separate AS3 file - actionscript-3

I am trying to just include a .as file in my flash application. I'm sure it's not that difficult and I'm just getting something slightly wrong, but at the top of my code I always put:
include {"Le Bot src/Skill.as";}
OR
import {"Le Bot src/Skill.as";}
to try and include a separate .as file. But, when I use include it comes up with the error:
expecting stringliteral before left brace
and when I use 'import' it comes up with the errors:
expecting identifier before left brace
expecting semicolon before left brace
I am just a beginner to AS3, is there any way to fix this problem?
Btw, if I remove the two braces on either side, then it comes up with another error

import locationOfASFile.Skill;
e.g. if your Skill.as file was located inside a directory named 'LeBotsrc' which was inside a directory named 'com'
import com.LeBotsrc.Skill;
Also your as package needs to reflect it's location. So inside Skill.as you would have
package com.LeBotsrc {

The include directive is not much used in AS3, since organizing code using packages and classes is easy. However, inlcude has a weird thing. No ending semicolon.
Try this:
include "Le Bot src/Skill.as"
So to sum it up:
include is not the same as import.
include does not use curly braces.
include MUST NOT have a semicolon at the end of the line.
inlcude must be on one line in the format of:
include "pathto/myfile.as"
Using include will add the actionscript in the specified file to the timeline where the include is used.
You could also accomplish the same thing by setting a document class that extends the main timeline or a symbol in the library. Doing so adds the complexity of needing to work with classes, but classes pack more than enough power and flexibility to make up for their additional complexity.
For example, using an include, you cannot specify a function or variable to be public or private. They are all public. Using classes makes it easier to make your code Object Oriented, which is a great way to make your projects more programmer friendly.

That Le Bot src\Skills.as should first be accessible by a correct relative path (package\name\class.as) from your project folder, then you do import package.name.class, placing your values instead of placeholders here. Say, you look into that Skill.as and find out:
package foo.bar {
import baz.*
...
public class Skill {
This means the AS file should be located at foo\bar\Skill.as where foo folder should be in the folder where is your FLA. In case of FlashDevelop, it should be inside src foder from *.as3proj file. Place it there, and add:
import foo.bar.Skill;
to whatever file or timeline you want to refer this class from.

Related

Create a Talk/Discuss link in a MediaWiki Plug-in

I am creating a MediaWiki plug-in that lists many files. For each file, I want to print a [Talk] or [Discuss] link. (It seems that the original name was talk but that it was renamed to discuss.) These links should be red if the page does not exist and blue if it does exist.
There should be a way to add such links in OutputPage.php, but I can't figure it out.
I know about these functions "foo":
$page = WikiPage::factory ( $title )
$talk = $title->getTalkPage()
But I'm not sure how to get $title from foo.
I'm also not sure how to change $talk into the appropriate HTML. I'd rather not add it to the output stream, because I'm building a lot of HTML separately, but I suppose I can refactor so that instead of passing my strings around, I pass around a handle to the output.
Why don't you use OutputPage::addWikiText() to add the appropriate link without worrying about the technical details: [[{{ns:11}}:Foo|Text]] for example.
Alternatively you can get $title from OutputPage::getTitle() for the current page, or from Title::newFromText() for any title you want to use. You can get $talk directly by specifying the correct namespace constant, which might be even easier than the trip via a WikiPage object.
Correct styling for the link can be done with the helper methods Title::exists() and one of the appropriate helpers for generating urls for pages.
See also https://doc.wikimedia.org/mediawiki-core/master/php/classTitle.html

Separate files for functions outside classes

It's a good practice to separate each class from the main code using
headers and sources. But what about functions? Let's say, I have a
function I would like to use across multiple classes and I don't
want to include this function as a method of a class.
If I decide to create a separate file for this function(s), should I
put everything inside .h or should I do as I do with classes
(separate .h and .cpp)?
Yes, whether it's a class or not it's still good practice to separate the declaration / signature (in the header file) from the definition / implementation (in the cpp file).
The code that calls the function does not need to know about how the function actually works - just how to call it.
This separation can avoid circular references that can sometimes otherwise occur. It avoids the compiler having to re-parse the definition every time the declaration is included.
Basically the reasons for separation between header and cpp are much the same for class and non-class functions.
However if you're using templates you will need to include the definition not just the declaration ( as you would with template classes ).
I'd suggest you put the functions in a namespace even if you don't put them in a class.

Importing separate SVG files to core-iconset

I have a bunch of SVG assets I'm currently storing each in their own file for my site. I want to use these SVG files as part of an iconset in polymer, so I can do stuff like <core-icon icon="tubers:potato">
The problem is that there seems to be no way to say something like
<core-iconset-svg id="tubers">
<svg id="potato">
... import svg file here without copy-paste ...
</svg>
</core-iconset-svg>
Which effectively means I have to take my SVG resource and wrap the polymer code around it. This isn't the end of the world, strictly speaking, but is is a little annoying (I want to treat SVG files as framework-independent resources like font or PNG resource).
However, the other problem I have found is that if I try to define my icons in different html files with this kind of structure:
/tuber-icons
/tuber-icons.html
/potato-icon.html
/parsnip-icon.html
and then have a distinct <core-iconset-svg id="tubers"> inside both icon.html files, and a <link rel="import"> directive in tuber-icons to bind it all together, it fails. It looks like you can only define a single core-iconset-svg directive with any given id value. This makes sense, but it means I cannot do icon="tubers:potato", but instead need to have a different top-level namespace for each icon.
The alternative is to concatenate all the SVG files into one big file, but that feels even worse, when it comes to copypasta errors, since then I end up with One Big File, which also has lots of copy-pasta'd SVG directives, each of which needs to be slightly massaged to fit the polymer process.
So, back to the question: is there any reasonable way to import an existing SVG directive that I'm serving as a static resource into a polymer core-iconset-svg directive?

phpDoc for object's properties

I've got file template.php, that is included in CBitrixComponentTemplate's method.
CBitrixComponentTemplate has property $this->__component, that is dynamicly filled with object EtmOrderAdd. EtmOrderAdd has property objValidator.
Now, when I am writing the file template.php, I need all these properties to be understood by phpDoc.
Here's the picture, illustrating my idea :
How should I write it?
Bitrix has almost no phpDoc for internal methods and functions. Also it has a plenty of legacy code, that won't show correctly with PhpStorm's code completion.
However, there are several things you can try to improve the situation:
Add bxApiDocs files as an External Library to PhpStorm.
This will add autocomplete for the internal bitrix methods
It seems like you've defined custom component class since $template->__component usually contains CBitrixComponent object that doesn't have objValidator property. So you need to add #property inside your class.php file of your component.

Where are these HTML elements created in the Joomla code?

I'm working on a site for a client, and I've never used Joomla before. I keep seeing elements in the HTML, that I can't find in the code. It's Joomla with Virtuemart and the bt_bazaar template.
For example, at the top of the page there's a div with the class bt_toolbar. When I search the entire public root of the site, it only turns up a match inside CSS, and this line from bt_bazaar/helpers/bt_helpers.php:
$this->bt_toolbar = '<jdoc:include type="modules" name="toolbar" style="BTxhtml" />';
Where is this toolbar? How do I find other module types in the code? Where is the class name bt_toolbar set?
Thanks,
Frankie
Its a Joomla Module.
You can find the joomla modules under
public_html/modules/mod_modulename.
here your module name is toolbar but this name may not be the module name (we can have option to use other names and same name).This name stands the position of the module.
go to admin side and in the module manager you can find a module name with toolbar position name.
eg: mod_somename.
Then go to front end modules/mod_somename/tmpl/default.php
This is the HTML out put of the module.
If you not found the same module on the above path or you changed the file not effecting it.
It may be overrided.
Then you can find the module at
public_html/templates/your_tmplate_name/html/mod_somename
it depends upon joomla version too.
Hope This will help you...
BTxhtml looks like module chrome so look in the modules.php file of your template and see if it is there.
Also name= tells you the name of the position the module is assigned to, so if you go to the module manager and filter on position toolbar you should find it.