My class was not showing up in autocomplete. It was part of another file and I copied it into it's own file.
The reason it was not showing up was because it was marked internal.
package com.example.model
{
/**
* Holds data.
* */
internal class ChartItemData extends Item {
}
}
The part that was confusing was that it was the only class inside the package. I didn't know you could do that.
I changed it to public and it was immediately visible.
Related
I'm trying to get my movieclip to jump automatically back to frame 1 as soon as it lands on the final frame.
I labeled the final frame as "final_frame", the title is the error I'm getting and this is the code I used:
private function handleTimelineEvent(e:TimelineEvent):void {
if (e.currentLabel === final_frame) {
gotoAndStop(1);
}
}
Am I making an obvious mistake? Also, if there's an easier/better way to do this, I'll be glad to hear it!
The class property descriptors can only be used in class files (external .as files). These descriptors (keywords) include: private protected public static and internal. see documentation for more details
Since you are using timeline code (which automatically creates it's own class file for you behind the scenes), you need to strip out all these keywords.
In your case, just removing the keyword private from your function declaration will do the trick. So it should look like this:
function handleTimelineEvent(e:TimelineEvent):void {
if (e.currentLabel === final_frame) {
gotoAndStop(1);
}
}
I'm working with the OSMF library REOPS [https://code.google.com/p/reops/]. Particularly the REOPS.zip project files. [https://code.google.com/p/reops/downloads/detail?name=REOPS.zip]
When trying to compile the RE_Skin_Compiled.fla, I receive the following error:
ClosedCaptionField.as, Line 14, Column 15 1144: Interface method get text in namespace com.realeyes.osmfplayer.controls:IClosedCaptionField is implemented with an incompatible signature in class com.realeyes.osmfplayer.controls:ClosedCaptionField.
This error is detailed by Adobe here: http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/compilerErrors.html
Which states:
Method signatures must match exactly.
There are only two methods in the IClosedCaptionField interface, and they do match what is implemented in the ClosedCaptionField class.
IClosedCaptionField.as
package com.realeyes.osmfplayer.controls
{
import flash.text.TextFormat;
public interface IClosedCaptionField extends ISkinElementBase
{
function get text():String;
function set text(p_value:String):void;
}
}
ClosedCaptionField.as
package com.realeyes.osmfplayer.controls
{
import flash.text.TextField;
import flash.text.TextFormat;
/**
* Displays captions for media in the control bar. Accepts HTML
* text (limited by Flash HTML display). This component starts
* out invisible, and must be manually made visible.
*
* #author RealEyes Media
* #version 1.0
*/
public class ClosedCaptionField extends SkinElementBase implements IClosedCaptionField
{
public var cc_txt:TextField;
public function ClosedCaptionField()
{
super();
//start up hidden
//this.visible = false;
//text = "";
}
/**
* text
* The HTML text to display
*
* #return String
*/
public function get text():String
{
return cc_txt.htmlText;
}
public function set text(p_value:String):void
{
if (cc_txt)
{
cc_txt.htmlText = p_value;
}
trace("set cc text: " + p_value);
}
}
}
In the RE_Skin_compiled.fla Actionscript Settings, I have added the path to the REOPS\src\ folder, and it is able to find the classes when checking the properties on the AS Linkage.
Any ideas on what I might be missing in order to get the RE_Skin_Compiled.fla to correctly compile along with it's skin classes?
In the RE_Skin_compiled.fla, there is an included [underscore]code[underscore] compiled clip object which was causing the issues with conflicting classes.
After deleting the [underscore]code[underscore] compiled clip, the fla compiled with the linked classes correctly.
I have a custom Flex Toggleswitch component that changes the text values of the switch.
package skins
{
import spark.skins.mobile.ToggleSwitchSkin;
public class MyToggleSwitchSkin extends ToggleSwitchSkin
{
public function MyToggleSwitchSkin()
{
super();
selectedLabel="Serviceable";
unselectedLabel="Fault";
}
}
}
If I add the control using the MXML tag, it works fine. However, when I add the component using action script, it does not.
import skins.MyToggleSwitchSkin;
public function addToggle():void {
var myCustomToggle:MyToggleSwitchSkin = new MyToggleSwitchSkin();
hgroup.addElement(myCustomToggle);
}
The control dsiplays but will not activate.
Any ideas what I have missed?
Without seeing your MXML Code, it's tough to compare your two approaches, but I believe #al_Birdy addressed the problem. You've created a custom ToggleSwitchSkin; not a custom ToggleSwitch.
Modify your addToggle() method like this:
public function addToggle():void {
var myCustomToggle:MyToggleSwitch = new MyToggleSwitch();
myCustomToggle.setStyle('skinClass',skins.MyToggleSwitchSkin);
hgroup.addElement(myCustomToggle);
}
I suspect you'll have better luck.
I have a assets file that embeds things,
[Embed(source='assets.swf', symbol='block')]
public static const SYM_BLOCK:Class;
I wish to expand on my block symbols class for later use, so I try to call it a heck of a lot of ways.
EX:
package isoscreen
{
import assets.Assets;
public class isoBlock extends SYM_BLOCK
{
...
import assets.Assets.SYM_BLOCK;
public class isoBlock extends SYM_BLOCK
{
...
import assets.Assets;
public class isoBlock extends Assets.SYM_BLOCK
{
...
is it possible? I haven't seen any examples of it anywhere.
ANSWER
The answer was simple, once shown to me. =)
But did require a bit of tinkering.
[Embed(source='/assets/assets.swf#block')] // you need to properly change the linkage to the file if your assets are in their own folder (also I found # as a shorthand to get to the symbol inside of the swf)
public class isoBlock extends Sprite
{
public var top, left, right; //You need to define each symbol within the symbol as well, or it will fail to create.
Thank you, folks.
A symbol is not exactly the same thing as a class, therefore you cannot extend it. You can however, link a symbol to your class, much like you would in Flash authoring.
package foo {
[Embed(source='assets.swf', symbol='block')]
public class BlockClass extends MovieClip {
// if your symbol only has one frame, extend Sprite instead
}
}
You can't do this for different reasons. The most important is:
You can't use variables in class declarations. E.g.: class A extends myVar is not allowed.
I am working in Flash CS4 with AS3.
I have a TextPage.fla file that contains a dynamic text field (name: PageTitle) as an instance on the stage.
In the document class (TextPage) I set the text of PageTitle according to some XML.
This all works fine.
I have another fla file, SpecialTextPage.fla, and that also has the PageTitle dynamic text field on the stage.
I now try to have the SpecialTextPage document class inherit from Textpage:
public class SpecialTextPage extends TextPage
{
...
}
but I get a "1120: Access of undefined property PageTitle." error when trying to publish SpecialTextPage.
The error location is given as TextPage.as
As a workaround I can just copy the whole TextPage.as file and add in the extra things I need in SpecialTextPage.as but I'd obviously prefer it if I could just extend it.
I got the feeling I am not quite understanding the relationship between flash's objects on the stage and the document class.
Can someone help?
A document class is basically taken and dumped on the first frame of the timeline of a SWF then executed at run time and therefore has access to everything on the stage like they were hand written properties in your class.
Now imagine you create a variable in your SpecialTextPage that you call var i:int; No matter what you do, the parent class will never have access to i (nor should it). The same way, the stage elements linked through to your document class, the parent will never have access to them.
Similar to MovieClip extending Sprite, Sprite can never make reference to the MovieClips timeline because it has no awareness of it.
But not all is lost! A nice way to achieve your goal is to have the following:
/* TextPage */
/* Parent Class */
/* ... */
public function TextPage() {
pageTitle.text = getTitle(); // This textfield would be the one in TextPage.fla
}
protected function getTitle():String {
return "All the text you could ever need in your title";
}
/* ... */
/* SpecialTextPage */
/* Child */
/* ... */
public function SpecialTextPage() {
pageTitle.text = getTitle(); // This textfield would be in SpecialTextPage.fla
}
The way I got around the problem was to disable declaring stage instances automatically.
(Publish Settings --> Flash Tab --> Uncheck 'Automatically declare stage instances')
I then needed to declare pageTitle on my TextPage class as a public field:
public class TextPage extends MovieClip
{
public var pageTitle:TextField;
...
}