ActionScript 2.0 :: Check To See If Asset Is There Before LoadMovie?
Apr 10, 2010
I know just loading the movie and then using getBytesLoaded will check to see if it is actually loading, but I'd rather run of test of say, 10 assets to see which are present and then start loading them after I know which ones are there.
I have an externally loaded swf that contains thumbnail movieclips. When a thumbnail is clicked an external image is loaded. I would like to be able to reposition this external image. I know I can use typecasting to control a movieclip of the swf but how do I control nested externally loaded files? I have a different approach that should work fine but I was just curious about my initial attempt.
I am trying to load assets from an SWC into a SWF at compile time, in as3. I'm getting the information about which assets to load from a JSON file. I can do so statically, but when I try to define the names dynamically, I'm running into problems. So for example I can do this:onemech[+ tmpObj.id] = new mech3 as MovieClip;And it loads the asset named mech3. But what I would like to be able to do is something like
var mechtype:String = "mech" + mechtypenumber; onemech[+ tmpObj.id] = new mechtype as MovieClip;
Obviously, that doesn't work.I looked around a bit and I found this here, which seems to be angling toward what I need, but I can't figure out how to apply what's said there to my specific situation.
As I am building a Flex framework for minigames, I plan to bundle a bunch of graphic assets (movieclip symbols) into a single swf file, which I will load into my Flex application, before extracting the symbols from the swf file for use in my application
When I was building apps in as2 - my main method of project distribution was to create a bunch of different swfs, each representing, probably, a timeline, some code, and a set of graphical assets. Tho cumbersome, it meant that I could progressively load large chunks of the project as needed, at runtime.
Obviously - working in as3 - this changes a bit. My last project ended up being a bit too large, even when all assets had been optimized - mostly because I just embedded them in one swf and loaded it (kinda long load time). So - new project, wondering what solid methods are available for loading packages of external assets. I could, obviously, just load everything individually, but I would like class linkage and symbols already defined - rather than doing this manually for bitmaps.
I am trying to implement a card game using Flash Professional CS5. Since flex makes the final size bigger, I do not want to use Flex for now. I have some difficulties to bind code logic with assets. I have a Deck class and Card Class and 52 card images which are converted to movie clips.
Option 1: I can create linkage to those movie clips means that I will have 52 different classes for each card and I have to create 52 different classes to put my functionality for each card.However I do not want to create 52 classes so is there any other solution?
Option 2: I found embedding asset paths to classes in Flex like that;
Code: [Embed(source="xxx")] public var customClass:Class;
So is there a way to make it without using flex in action script code?
I have tried many things but when i load my external jpg inside a MC (thru the use of a MovieCliploader which then load the jpg inside that MC in an empty MC). I have put my code in the onLoadInit() and did something like
MC._width = target._width;
My MC has a specified width and height in the library. is it because of that or should i put it smaller.
So I've seen many a tutorial on how to do this in AS3 but I'm trying to work out if there is a way to have all my assets for a game I'm making external, so they can be shared with a level editor that resides in a different .swf and won't be loaded twice.I spent a while looking and found out about Shared Libraries, which at first I thought would solve the problem, until you find out that you can't use attachMovie to attach anything to the stage at run-time if it is an imported object, which just sucks to be frank .So I then thought of a work-around for that by adding these shared objects inside a MovieClip that wasn't shared so I could add that from the stage and access the clip inside using the instance name that I would assign it. This worked fine until I remembered that I had was using several Bitmaps and the BitmapData class, hence if I placed these bitmaps in a MovieClip I can't even assign an instance name to access them to perform the code that I wish to on them.
If I draw something manually, can I still change the colour by actionscript? I want to draw a cat, and the cat colour depends on the the user choice in the previous 'screen'. How should I go about this?
I'm creating a media player (mostly video but with some graphical interfaces) that has a full-screen mode. However, before going fullscreen it's relatively small (about 620x340) and going fullscreen would typically be about double the resolution. What is the best way to prepare the videos and assets in the file so they look good at fullscreen and at the smaller size? I want to also keep the file size to a minimum (within reason).
i've imported an image asset (Background.jpg) to my Flash CS5 library and exported it to ActionScript as class Bitmap with a base type of BitmapData. the following code returns the following error:
backgroundTexture = new Shape(); backgroundTexture.graphics.beginBitmapFill(Background); backgroundTexture.graphics.drawRect(0, 0, stage.stageWidth, stage.stageHeight); backgroundTexture.graphics.endFill();
I'm building an Adobe AIR application (2d platformer adventure game), utilizing the Flash Builder 4 IDE, which will be packaged on a CD for installation. I've embed the majority of the game assets into a static class to keep it simple and organized. This way I can reuse assets and swap them without much digging.
Example: [Embed(source = "../data/gfx/spritesheets/boyHero.png")] public static var boyHero:Class;
In the early days of the projects, everything went to plan. However as the project has grown to be over 28MB, I've started to run into Out Of Memory errors. These occur when I add new assets, refactor for a while, or add new classes. Once I get this error, I can restart FB and then work for another 15-20 minutes. I've modified my .ini file bump up Flash Builder 4's memory allocation. It's currently set at: -Xms512m -Xmx1024m
While I'm at it, here are the specs/plug-ins that I've got installed: Flash Builder v 4.0 (build 272416) JNA Library 3.2.7 subclipse plugin 1.6.17 subversion client adapter 1.6.12 subversion JavaHL Native Lib 1.6.15 SVNKit lib 1.3.5.7406
Mac OSx v 10.6.7 2.53 GHz Intel Core 2 Duo 4GB DDR
My Questions: 1) Is the issue with the path that I've chosen for the way I'm handling in-game assets? I am streaming in some assets such as tutorial swfs which are loaded via the SWFLoader. I could go this route for all assets... but, should I? Is this the right way to handle a disk game? (The game runs without a hitch when installed on QA machines...) 2) Provided the embedding of static assets isn't an issue, Is this a FB4 bug? Where should I head for more information?
I have some FLA/SWF assets which are hierarchies of bitmaps.They have timelines which page-flip through different bitmaps.I'd like to scale these assets down in pixel-size, including the bitmaps they're composed of.I'm not a Flash Animator, but the artist i'm working with doesn't know of an automated way to achieve this. ie, that it's a long a laborious manual process.Does anyone know of a tool which can simplify the re-scaling of bitmap-based FLAs ?
I have two or more graphic elements (bitmap, control) on stage. All of them are listening to mouse events. Some times they can be overlapped by other elements completely or partially. (think of scrambled pieces of jigsaw puzzle). When I click on an element, the click event should by passed on the element if there is something underneath it at that point. If there is nothing underneath the mouse point, the move event should trigger.
For example: Look at the boxes below. Say box A drawn with "=" sign is overlapping box B drawn with "-" sign. The collusion area is drawn with "#" sign. If the mouse is clicked on "#" area, then the event should trigger the box B's click event instead of the box "A" and respective events if the mouse is clicked on non colluding areas of A and B. ======== = = = ####---- = #### - ====#### - - - - - -------- I want to able to bypass all the element's mouse events until the element in the bottom has reached.
Im trying to fix some as classes that are importing from mx.core.* and have defined a Class that extended the BitmapAsset class--I dont believe that class exists in the Flash library, so I replaced them all with BitmapData--Can someone explain what mx.core is and what is the Flash equivalent of BitmapAsset?
I'm currently having a problem with preloading. What I have is: 1. Preloader -> an SWF preloader, made in Adobe Flash CS5 2. GUI -> an SWF file containing the user interface, made in Adobe Flash CS5 3. Game -> an SWF containing actual game logic, made in Flash Develop
The preloader SWF should preload both GUI and Game. I can do this, no problem. The problem however is: I need to be able to control the GUI from the Game. So how can I access the GUI from the Game? In particular the main movieclip in the GUI which contains every interface screen. How can a script inside a SWF communicate with another SWF (all in the same file)?
I have a class called Bike.as, linked to a movieClip in the library. The class essentially tweens a bike graphic across the stage. At the end of the tween, I instantiate a new class called Slideshow. Slideshow loads an image. The image loads(I get no loading error, and I can trace info about the loaded content)... I just can't seem to see it. In attempting to debug, I wrote the loading code(in Slideshow) into the Bike.as file(replaced the code that instantiates Slideshow), and it worked. Did it work because Bike is linked to a movieclip, and Slideshow is not(Slideshow is called in Bike.as)? I'm attempting to transition from AS2 to AS3. Here's my Slideshow class:
public class Slideshow extends Sprite { private var container:Sprite; private var loader:Loader;
Inherited some flash widgets that are developed in .fla format and exported to .swf apps, using Flash Pro CS5. I have only limited understanding of AS3 or 4, flex and flash in general, but I'm quickly becoming dangerous.
My bottom line problem is I need to find a command line tool to 'build' the .fla source into .swf entities. q1: are there any cmd line tools with the Flash Pro CS5 for such purpose? I cant seem to find any, but I may not be looking at the right places.
I know there's such a thing as the Flex SDK, but what's under Flash CS5 at "Adobe Flash CS5CommonConfigurationActionScript 3.0flex_sdk", doesn't seem to have anything useful in it, only a general flex library.
Another requirement I need to solve is to create customer specific, purpose built versions of the widget. From the Flash IDE, I can figure out how to replace the background images, etc., but.q2: how can I do this at export/build time and later on, via the command line tool?
Basically, a build/compile directive in source would allow the swf builder to replace a given image asset with the version I intend to build with.
I'd like to set the base class of a library asset at runtime,rather than specifying it before. Is this possible? I'd like it to just extend movieClip, but at runtime change that to extend a custom class.
I am having a strange issue where I have created a MovieClip in the IDE and given it a class name ( MyObject ) and exported for actionscript...this object is created in an external class. This object has a few MovieClip symbols inside, ( MyButton ) and ( MyOtherButton ). After creating a mouse-over event for MyObject and catching the target ( either MyButton or MyOtherButton ), in the listener function, I trace the event.target in hopes that it will output "Object MyButton" or "Object MyOtherButton" but instead, I get "Object MyButton_6" and "Object MyOtherButton_2"...
I understand that to reference any loaded assets I need to use the File class and package my assets with the Air app. I'm working for the moment with the CS5 IDE and using the Air publish settings to include the folders where my assets are (i.e. I add the folders, not the individual files, as there are many).When I try to load the first file, an xml file, via URLLoader I get a "2032" error -- an IOError, stream error.The code I'm using to get the correct path for my loaded assets is
function getPath($path:String):String { var f:File = File.applicationStorageDirectory; debug(f.resolvePath($path).url)
I'm embedding a font at runtime with flex, using the following syntax:
Code:
[Embed(source='./Regular.ttf', fontFamily="Arial", fontName="Arial", fontWeight="normal", mimeType='application/x-font')] public var Regular:Class;
I want this to be optional such that if this TTF file unexists at the specified location, then it can just be skipped and Regular takes a value of null.
I haven't experimented with external SWF's purely as image/sound libraries etc. I generally embed assets and/or load in sound/textures/geometry etc dynamically.
However as I'm starting development on my first game, I would like to use an asset SWF per level, so all images, sounds, models etc are contained in this SWF, nice and clean, just one file loaded per level. No code, just assets.
Not only for the structure, but embedding transparent PNG's is very important, as obviously uncompressed PNG's are pretty hefty, and flash does a great job of it.
So for those with experience of asset SWFs, what do you think is the best method of loading/removing/accessing/managing them?
Yet another irritating technical issue, it's the first time I've tried loading assets from another server and it's not working.
Apparently having the loader context check policy file does nothing with SWFs, I've tried with and without, no difference.
I've tried Security.allowDomain("*"); and loading a crossdomain.xml file where the assets are located, and no joy. Every time I try it, I just get an error trying to load a class (that works fine from local SWFs).
I'm compiling from CS5 with access network selected. Also tried with Flex, same thing.
I have Dreamweaver CS5, and used the "Insert FLV" function to generate a flash video player. It creates a /Scripts directory with two files, swfobject_modified.js and expressInstall.swf, and it also creates two .swfs in the directory the .html file is located, FLVPlayer_Progressive.swf and an .swf named after the skin (e.g. Clear_Skin_1.swf).
When I have Dreamweaver generate the html code for all this with a relative path, it works. When I give Dreamweaver an absolute path, it doesn't. You can see an example at www.youngstreetdesign.com/staging/flvtest/test.html.
The top is the relative, the second the absolute. The third is something unrelated.Dreamweaver says "enter relative or absolute path here" in the entry where you give it the video's path, and the documentation says that absolute paths should work, so, I'm at a loss.