ActionScript 3.0 :: Passing Library Assets To Class
Oct 10, 2011
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 Replies
Similar Posts:
Aug 7, 2009
I had a class that I was passing a simple argument to like so:
var quiz_1_2:CaseStudyQuiz = new CaseStudyQuiz(2);
addChild(quiz_1_2);
I now would like to use this class for multiple MCs in my library. I thought I could let Flash create a class for each of them and specifying the CaseStudyQuiz class as the Base class. When I do that, I get the following error:
1136: Incorrect number of arguments. Expected 0.
View 12 Replies
Jul 11, 2009
I've seen that it's very simple to create a document class (a class associated to the main timeline itself), or an instance of a class which is linked to a single asset (e.g. a movie clip).But what if I need to implement a class (let's call it Main) which uses multiple assets from the Flash library? The only way I know to do this is by instantiating any asset with its linked class, and passing them all to the Main constructor like this:
ActionScript Code:
var asset1:Asset1 = new Asset1(...);
var asset2:Asset2 = new Asset2(...);
var asset3:Asset3 = new Asset3(...);
[code].....
This is kind of a tedious process, especially when the composition hierarchy is long and you have to pass them all as arguments through many nested classes.For instance, I needed to link a preload sprite (the typical circle in gradient color which is constantly rotating until the load is complete) from the library to any thumbnail class of a gallery, which in turn is part of another class, which in turn is part of the main class. So I needed to pass this preload clip as an argument throughout the nested classes.
View 8 Replies
Dec 15, 2010
I started using Flash CS5. I spent many hours working on a .FLA file. Saving as I went and at one point Flash CS5 crashed during the save. The .fla file is now corrupt. The new .fla format is essentially a .zip file. So I was able to change the file name to *.zip and explore inside of it. The DOMDocument.xml file is corrupt and dead. The DOMDocument.xml is the timeline so all my placement and animation is gone. However, my LIBRARY folder is in tact and has all of my library items as *.xml files. How I can get those library items into another .fla file so I don't lose ALL my work? I've tried creating a new .fla file and dragging the LIBRARY folder into the new .fla, but my library items don't show up when I load the new .fla in the Flash CS5 IDE.
View 2 Replies
Feb 19, 2009
Since I can access the library assets from external class, I have a question :
1. Is it possible to use any of library assets of one movie into another? Let's say in my movie A, I have McA1 movieclip in the library. Is it possible to access/display/addChild McA1 in movie B?
2. If there's a case that Movie B is loaded into Movie A - does all the library from Movie B will be inherited into movie A - vice versa - so it makes them accessible?
3. If the answer of 1, and 2, is no and no, is there any work around to make any library asset accessible accross the board? Is this what so called runtime sharing? Do you have any resource that I can refer to?
View 5 Replies
Sep 9, 2009
I have fla_A, and fla_B. fla_B contains a single MovieClip which contains a bunch of MovieClips that are all set to Export for ActionScript (NOT first frame, as this will need to be preloaded). I want to load fla_B into fla_A, and be able to instantiate the nested clips (inside fla_B) as if they were native to fla_A itself.
After loading the swf, I'm using:
[Code].....
Can I cast "e.currentTarget" as something useful like MovieClip (well, not MovieClip, 'cause that doesn't work), or something that will stick around from which I can dynamically load things?
View 1 Replies
Jan 8, 2011
I have a great shared library tutorial BUT I don't like one section. Assets.swf is the shared library with a variable array called availablegraphics on it's timeline where we put in the available assets That is the bit I don't like. Isn't there a better way to loop through to get the assets. Also they use a loop using library.availablegraphics - which I have never seen before and seems a little weird. In conclusion it's great but is there a better post or tutorial on shared library and how to loop through the assets without knowing exactly what or how many there are.
[Code]...
View 4 Replies
Sep 8, 2011
Specifically, various MovieClips seem to be missing all of its content. I work in flash for a while, make a series of changes, save the file and close it, and then reopen the file. Upon reopening, the artwork inside the MovieClip does not appear. The former artowrk can be bitmaps, shapes, drawn objects, or even other symbols. I can take the time to replace the missing artowrk inside the symbol (the symbol is still there on the stage and in the library, just the artwork is missing), but three saves and closes from now, the artwork may be gone again, or new MovieClips may appear empty - there appears to be no discernable pattern yet.
View 1 Replies
Dec 6, 2009
When I drag and drop images in flash library, the path is sometimes relative (./somefolder/someimage.png), and sometimes it is absolute (D:lahsomefoldersomeimage.png).
How can I use only relative paths in flash library in order to be able to update all images from any computer and/or from any folder ?
View 1 Replies
Feb 19, 2010
I'm building an avatar class that will allow a user to swap out character assets during runtime. The idea is pretty straight forward. The artist I am working with designed the art assets for the individual pieces of the avatar and performed the animations in flash. Since the animations were created in flash using vector art as opposed to pre-rendered 3d, I want to simply replace each individual movieclip within the animation with the asset selected by the player.
Problem:The issue i'm running into is that the animations have several key frames. My thought is to load the avatar object (an external swf) into my main application. Once loaded, I obtain a reference to all library assets that are used in the animations. For example, to get the face, I have something like:
Code:
if(this.loaderInfo.applicationDomain.hasDefinition("face"))
{
[code].....
View 4 Replies
Dec 13, 2010
I have a swf called "myfile.swf" with a mp3 set to export for actionscript, and the Class has been called "soundName"With the following code, the sound plays great...
Actionscript Code:
var bgURL:URLRequest = new URLRequest("myfile.swf");var swfLoader:Loader = new Loader();swfLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadProdComplete);swfLoader.load(bgURL);function loadProdComplete(e:Event):void { var tmpSound:Class = e.target.applicationDomain.getDefinition("soundName") as Class; var snd:Sound = new tmpSound() as Sound; snd.play();}
This lets the sound play great. But, because of what I'm trying to do, i would like it better to put the swf into a movieclip, then play the sound from there.
But i cannot seem to get it to work. The following code adds the movieclip to the stage fine, but then i have no way of accessing the library assets (i.e the "soundName" mp3) from the swf inside of the movieclip.
Actionscript Code:
var bgURL:URLRequest = new URLRequest("myfile.swf");var swfLoader:Loader = new Loader();swfLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadProdComplete);swfLoader.load(bgURL);function
[code]....
View 2 Replies
Apr 20, 2010
I have several small movie clips saved in the library of myCS4 Flash.fla file, I want to make them available to dynamically add to the display list as children, based on the button clicks of the viewer. I can get it all to work fine via Symbol Properties > Linkage > Export for Actionscript. When the movie clips are set to "export for actionscript" from the Library, playback seems to hang on frame 1 until all of these exported assets have downloaded.
The big problem is that I have an ultra-simple but totally custom preloader/progress animation coded in a loop in the second and third frames, which kicks out to frame 4 and continues playback as soon as the download is complete. Because of this, the preloader has essentially become useless - because all that can be seen is several seconds of empty stage, until the vast majority of the bulky assets have downloaded. Then the preloader flashes onstage for just an instant, and disappears because the content is already up.
So, my questions are:
A) Is there a SIMPLE alternate method to load these library assets in such a way that it doesn't cause this major lag on frame 1?
B) Failing that, I suspect I may have to retool my preloader to run as an ENTER_FRAME event in frame 1. Is this worth the effort (can this potentially resolve the lag issue and allow for a meaningful preload progress animation, despite the lag from the asset export?)
View 1 Replies
Mar 26, 2009
This is the concept I want to get into code:
1) Have a Document Class attached to the Main.swf
2) Have a Assets.swf that has all MovieClips that set to Export and have been given actual Classes.
3) Have the document class Load the Assets.swf.
4) Once loaded, be able to create instances of the MovieClips from Assets.swf by writing the code in the Document Class of Main.swf
I can get all this to work.. However what I am finding is if I have a public function on the Document class that creates an instance of something from the Assets.swf, lets say var okTest:TestClass = new TestClass(); I have to also import it in the Document Class (import com.test.TestClass). When I compile it, yes it works. If I remove the Assets.swf file it doesn't display. Ok.. But I've noticed that the Main.swf file is including all the imported classes (eg: com.test.TestClass) so the Main.swf filesize is pretty much the same as the Assets.swf file.
I also ran it through a decompiler and can see yes in fact Main.swf is including all those Classes from Assets.swf because I'm trying to access them from Main.swf and had to import. So the biggest question is how do I go about this properly? Being able to load the asset file that has movieclips etc that have custom classes. Then create instances of those classes within the document class but only if Assets.swf is loaded.
View 2 Replies
Sep 16, 2010
I have built a component, but the assets do not appear in the symbol library of the destination fla when I drag the component to the stage. This is fine, except that I have embedded a font in the component. To ensure the font exists in the destination swf, it must exist in the symbol library of the destination fla.My component extends the UIComponent class, and I have a component shim, although I'm still not entirely sure of its functionI have followed all of the steps found in the 9 part MenuBar tutorial, and everything works, except for this one issue.
View 2 Replies
Jul 22, 2009
I've created an fla whose document class imports some static functions. The library also has some linked symbols (should they also be imported in the doc class?). I exported the fla as an swc, and tried using it in a new project. Whats the right way to reference this? And do i need to import the swc into this new fla to use them?
View 0 Replies
Dec 8, 2010
I have an SWC which includes a number of Assets for my project. Within this SWC is also a static AS file which contains Class declarations for each image in the library. For example, the SWF contains these images:
[CODE]...
View 1 Replies
Nov 6, 2009
I'm creating library swfs in as3 this way, works like a charm (except for the slow mxmlc compiler):
package {
import flash.display.Sprite;
public class Library extends Sprite {[code]....
I would like to create the same kind of libary using swfmill. I've tried the following swmfill simple xml:
<movie version="10">
Examining the libraries in FlashDeveloper's explorer reveals that the as3 library exports BOTH classes and symbols, but the swfmill library exports ONLY symbols.My host application is accessing the as3 library assets this way:
private var loader:Loader = new Loader();
private function onCreationComplete():void {
this.loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete);[code]....
But with no exported swfmill classes, there's obviously nothing to instatiate...Is swfmill expected to export classes this way? If not,is there a way of accessing the symbols without instantiating them as classes?
View 1 Replies
Feb 10, 2011
I want an air application to be able to update the assets it uses, but minimizing the download needed, so only downloading files added since it last updated.I'm thinking this would include a server portion which would zip the needed files based on a version number? Has anyone implemented anything similar / got any thoughts on the best approach to building this sort of system?
View 1 Replies
Oct 22, 2009
when you have a document class for something, how do you load the symbols?lets say you have a gallery and a few buttons for it, and you will load that gallery swf into main site.is it better to leave these symbols on the stage or load them from the library or something else?
View 2 Replies
Dec 24, 2010
I want to reuse the TitleWindow's closeButton inside a simple Flex component I am writing, but I'm having trouble getting it to compile. I copied the code that deals with the closeButton, which looks somewhat like this:
[Code]...
View 1 Replies
Sep 10, 2009
I'm still learning how to compile with the Flex SDK. And I'm learning how to use SWC files and [EMBED] statements to pull my assets into my application.With the Flash IDE, I can link a library asset to a class and it's automatically embedded into my custom class. So that's 1 asset in 1 class. With the Flex SDK and SWC files, it seems I can only* pull in assets at the variable level, so I end up with my custom classes containing yet another class -- this means I have an extra wrapper/decorator (whatever you want to call it) class that I didn't have when using the Flash IDE.Is this what people typically do? Doesn't that seem superfluous?I've read Colin Moock's 'Essential Actionscript 3.0', where he mentions something about embedding a SWF at class-level as binary data.
View 2 Replies
Oct 12, 2010
i have a movie clip which is exported for ActionScript , i want to get a variable from the document class into the movie clip class i tried this but there was an error !!
ActionScript Code:
var main:Main=new Main();
main.txtScore.text="hello";
View 1 Replies
Mar 1, 2011
I created a movieclip with a star. Then, I creates a document class and I named it as Main.as.
In that document class I wrote:
package
{
import flash.display.*;
public class Main extends MovieClip
[Code]....
I´m not posting here all the code, but you can easily see that I´m using x_origin and y_origin variables to keep the original position of the movie clip. I will use them to move the star back to the original position.
The problem is that instead of being 20 and 30 respectively, tracing them I see that they are both ZERO. So when I drop the star, instead of going to x=20,y=30 it moves back to x=0 and y=0. I´ve to get the star position relative to stage, but I can´t find anyway!
View 4 Replies
Dec 28, 2009
I'm trying to create a class which will create a tween for several different instances of an object. I am creating the instances in the Document Class. The trick is, I would like to specify how long each tween will take.
Here's what I have so far:
DOCUMENT CLASS
ActionScript Code:
package {
import flash.display.MovieClip;
import mcCloud;
[Code].....
As you can see, I have a variable "myTime" which syncs the timer and the tween. This causes to tween to repeat and the clouds to continually scroll across the stage. How can I determine the var myTime at the time I create each instance of the Movie Clip mcCloud?
View 6 Replies
Aug 6, 2009
I've got a document class (EgoGame.as) and another class (Ball.as) which has been duplicated to deal with several different video pieces. Inside the document class is a list of 'if' statements which decide which video should be played. At the moment I'm doing it the old fashioned way whereby if the condition is true....it tells the relevant Ball class to gotoAndPlay a certain frame within the linked movieclip...
[Code]...
View 1 Replies
Oct 14, 2010
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.
View 1 Replies
Mar 13, 2011
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.
View 2 Replies
Jan 22, 2011
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]...
View 1 Replies
Dec 9, 2010
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 Replies
Jul 24, 2010
I have a class that works with an external swf with play, pause and slider. Now that I have all that working, I'd like to be able to pass the URL of the external SWF to the class from the main fla AS. I managed to use a 'set' inside the class to retrieve the name, but it apparently doesn't trigger until after the external SWF gets loaded.
Code snippets follow:
CntlClass:
public var loader:Loader;
private var _urlName:String;
public function CntlClass() {
loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, movieLoaded);
loader.load(new URLRequest(_urlName));
public function set urlName(value:String):void {
_urlName = value;
}
Main FLA file - other than a controller (cntl_mc) containing a play button, a pause button, and a slider, the only thing in the FLA file is this code in the first frame:
cntl_mc.urlName = "extswf.swf";
View 5 Replies