My app works, but not when I load it into another swf??


I have a map application I've built using Flash CS4 and ActionScript 3 .as files. It's working fine on my local machine. I'm trying to build a preloader for it. My usual way of doing that is to create a shell .swf file which exists just to load the main movie and show the user preloading progress. Unfortunately, whenever I try to load in a movie that uses external .as files, stuff breaks. I'm assuming that it has to do with the LoaderContext and ApplicationDomain, but I've tried every ApplicationDomain option, and I always get the same errors.

In my map application, I've got a constructor function called Imap() that simply calls an init() function which then sets everything in motion. As I said, when I run the map app, things run smoothly. When I load it into my loader swf, I get (the functions trace out their names as they begin to run):

Imap()
init()
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at com.[domain].imap::Imap/init()
at com.[domain].imap::Imap()


The code in my (as yet uncompleted) preloader swf is:

package
{
import flash.display.*;
import flash.system.*;
import flash.net.*;

public class Preloader extends MovieClip
{
var loader:Loader = new Loader();
var outline:Sprite = new Sprite();
var fill:Sprite = new Sprite();
var w:Number = 100;
var h:Number = 10;
var loaderContext:LoaderContext = new LoaderContext()
public function Preloader()
{
loaderContext.applicationDomain = new ApplicationDomain();
// I've also tried
// new ApplicationDomain(ApplicationDomain.currentDomain) ,
// ApplicationDomain.currentDomain, and
// new ApplicationDomain(null)
// all to no effect
[...]

loader.load(new URLRequest("map.swf"), loaderContext);
addChild(loader);

}
}
}

This problem has vexed me in the past as well, and I've never found a solution for it. If anyone could help me out, that would be great. As an alternative, if anyone would like to suggest a preloading solution that would avoid this whole problem, I would appreciate that as well.

Posted On: Thursday 25th of October 2012 10:10:11 PM Total Views:  103
View Complete with Replies

RELATED TOPICS OF Flash / ActionScript PROGRAMMING LANGUAGE




how to get menu to pop up in Android app

anyone out there know how to get a menu to pop up in Flash CS5 when coding for an android app. Basically I have a nice, simple app that when you press the menu button on your phone I want a movie clip to pop up at the bottom of the screen that then acts as a menu for the app. When you press the menu button again the movie clip disappears. There is some code in the sample files in flash cs5 but it won't seem to work for me. Has anyone gotten this to work successfully for them.
VIEWS ON THIS POST

124

Posted on:

Thursday 25th October 2012
View Replies!

Overlapping Music Problem

, I am very new to Actionscript, but with the help of Internet tutorials and helpful folks, such as yourselves, I have been able to teach myself. I am working on a music playlist. Each song on this list has its own play, stop, and volume button. So far everything is working out pretty decently, however, I have run into two major issues. Issue 1) Clicking the play button on a song results in multiple launches of that particular song, resulting in an unpleasant cacophony of overlapping music. What code could I use to make the song play only once when play is hit Issue 2) Clicking on different tracks at the same time results in all those tracks playing simultaneously. What code could I use so that only one song can be played at a time Thank you so very much for your time, all help is tremendously appreciated. :-) I have posted my code below, I know its huge, but its mostly just repetition. ActionScript Code: import flash.events.MouseEvent; import flash.media.Sound; import flash.net.URLRequest; import flash.media.SoundChannel; import flash.media.SoundTransform; import fl.events.SliderEvent; //Objects and Variables var myMusic:Sound = new Sound(); //Instantiation var soundFile:URLRequest = new URLRequest(" My Heroes.mp3"); var channel:SoundChannel = new SoundChannel(); var sTransform:SoundTransform = new SoundTransform(); myMusic.load(soundFile); var myMusic2:Sound = new Sound(); //Instantiation var soundFile2:URLRequest = new URLRequest("Alone in Lower Manhattan.mp3"); var channel2:SoundChannel = new SoundChannel(); var sTransform2:SoundTransform = new SoundTransform(); myMusic2.load(soundFile2); var myMusic3:Sound = new Sound(); //Instantiation var soundFile3:URLRequest = new URLRequest("Asphyxiated Dreams.mp3"); var channel3:SoundChannel = new SoundChannel(); var sTransform3:SoundTransform = new SoundTransform(); myMusic3.load(soundFile3); var myMusic4:Sound = new Sound(); //Instantiation var soundFile4:URLRequest = new URLRequest("Banana Peel Junkies .mp3"); var channel4:SoundChannel = new SoundChannel(); var sTransform4:SoundTransform = new SoundTransform(); myMusic4.load(soundFile4); var myMusic5:Sound = new Sound(); //Instantiation var soundFile5:URLRequest = new URLRequest("Get A Kick Out of You.mp3"); var channel5:SoundChannel = new SoundChannel(); var sTransform5:SoundTransform = new SoundTransform(); myMusic5.load(soundFile5); var myMusic6:Sound = new Sound(); //Instantiation var soundFile6:URLRequest = new URLRequest("Microdeaths.mp3"); var channel6:SoundChannel = new SoundChannel(); var sTransform6:SoundTransform = new SoundTransform(); myMusic6.load(soundFile6); var myMusic7:Sound = new Sound(); //Instantiation var soundFile7:URLRequest = new URLRequest("Sit Sam Theme.mp3"); var channel7:SoundChannel = new SoundChannel(); var sTransform7:SoundTransform = new SoundTransform(); myMusic7.load(soundFile7); var myMusic8:Sound = new Sound(); //Instantiation var soundFile8:URLRequest = new URLRequest("Soundtrack.mp3"); var channel8:SoundChannel = new SoundChannel(); var sTransform8:SoundTransform = new SoundTransform(); myMusic8.load(soundFile8); var myMusic9:Sound = new Sound(); //Instantiation var soundFile9:URLRequest = new URLRequest("Strands.mp3"); var channel9:SoundChannel = new SoundChannel(); var sTransform9:SoundTransform = new SoundTransform(); myMusic9.load(soundFile9); var myMusic10:Sound = new Sound(); //Instantiation var soundFile10:URLRequest = new URLRequest("Toxic.mp3"); var channel10:SoundChannel = new SoundChannel(); var sTransform10:SoundTransform = new SoundTransform(); myMusic10.load(soundFile10); var myMusic11:Sound = new Sound(); //Instantiation var soundFile11:URLRequest = new URLRequest("Windows of the World.mp3"); var channel11:SoundChannel = new SoundChannel(); var sTransform11:SoundTransform = new SoundTransform(); myMusic11.load(soundFile11); //Listeners btnPlay.addEventListener(MouseEvent.CLICK, playMusic); btnStop.addEventListener(MouseEvent.CLICK, stopMusic); sldVolume.addEventListener(SliderEvent.CHANGE, changeVolume); btnPlay2.addEventListener(MouseEvent.CLICK, playMusic2); btnStop2.addEventListener(MouseEvent.CLICK, stopMusic2); sldVolume2.addEventListener(SliderEvent.CHANGE, changeVolume2); btnPlay3.addEventListener(MouseEvent.CLICK, playMusic3); btnStop3.addEventListener(MouseEvent.CLICK, stopMusic3); sldVolume3.addEventListener(SliderEvent.CHANGE, changeVolume3); btnPlay4.addEventListener(MouseEvent.CLICK, playMusic4); btnStop4.addEventListener(MouseEvent.CLICK, stopMusic4); sldVolume4.addEventListener(SliderEvent.CHANGE, changeVolume4); btnPlay5.addEventListener(MouseEvent.CLICK, playMusic5); btnStop5.addEventListener(MouseEvent.CLICK, stopMusic5); sldVolume5.addEventListener(SliderEvent.CHANGE, changeVolume5); btnPlay6.addEventListener(MouseEvent.CLICK, playMusic6); btnStop6.addEventListener(MouseEvent.CLICK, stopMusic6); sldVolume6.addEventListener(SliderEvent.CHANGE, changeVolume6); btnPlay7.addEventListener(MouseEvent.CLICK, playMusic7); btnStop7.addEventListener(MouseEvent.CLICK, stopMusic7); sldVolume7.addEventListener(SliderEvent.CHANGE, changeVolume7); btnPlay8.addEventListener(MouseEvent.CLICK, playMusic8); btnStop8.addEventListener(MouseEvent.CLICK, stopMusic8); sldVolume8.addEventListener(SliderEvent.CHANGE, changeVolume8); btnPlay9.addEventListener(MouseEvent.CLICK, playMusic9); btnStop9.addEventListener(MouseEvent.CLICK, stopMusic9); sldVolume9.addEventListener(SliderEvent.CHANGE, changeVolume9); btnPlay10.addEventListener(MouseEvent.CLICK, playMusic10); btnStop10.addEventListener(MouseEvent.CLICK, stopMusic10); sldVolume10.addEventListener(SliderEvent.CHANGE, changeVolume10); btnPlay11.addEventListener(MouseEvent.CLICK, playMusic11); btnStop11.addEventListener(MouseEvent.CLICK, stopMusic11); sldVolume11.addEventListener(SliderEvent.CHANGE, changeVolume11); //song1 function changeVolume(evt:SliderEvent):void { sTransform.volume = sldVolume.value; channel.soundTransform = sTransform; } function stopMusic(evt:MouseEvent):void { channel.stop(); } function playMusic (evt:MouseEvent):void { channel = myMusic.play(); } //song2 function changeVolume2(evt:SliderEvent):void { sTransform2.volume = sldVolume2.value; channel2.soundTransform = sTransform2; } function stopMusic2(evt:MouseEvent):void { channel2.stop(); } function playMusic2 (evt:MouseEvent):void { channel2 = myMusic2.play(); } //song3 function changeVolume3(evt:SliderEvent):void { sTransform3.volume = sldVolume3.value; channel3.soundTransform = sTransform3; } function stopMusic3(evt:MouseEvent):void { channel3.stop(); } function playMusic3 (evt:MouseEvent):void { channel3 = myMusic3.play(); } //song4 function changeVolume4(evt:SliderEvent):void { sTransform4.volume = sldVolume4.value; channel4.soundTransform = sTransform4; } function stopMusic4(evt:MouseEvent):void { channel4.stop(); } function playMusic4 (evt:MouseEvent):void { channel4 = myMusic4.play(); } //song5 function changeVolume5(evt:SliderEvent):void { sTransform5.volume = sldVolume5.value; channel5.soundTransform = sTransform5; } function stopMusic5(evt:MouseEvent):void { channel5.stop(); } function playMusic5 (evt:MouseEvent):void { channel5 = myMusic5.play(); } //song6 function changeVolume6(evt:SliderEvent):void { sTransform6.volume = sldVolume6.value; channel6.soundTransform = sTransform6; } function stopMusic6(evt:MouseEvent):void { channel6.stop(); } function playMusic6 (evt:MouseEvent):void { channel6 = myMusic6.play(); } //song7 function changeVolume7(evt:SliderEvent):void { sTransform7.volume = sldVolume7.value; channel7.soundTransform = sTransform7; } function stopMusic7(evt:MouseEvent):void { channel7.stop(); } function playMusic7 (evt:MouseEvent):void { channel7 = myMusic7.play(); } //song8 function changeVolume8(evt:SliderEvent):void { sTransform8.volume = sldVolume8.value; channel8.soundTransform = sTransform8; } function stopMusic8(evt:MouseEvent):void { channel8.stop(); } function playMusic8 (evt:MouseEvent):void { channel8 = myMusic8.play(); } //song9 function changeVolume9(evt:SliderEvent):void { sTransform9.volume = sldVolume9.value; channel9.soundTransform = sTransform9; } function stopMusic9(evt:MouseEvent):void { channel9.stop(); } function playMusic9 (evt:MouseEvent):void { channel9 = myMusic9.play(); } //song10 function changeVolume10(evt:SliderEvent):void { sTransform10.volume = sldVolume10.value; channel10.soundTransform = sTransform10; } function stopMusic10(evt:MouseEvent):void { channel10.stop(); } function playMusic10 (evt:MouseEvent):void { channel10 = myMusic10.play(); } //song11 function changeVolume11(evt:SliderEvent):void { sTransform11.volume = sldVolume11.value; channel11.soundTransform = sTransform11; } function stopMusic11(evt:MouseEvent):void { channel11.stop(); } function playMusic11 (evt:MouseEvent):void { channel11 = myMusic11.play(); }
VIEWS ON THIS POST

44

Posted on:

Thursday 25th October 2012
View Replies!

Editing flash application text content. Best way?

, I'm creating a Flash presentation, and the user wants to be able to change the text on any screen from Flash itself. This was my original my idea (I don't have much experience in AS): 1 - Put all the text in a text file (XML or plain). 2 - Make AS read the text and fill in the text fields in the Flash presentation. 3 - When it's needed to change the text content, execute the Flash presentation with a parameter that will tell AS to show all the fields as INPUT. 4 - Save the new text in the text file via PHP. But I have been asked if it would be possible to avoid the use of a text file (and the server connection with PHP) and change the swf text content directly with AS. Is this possible I have been googling it but with no success. I have the idea that this wouldn't be possible but i don't know all the possibilites in the Flash environment.
VIEWS ON THIS POST

245

Posted on:

Thursday 25th October 2012
View Replies!

Overlapping MovieClips and MouseEvent

i have this problem please help me. Want to keep both MovieClips MouseEvents, but when i roll_over both of them the bottom one does not fires MouseEvent.ROLL_OVER plz help. P.S. sorry for bad description low English knowladge. Source is Attached
VIEWS ON THIS POST

52

Posted on:

Thursday 25th October 2012
View Replies!

Create mobile application for Nokia E7 with Flash CS3?

. I am looking for a guide of how to create mobile apps using flash CS3. I am interested in Nokia E7 model and it is using Flash Lite 4.0. How can I create simple application and test it on the phone Any help is appreciated. Some links of guides also. I have been told that there is no difference of writing simple desktop application or mobile application.
VIEWS ON THIS POST

59

Posted on:

Thursday 25th October 2012
View Replies!

Android app menu swipe

, Im currently trying to make a prototype application in flash to port to my mobile. Theres a horizontal menu i have in it that i want the user to be able to swipe right or left and the menu objects (squares) reel that way till its 'momentum' runs out. There are 4 box objects in the menu and the ones at either side hang out the side, so to make it reel, theyd have to go through a magic door to the other side if u get me so that they can reel on and on.
VIEWS ON THIS POST

118

Posted on:

Thursday 25th October 2012
View Replies!

Pre-loading/exporting best approach?

You can also try having a loading swf that just loads the main content swf. So two swfs instead of two frames.
VIEWS ON THIS POST

154

Posted on:

Thursday 25th October 2012
View Replies!

Getting Movie Clips to Apppear and Disappear with the use of a timer

I'm re-creating a cctv style project, and I am trying to play flv's at different times using the timerEvent, as the flv's are embedded within one keyframe i need to use as3.. Any Ideas would be so helpful
VIEWS ON THIS POST

148

Posted on:

Thursday 25th October 2012
View Replies!

mouse cursor changes in flash apps

i have a flash loader thats loads many flash swf games, the problem is that the mouse corsair turns to the game's corsair and we trying to keep our original corsair. help will be appreciated.
VIEWS ON THIS POST

211

Posted on:

Thursday 25th October 2012
View Replies!

Flash how to ipad flash app save data

I'm planning to build an ipad flash game and would like to save some information, like user info like name and unlocked levels. How can i do that
VIEWS ON THIS POST

152

Posted on:

Thursday 25th October 2012
View Replies!

How to terminate a Flash application upon unforeseen errors?

How to terminate a Flash application upon unforeseen errors Dear all, I am writing up an app that must not be allowed to shut down the users system under any circumstances, thus I need to learn how I can terminate my app. What tools are there to do this So, Is there a basic way to have a global error sniff that somehow determines that the app needs to be terminated and thus prevents affecting other processes that are running PLS advice Jaxz
VIEWS ON THIS POST

209

Posted on:

Thursday 25th October 2012
View Replies!

Flash full screen exe/app

Been re-working a couple flash as3 movies that are to be exported as exe and app. They call in a few external flv's, swf's, and a few external images. Now, the old versions were kindof a mess, so I have been cleaning it up, and got it mostly down to a single frame, with no objects on the stage until I call them out via action script from the library. So far so good... At the top of my as is the line: this.stage.displayState = StageDisplayState.FULL_SCREEN; In the old versions this worked fine, but now in my re-worked version, the screen does open in full screen like it is supposed to, but the items on my stage are not expanding to the full screen size along with the stage itself. Was wondering what I should look for that could be messing it up
VIEWS ON THIS POST

52

Posted on:

Thursday 25th October 2012
View Replies!

Overlapping movieclips when zooming

I have function to zoom in and out a movieclip in one frame. Problem is that when i click on a button for another frame, where i have another picture, this from frame one, overlap. Code: koszula0.addEventListener(MouseEvent.ROLL_OVER, zoomIn_0); koszula0.addEventListener(MouseEvent.ROLL_OUT, zoomOut_0); function zoomIn_0(ev:MouseEvent):void{ this.setChildIndex(this.getChildByName(ev.target.name), this.numChildren-1); TweenLite.to(koszula0, 1, {scaleX:3, scaleY:3}); } function zoomOut_0(ev:MouseEvent):void{ TweenLite.to(koszula0, 1, {scaleX:1, scaleY:1}); } i have no idea how to unriddle this... thx. for any idea.
VIEWS ON THIS POST

155

Posted on:

Thursday 25th October 2012
View Replies!

Flash no pixelSnapping using copyPixels

I'm using copyPixels to draw a section of a Canvas bitmapData to a Screen bitmapData. A CanvasRectangle is moved around as a type of camera and here's the problem: Even though tracing out the Rectangle's X and Y shows they are float values, drawing to the Screen produces a type of pixelSnapping as if the Rectangle's coordinates were integers. I've tried setting the PixelSnapping of the Bitmap holding the Screen BitmapData to NEVER but it made no difference. Is there a way to copyPixels maintaining float values for X and Y
VIEWS ON THIS POST

88

Posted on:

Thursday 25th October 2012
View Replies!

Calling the flash application with javascript for batch processing?

boys and girls. I'm working on a cartoon series in the uk and we use flash, 3d and after effects. I'm building a little pipeline tool to help us compositors do your job (there's hundreds if not thousands of files to be comped for a great number of shows) anyhow, we use flash for the 2d animation and we need to extract pngs. Right now it's a process I can't streamline (ie compers still have to have flash opened to choose which layers to export manually) but I'd like to be able to open flash and launch a specific javascript file ('command') this is not AS3-related but does anyone of you know how to do this
VIEWS ON THIS POST

192

Posted on:

Thursday 25th October 2012
View Replies!

From -PI...PI wrapper.

all So I've been looking into faster sin/cos functions lately and found code for a faster method than Math.. that I've come to adopt in my code. Thing is, bit of code requires that the input value be between -PI..PI. Their suggestion was an if/then that would add/ subtract 2*PI.. Which meant that that would have to be in a while loop, too, (while value > PI......) until it is within range. Considering that I'm trying to optimize/speed up calls to sin/cos, that'd kinda defeat the purpose. So I took it upon myself to figure it out in one blow: Code: // xx = input value in radians var Sign:Number = ((xx < 0) -1 : 1); // if input value is +/-... /* xx is brought within realms of -PI..PI: -Pi * (1 if xx/Pi is odd, ie wraps back towards -PI ; 0 if even, ie tends to +PI ) + xx mod pi (remainder, will be +/- depending on orig value of xx); */ // So we have... xx = (-Sign*PI * (int(xx / PI) & 1)) + ( xx % PI); Now. I'd like to know if that is an efficient/effective/practical method, or if there's an easier way to get that value than what I've devised, as I'm hardly either mathematically or computer logically savvy lol, and I figure that I've gone a bit overkill and there's actually a simpler way to do this. Any help/hints/tips would be appreciated! , I am not going to comment on your code since don't have time to look it over as for now but optimizing sin/cos always boils down to lookup tables. There is nothing faster than making a sin/cos lookup table we used this method since assembler intros in the old DOS days and it works like charm unless you really need some high precision where the table size can get astronomical.
VIEWS ON THIS POST

47

Posted on:

Thursday 25th October 2012
View Replies!

huge problem when testing flash app in browser

something weird is going on. i am developing a website and when i test the movie on the flash IDE it works just fine, it also works on the standalone flashplayer. the problem im having is that when on the browser, plugin or ActiveX players it throws errors like this Property registerEventListener not found on app.projects.Projects_Model and there is no default value. i know everything is there because it works on when i test it.. but it seems that it cannot find the registerEventListener method from the inherited class inheritance is as follows EventBroadcaster which contains the [public function registerEventListene] BaseModel ProjectsModel is this a bug in the flash player or am i missing something \t
VIEWS ON THIS POST

125

Posted on:

Thursday 25th October 2012
View Replies!

Everything disappears when I'm in Fullscreen mode. What do I do?

I'm running a standalone EXE file via the Projector (or whatever it's called when you run a standalone EXE file made with Flash). It's NOT a web-based application. Every time I go to fullscreen mode, I just get a blank screen. of the images are gone. However, if I press Esc to exit the full screen mode, then the pictures appear again. Is this a bug with Flash CS3 This is what I put in the first frame of my movie in the 'actions' section: Code: import flash.system.fscommand; import flash.display.Stage; import flash.display.StageDisplayState; stage.scaleMode = StageScaleMode.SHOW_ALL; stage.displayState = StageDisplayState.FULL_SCREEN; stage.scaleMode = StageScaleMode.NO_SCALE; stage.align = StageAlign.TOP_LEFT; stage.displayState = "fullScreen"; stage['displayState'] = "fullScreen"; When I run the Flash program (as an exe file), the program goes fullscreen, but all of the elements on the stage disappear, leaving the screen blank. However, when I exit out of fullscreen mode (by pressing ESC) then everything looks like it's supposed to, with the images showing up and everything. Is there any way to fix this
VIEWS ON THIS POST

131

Posted on:

Thursday 25th October 2012
View Replies!

wmode transparent causes MCs to disappear

I've seen only a couple of threads on this topic and no one had a solution, but here is my problem: I have several movieclips that contain text boxes with filters on them (drop shadow). When I export the movie normally it works fine, but when its live on our site our jQuery menu gets covered up by it in IE. When I add in the embed param wmode="transparent" the menu works correctly (comes in over the top of the movie) but the MCs that had filters applied to them complete disappear. Does anyone know how to fix this
VIEWS ON THIS POST

102

Posted on:

Thursday 25th October 2012
View Replies!

Border not disappearing...

Im unable to figure out why the border I create is not removing its self after I removeChild. Here is my code: Code: function gallerySet(event:MouseEvent):void { picLoad.load(new URLRequest(myXML.Gallery[galNum].Image[event.target.name].@picURL)); picWidth = myXML.Gallery[galNum].Image[event.target.name].@Width; picHeight = myXML.Gallery[galNum].Image[event.target.name].@Height; addChild(holder); holder.addChild(picLoad); holder.addChild(bordCon); TweenLite.to(holder, .5, {alpha:1}); //TweenLite.to(border1, .5, {alpha:1}); picLoad.x = ((holder.width - picWidth) / 2) + 75; picLoad.y = (holder.height - picHeight) / 2; var border1:Shape = new Shape(); border1.graphics.lineStyle(1, 0xffffff); border1.graphics.drawRect(picLoad.x, picLoad.y, picWidth, picHeight); bordCon.addChild(border1); picLoad.alpha = 0; TweenLite.to(picLoad, 2, {alpha: 1}); holder.exitBtn.addEventListener(MouseEvent.CLICK, exit2); holder.addEventListener(MouseEvent.MOUSE_DOWN, dragOn2); holder.addEventListener(MouseEvent.MOUSE_UP, dragOff2); } //this is where I exit the holder... function exit2(event:MouseEvent):void { TweenLite.to(holder, .5, {alpha:0}); TweenMax.to(bkg, .5, {alpha:1}); holder.addEventListener(Event.ENTER_FRAME, exit2b); } function exit2b(event:Event):void { if (holder.alpha == 0 ) { bordCon.removeChildAt(0); removeChild(holder); holder.removeEventListener(Event.ENTER_FRAME, exit2b); } } the holder and border goes away, however when I go to another gallery the previous borders pop up. Instead of creating a new border and deleting the old one it is creating a new border and the old one still remains.
VIEWS ON THIS POST

55

Posted on:

Thursday 25th October 2012
View Replies!