ActionScript 3.0 :: GUI And Game - Loading SWF And Passing Asset
May 12, 2011
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)?
View 7 Replies
Similar Posts:
Jun 1, 2011
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?
View 1 Replies
May 23, 2011
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.
View 1 Replies
May 6, 2011
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)
[code]....
View 0 Replies
Jun 2, 2011
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.
View 3 Replies
Jan 21, 2010
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.
View 0 Replies
Jan 11, 2011
I am accessing some games that my company built using a AIR browser (allowing us to sell an installable product on a CD, but keeping the content online for ease of maintenance). I can get the games to load, but i cant get them to accept keystrokes, ie: we have a tetris-like game that isnt getting any of the arrow key inputs. I'm fairly certain this has something to do with a focus issue, but I have no idea how to fix it.
View 2 Replies
Dec 2, 2009
I have benn programming in AS2 for a while, but I'm moving to AS3, and I'm having some trouble with syntax and mostly with management of parameters and variables (actually I tried to work with functions in packages without good results T.T). The game has four different types of shooters, and all of them use the same bullet (shoot function). I have succeeded on disappearing the target (a coin in this case) when it is hit by the bullet, but the problem is that I can't quite find the way to dissapear the bullet properly. I keep receiving this message:
ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
at flash.display:isplayObjectContainer/removeChild()
at eco_adm9_fla::MainTimeline/moveBullet()
[code].....
View 3 Replies
Feb 15, 2010
When game page loading , the flash game itself does not appear ( just white area as the holder of the flash game) untill the game almost finish downloading, then it appears .. This long waiting with just white area makes visitors leave, thinking there was nothing there.
View 1 Replies
Mar 24, 2010
i have done a template for an elearning project. in that iam loading a swf with in another swf when click on a lesson button. the second swf will load a xml file. I want chang the xml file name while loading the second swf within the first swfto pass the variable or a value while loading a swf within a swf. i got struct up.. iam in pressure
View 1 Replies
Jun 25, 2009
I needed to write a very small SWF that would load a second SWF, passing all FlashVars to it. In searching for how to do this, I found bits and pieces, but nothing complete. So, in case this is useful for someone else:
ActionScript Code:
public class MyPlayerLoader extends Sprite
{
/**
[Code].....
Basically, this packages up all passed in FlashVars into a URL and loads it. There is one FlashVars that isn't passed, and is identified by SWF_TO_LOAD_PROPERTY. If in the FlashVars, that identifies the SWF to load. If not present, DEFAULT_SWF_TO_LOAD is used instead.
View 1 Replies
Oct 21, 2010
I have a AS3 game with about 300 images to load.
Method A) Now what I do in .net is load images required in each class e.g., Player class has 50 images to do with player movement and Enemy Class has 50 images to do with enemy movement.
Method B) I have read in AS3 you usually load all the images in the game in 1 class and pass the array of images on to the relevant classes so player/enemy images are loaded in a load class and then pass on those images to the classes.
Which method is best as I prefer method A?
View 4 Replies
Nov 6, 2011
I am still on my task to create a reusable chunk of UI. I have got many aspects working but one thing now confuses me. If you have a class that expects a string and an image to fill a sprite, how do you pass them both through when you instantiate your custom class?
So image you have a MovieClip with a class file, let's imagine it's very simple and all it wants is a string and a sprite.
Code:
package {
import flash.display.MovieClip;
import flash.display.Sprite;
[Code].....
At which point do I instantiate my class? It will be expecting two parameters yes? So do I do this in one loop or two or what? I got it working fine for one thing, but not for more.
View 3 Replies
Oct 30, 2010
I'am trying to load an external swf file and passing it some variables. He is my code:
[Code]...
When i load a simple swf, it work fine, but when i try to give him some variable it does not work anymore.(i'am also muting sound)
View 1 Replies
Jul 5, 2010
I am trying to pass a string of images into an array and then load each image dynamically into a seperate bmp. The code is as follows:
ActionScript Code:
package{
import flash.events.*;
import flash.display.Sprite;
import flash.display.Bitmap;
import flash.display.BitmapData;
[Code] .....
View 4 Replies
Aug 21, 2009
I am trying to load a flash game in flex but the game does not work the same as it does in the flash player. The game was made using AS2 but I read somewhere that is should play without errors, that is not the case. Played normally the guns shoot the enemies no problem but in flex the bullets just float around the enemies never hitting them. It is hard to describe what is happening so I also included a link with the flex 3 project file that has all of the files.
Here is what I am using for my flex 3 code.
Code:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="[URL]" layout="vertical"
creationComplete="init()">
<mx:Script>
<![CDATA[
private function init():void{
[Code] .....
So is there a way to just play the swf file without messing up the game?
View 1 Replies
Dec 17, 2009
I have 2 questions regarding bitmaps. Say I'm loaing graphics from a game off a server into a .swf file:
1) Which format is the best to use - gif, jpeg,png? (for non transparent images)
2) When a user plays a .swf movie it gets saved to their browser cache and its loaded the next time they access the same file, but when your externally loading images does flash have to re-download all the images or is it all stored in the browser cache?
View 2 Replies
Jan 10, 2003
I load a game on click of a button in level1. When I click on some other button I load another swf in level10 & unload the game in level1. When I click the game button I load it again. The problem is: when the game is loaded first time it works fine but in subsequent attempt it behaves erratically. I am using time interval functions a lot of places in the code which moves the thngs on the screen. When I load the movie again after clicking on some other button, the things start moving on its own...
View 1 Replies
Aug 13, 2010
In the game I am creating, I don't want to import the images directly to flash, otherwise the game will be well over 10MB and that is not a good thingamajiggy So, I am loading them in from a folder residing in the same directory as the SWF.Question - Even if a 56k user plays the game, they shouldn't have a problem receiving the files pretty quickly, considering the image folder with the 8MB+ images is in the same directory, right?
View 4 Replies
Jan 21, 2012
started programming the menus for the game im working on. Everything shows up ok so far but when i select the buttons rather than it loading the next part, its going to a black screen? Does anyone have any suggestions? My code for the MainMenu is as follows:
package
{
import flash.display.MovieClip;[code]....
Then the "game" is another class which is loaded when you select to play the game.
EDIT: Forgot to mention, i have images loaded that are converted to movieclips and named the same as the class so that they display as the background. The main menu image works fine, just not the game background.
View 2 Replies
Jan 8, 2011
I'm changing scalex of an object over time.
Code:
function onLoop(){
angle+=1;
obj.scalex=Math.cos(angle*3.14/180);
}
The object becomes thiner and thiner. Is there any way how to know where(x,y) is the top left corner of the object?
View 2 Replies
Nov 12, 2009
I know this has probably asked a lot before, but I tried searching some and couldn't find it.
When I make a loading bar it won't show up until the whole game's loaded.
View 9 Replies
Feb 1, 2007
I have built this AS2 game that uses quite a few classes and library symbols.It works fine the first time you play the swf. But if you try to do the whole ctrl + ENTER in the Flash IDE, it doesn't seem to load any of the assets that are dynamically attached to the stage.This also happens if you have another swf use loadMovie to load it.I have all the dynamically attached symbols assigned with the linkage and set to export on the firstFrame. There is an include .as file on the first frame of the fla.
View 3 Replies
Feb 19, 2009
I'm making this game with complex visual effects (some rendered lighting using bitmaps), so it takes about 1 second or so generating a level with 3 big lights, so it may take a little more using more lights. The map is built when the player clicks to play the level. The thing is I can't show him the game is busy processing the level elements, because the graphic elements won't refresh until the start level function returns, which would make some sort of info sign while the map is loading useless. How would I make it so this information is visible right after I click Start level and disappear as soon as the level is built? I'm assuming the event handler from clicking Start level has to return before the level starts loading, but how can I schedule the game for loading?
View 4 Replies
Apr 8, 2011
Somebody give me some tutorials sites for saving and loading game.
View 1 Replies
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.
View 2 Replies
Mar 1, 2010
What is the class of an embedded asset?
[Embed(source="picture.png")] public static const picture:Class;
what is the class of:
new picture();
what superclasses does it inherit? i thought it would be Sprite, but it gave me a TypeError.
View 1 Replies
May 22, 2009
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
View 3 Replies
Aug 19, 2010
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.
[Code]...
View 4 Replies
Jun 28, 2011
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?
View 3 Replies