ActionScript 3.0 :: Use Library Resources From Class?
Feb 28, 2009I have a font in my library and I want to access it from a class.
myFont:Font = new FontName(); doesn't seem to be working.The linkage is setup. How can I get this to work?
I have a font in my library and I want to access it from a class.
myFont:Font = new FontName(); doesn't seem to be working.The linkage is setup. How can I get this to work?
I am somewhat new to OOP and am attempting to learn how to design and execute custom classes. My goal is to create a package that extracts data from an XML document. Do any of you have links, books or other resources you would recommend? So far, I've got the following:
[Code]...
I'm building a Flex project with a lot of embedded bitmaps and such. The usual method for getting to the bitmaps in Actionscript seems to be to do something like
[Bindable] [Embed(source = '../lib/WhiteFencePost.png')]
private static var clsObstacleFencePost : Class;
var bitmap : BitmapAsset = new clsObstacleFencePost();
I've already got several dozen of these things, and I can easily see ending up with hundreds of them by the time the project's done. Is there some way that I can avoid creating a Class for every bitmap?
I created an flv video player using Flash Builder 4. This "BasicVideoPlayer" project is compiled into a SWC that will be eventually be used to create other video players that extend the functionality. One of the features is a view that appears when the video has finished playing that displays a "Play Again" button. This "Play Again" view has its own class, "BasicPlayAgain", that accepts a graphic asset that is exported from a .fla file that contains all of the graphic/UI assets.
In my new project, "EnhancedVideoPlayer", I'm using the BasicVideoPlayer SWC as a library to create a new video player that will add more functionality to the "Play Again" view; specifically it will add more buttons to that view.The EnhancedVideoPlayer uses a default class that extends the BasicVideoPlayer class. The BasicVideoPlayer class has a member called "playAgainScreen" whose type is BasicPlayAgain. The EnhancedVideoPlayer needs to override the playAgain member and recast it as EnhancedPlayAgain so it can control the new buttons properly.
I'm trying to load a RSL library into a flash animation developed with Flash CS5 IDE, that extends a custom class and implements an interface. I have reduced the problem to the simplest setup and find that I can have my main class extend another class or implement an interface, but not do both at the same time if I want to load an RSL.I have a very simple class to extend:
import flash.display.Sprite;
public class MySprite extends Sprite
{[ code]...........
but if I want both I get the VerifyError: Error #1014 with MySprite not found and ReferenceError: Error #1065.
The use of library classes confuses me once again. I have the following situation:
[Code]....
I cannot put in any baseclass when using the class, so I'm forced to remove the baseclass. When using only the class I get a whole bunch of errors don't make any sense at all, and still appear even if I comment out all the code in the Page class. comop_padpagesFavorietenPage.as:7: 1152: A conflict exists with inherited definition com.op_pad.pages:Page.help in namespace public.
[Code]...
Library symbol "Card" is linked to class "Card" which extends "MovieClip". Library symbol "Card" contains a card background image.Library symbol "Ace" is linked to class "Ace", which extends class "Card". Library symbol "Ace" contains a TextField with a big letter "A".So we have Ace extends Card which extends MovieClip. Ace therefore extends MovieClip, but does not DIRECTLY extend MovieClip.When I drop an instance of Ace on the stage and compile the clip, all that shows up is the big letter A. However, I expected the background image from Card to be included, since Ace extends Card, and the Card symbol contains the background.It seems like Flash ignores symbol content unless it belongs to the top-level class being instantiated.I think it's LAME that one symbol can't extend another. The IDE could easily draw Card as a non-editable background while I'm editing Ace which extends it, and it should instantiate Card's content and then Ace's content when an Ace is instantiated.
View 3 RepliesIn As 2 you were able to reference a linkage ID using a string.Example
Code:
var strName = 'home';
attachMovie(strName+'_mc', strName, 1);
[code].....
Got two classes "Engine.as" and "Player.as". Engine.as is the document class that is calling Player.as.
The point is to have Player.as create a movieclip on the stage, but it seems it cannot access the library or something. Because when the player class is at the createHero() method it gives me the "error 1009 cannot access a property or method of a null object reference"
Engine class:
Code:
package test{
import flash.display.*;
import flash.events.*;
[Code]....
I am trying to develop a kind of monopoly in Flash AS3. For the tokens, a player have to choose a shape (as "dog", "shoe", "car", ...). All these shapes are allready designed as MovieClips, and are stored in the library (as "tDog", "tShoe", "tCar", ...). In my code, I have a Token() class, wich is called in the main script when setting the scene. This class is an extension of a MovieClip, and is designed as follow :
[Code]....
how to add a MovieClip from the library by a class i've MovieClip and i want to add it to the stage by a class note i've already a class and linked to a MovieClip and what i woona do is to addChild another MovieClip in the stage
View 3 RepliesI'm trying to figure out how to add a movieclip (called menuList) from the main fla library to the stage inside my document class. Up until now I've just created new mc's or used ones already on stage in the fla but now I need to add directly from the library. In the following example I've tried to create a variable, type it, and define it as the menuList_mc object but I just get the 1120: Access of undefined property menuList_mc message. What am I doing wrong here?
ActionScript Code:
public var menuList:MovieClip;
public function createMenuList(event:Event = null):void //called by constructor{
menuList = menuList_mc;
//addChild(menuList); will do this after i properly define menuList
}
I'm still in the 'need to learn a lot more' phase of AS3 and am wondering the best way to do this. I have some graphics (MovieClips) in my library that I'd like to have use the same class. But Flash wants unique class names.What's the proper way to handle this? External swf graphics?
View 7 RepliesI've got a question which is primarily an OOP question, but it is specific to AS3 in it's implementation.
I writing an interface which consists of displaying a (circuit) card rack which holds twenty cards of various types. Some of the properties of the cards are common to all cards such as slot number, card type, id, etc. They also behave similar when clicked on, taking you to another view.
It seems to make sense to create an abstract class (Card) that has all the common properties and behavior of all the cards, and then extend that class to create the specific card types, but the problem is that the display objects representing the cards are movie clip symbols in the library.
It boils down to this question: How do I extend a class that is already extending the movie clip class (a symbol in the library)? I know that AS3 doesn't allow it, but I figured someone has probably run in to something like this before.
I've created a movie clip and placed it in the library. I've given it a class name via the properties panel in the library. Every time I drag it to stage I want to make sure its alpha is set to 0. If I drag 300 of those clips to stage, is there a way to reference the class name I gave it in order to automatically set the alpha value as soon as they're dragged into the stage?
View 2 RepliesI use the script below to distort a wall. When I have the MC on the stage it works but shows it twice. I solved this by hiding it with _visible but I really want to load the MC from the library. So I wrote the script like this. But nothing shows?[code]...
View 1 RepliesI've started a new cs3 flash file. I've created a few symbols, scattered them about the stage, then gone to start writing my class file. I've created the class fine and i have created an external .as with the same name as the fla file (miniGolf.fla and miniGolf.as). The problem is that i can't link the fla to the .as. Every time I click the little pencil icon I get an error saying:
"You must specify a unique class name that is not associated with any library symbols"
I create a dot as a movieclip in the library. also i set the linkage to Dot class. Is it OK to create an external class Dot to associate with the movieclp inside the library? if it's ok. I would like to ask that is there any wrong in my code?
Code:
package {
import flash.display.MovieClip;
import flash.events.Event;
public class Dot extends MovieClip {
[Code]....
I have a quick newbie question (I just switched to AS3) : I have two clips in the library that are exactly the same in structure, just that the design changes. Two different characters lets say. Now, I'd like to apply a class to them, and that class is going to be 100% the same for both, how can i do to have the two clips pointing to the same class...? For the moment what I did is save my class with another name, but I guess it's a bit lame...
View 5 RepliesIf it's possible to access the class library, i.e. instantiate custom classes, from a loaded external SWF file?
I have a sprite on the stage with the instance name "speakers". I've got this working so far[code]...
I have a folder with my .fla, and a folder called "classes" where I stored all my classes. I'm trying to access a MC in the .fla file so that I reference it from one of those classes in the "classes" folder. for you visual learners...
Code:
<project>
project1.fla <- library here
[code].....
I am trying to unload a class from memory using the following experiment:Create a shape on stage, make a movieclip out of it, add a trace in the first frame, extend the movieclip to be about 40 frames, give the movieclip a linkage name "test" and remove it fromstage.Experiment 1:Add the following code to the stage:ActionScript Code:var mcl = new test();Publish the movie. You should see the trace statement showing up all the time.Now I wish to delete this instance.Experiment 2:ActionScript Code:delete mcl;gives an error that it cannot delete a fixed property and have to set it to null instead.Experiment 3:
ActionScript Code:
mcl = null;
No error, but still see the repeating trace output.
[code]....
what I am trying to do is create class that loads assets(images) from library and places them on the a stage.I want my class to be something like this...I know it needs to be more complex, I am just trying to "draw" out my idea for you, I have tried using getDefinitionByName to pass the linked MovieClip and some variations on that but for some reason I can't get it to work.[code]
View 3 RepliesI'm currently attempting to build my first classes in AS2 (with high hopes to soon move to AS3..baby steps). I have run into a problem that has cost me the last few hours of the night tonight and I still feel like I'm no closer to the solution >_<
The scenario: I am attempting to create a couple classes that work together to handle the creation of textFields and the methods by which to scroll them (if needed). One class method creates the TextField, populates it, then calls the next class that attaches and sets up the scrolling components/methods if needed.
The problem: I cant access items in my library from my class no matter which way I slice it. I need to attach movieClips from the library to act as my scroll components and am currently attempting to do so by passing the linkageIDs through the constructor. Tracing the items passed through works fine, but attempting to use attachMovie with them (or with the ID's as literal Strings) fails silently; nothing gets attached.
I'm creating a card game and I need to use graphics from the library. All the movieclips have their linkage setup. How do I access the library movieclips from a class?
View 2 Replies i'm trying to do is to move all the squares. I've got a Square movie clip class in my library. The program should populate an amount of squares, unfortunately the amount can vary, which is why i haven't just gone with
var square1:Square = new Square();
var square2:Square.. etc.
var thisSquare:Square;[code]........
I'm having a total brain fart right now because I haven't dealt with AS2 library linkage classes in a while. I want to be able to let a designer assign an object in the library to a specific class and have that class listen for changed _x and _y values.I have the class made up that extends MovieClip:
Code:
class CoordinateMonitor extends MovieClip {
public function CoordinateMonitor () {}
}
But I draw a blank now on how I'm to monitor _x and _y values for the clip. I'm pretty sure I remember it being possible to do this and declaring an overriding function ("public function set _x(val:Number) { super._x = val; }") does not work as intended.
have some good graphics libraries they can recommend for AS3? Need glass, textures, effects. The more the better.Using Astral but it is limited to 6 skinnable components. Looking more for something for "Advanced Primitives".CodeCanyon has some available, but remember I program for charity. No funds available.
Example: Tooltips that allow you to add a dashed-underline effect to the text. This would be an object that I can add to the project from the library, or reference an .AS file. It would automatically give the button an assortment of special appearance options (like a dashed-underline), and the hovering tooltip.
I am working on a flash game that I am building in Flash Builder 4. I have a library of movieclips in the FLA file and need to create instances of these movieclips within objects of a custom class. I am unsure how to refer to the library of the flash file while in a class file.
I also would like to call these movieclips dynamically based on the combination of two strings. I know it is possible to create variables dynamically with this[variableName]. Can I refer to library objects from the flash doc in the same way?
have an external class which controls about 400 buttons. But I want this class to also be able to show a Popup window. But this would mean I would need to access the Library.Within this library would be a MovieClip exported for Actionscript with the name PopUP.WITHIN the fla it's easy:PHP Code:va popUpWindow:PopUP = new PopUP();addChild(popUpWindow);
View 4 Replies