I looked online, but couldn't find anything helpful. I got these codes on the web, but they're not working.... (I'm pretty new to flash).
-----------------------------------------------
projectgallery.swf - PARENT SWF
projectgallery_cutLimestone.swf - EXPORT SWF
returnToAlbums_btn_inst - instance of a button on the export swf that I want to be able to click to go to a different frame in the parent SWF
___________________________
Here are my codes:
------------------------------------------------
on the parent SWF:
import flash.display.MovieClip;
import flash.events.MouseEvent;
var myLoader:Loader = new Loader();
var url:URLRequest = new URLRequest("projectgallery_cutlimestone.swf");
myLoader.load(url);
function loadHandler (event:Event) {
var projectgallery_cutlimestone:MovieClip = event.target.content;
addChild(myLoader);
trace(projectgallery_cutlimestone);
function returnToAlbums (event:MouseEvent):void {
projectgallery_cutlimestone.returnToAlbums_btn_inst.play();
}
projectgallery_cutlimestone.addEventListener(MouseEvent.CLICK, returnToAlbums);
}
myLoader.contentLoaderInfo.addEventListener(Event.COMPLETE,loadHandler );
---------------------------------------------
When I try it, the SWF loads fine, but when it loads, this OUTPUT error appears:
[object Main]
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at Main/frame2()
at flash.display::MovieClip/gotoAndStop()
at Main/preload1()
--------------------------------------------------
then, when I try to click the button returnToAlbums_btn_inst, this OUTPUT error appears:
ReferenceError: Error #1069: Property play not found on flash.display.SimpleButton and there is no default value.
at Function/<anonymous>()
-------------------------------------------------
I'm really new to flash, so I don't know why it's not working. The instance is labeled (I double-checked).
Okay.... I tried deleting the whole Handler function (I didn't really know what that was anyway-- just saw it online...?)
---------------------------------------
So now for my parent SWF, my code is:
--------------------------------------
import flash.display.MovieClip;
import flash.events.MouseEvent;
var myLoader:Loader = new Loader();
var url:URLRequest = new URLRequest("projectgallery_cutlimestone.swf");
myLoader.load(url);
addChild(myLoader);
--------------------------
for my exported SWF:
-----------------------------------
stop();
returnToAlbums_btn_inst.addEventListener(MouseEvent.CLICK, gotoAlbums);
function gotoAlbums(event:MouseEvent):void {
parent.gotoAndStop(2);
}
-----------------------------
by the function preload do you mean the one that originally preloads my parent swf on frame 1? here's that:
---------------------------------
import flash.events.Event;
stop();
this.addEventListener(Event.ENTER_FRAME, preload1);
function preload1(e:Event):void{
var total_bytes:Number = this.stage.loaderInfo.bytesTotal;
var loaded_bytes:Number = this.stage.loaderInfo.bytesLoaded;
if (total_bytes==loaded_bytes){
gotoAndStop(2);
this.removeEventListener(Event.ENTER_FRAME, preload1);
}
}
on the parent swf:
-----------
stop();
cutLimestone_btn_inst.addEventListener(MouseEvent.CLICK, gotoCutLimestone);
function gotoCutLimestone(event:MouseEvent):void {
gotoAndStop("cutLimestone_btn_frame");
}
-------------------
on the export swf:
--------
stop();
returnToAlbums_btn_inst.addEventListener(MouseEvent.CLICK, gotoAlbums);
function gotoAlbums(event:MouseEvent):void {
parent.gotoAndStop(2);
}
Export SWF works without error now, but parent SWF returns:
-------------------------------------------
TypeError: Error #2007: Parameter child must be non-null.
at flash.display::DisplayObjectContainer/addChild()
at Main/frame3()
at flash.display::MovieClip/gotoAndStop()
at Main/gotoCutLimestone()
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at Main/preload1()
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at Main/preload1()
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at Main/preload1()
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at Main/preload1()
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at Main/preload1()
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at Main/preload1()
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at Main/preload1()
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at Main/preload1()
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at Main/preload1()
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at Main/preload1()
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at Main/preload1()
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at Main/preload1()
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at Main/preload1()
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at Main/preload1()
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at Main/preload1()
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at Main/preload1()
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at Main/preload1()
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at Main/preload1()
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at Main/preload1()
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at Main/preload1()
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at Main/preload1()
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at Main/preload1()
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at Main/preload1()
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at Main/preload1()
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at Main/preload1()
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at Main/preload1()
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at Main/preload1()
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at Main/preload1()
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at Main/preload1()
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at Main/preload1()
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at Main/preload1()
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at Main/preload1()
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at Main/preload1()
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at Main/preload1()
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at Main/preload1()
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at Main/preload1()
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at Main/preload1()
-----------------------------------------
under OUTPUT when I try to load the SWF. The returnToAlbums_btn_inst doesn't work still either.
Yes you do ![]()
It's the one that's generating tons of errors you just posted.
Beaastie wrote:
-----------------------------
by the function preload do you mean the one that originally preloads my parent swf on frame 1? here's that:
---------------------------------
import flash.events.Event;
stop();
this.addEventListener(Event.ENTER_FRAME, preload1);
function preload1(e:Event):void{
var total_bytes:Number = this.stage.loaderInfo.bytesTotal;
var loaded_bytes:Number = this.stage.loaderInfo.bytesLoaded;
if (total_bytes==loaded_bytes){
gotoAndStop(2);
this.removeEventListener(Event.ENTER_FRAME, preload1);
}
}
Okay, now the OUTPUT error says:
TypeError: Error #2007: Parameter child must be non-null.
at flash.display::DisplayObjectContainer/addChild()
at Main/frame3()
at flash.display::MovieClip/gotoAndStop()
at Main/gotoCutLimestone()
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at Main/frame2()
at flash.display::MovieClip/gotoAndStop()
at Main/preload1()
and it doesn't even load the export swf.
The handler funciton you deleted in parent wasn't useless.. we'll have to put it back. With some modifications..
change parent code from
import flash.display.MovieClip;
import flash.events.MouseEvent;
var myLoader:Loader = new Loader();
var url:URLRequest = new URLRequest("projectgallery_cutlimestone.swf");
myLoader.load(url);
addChild(myLoader.content);
to
import flash.display.MovieClip;
import flash.events.MouseEvent;
import flash.events.Event;
var myLoader:Loader = new Loader();
var url:URLRequest = new URLRequest("projectgallery_cutlimestone.swf");
myLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadCompleteHandler);
myLoader.load(url);
function loadCompleteHandler(event:Event):void {
addChild(myLoader.content);
}
Fingers crossed!
Oh my. Let's try one more thing, if it doesn't work, pack the whole project and send me link via private message.
change parent one more time:
import flash.display.MovieClip;
import flash.events.MouseEvent;
import flash.events.Event;
import flash.events.ProgressEvent;
var myLoader:Loader = new Loader();
var url:URLRequest = new URLRequest("projectgallery_cutlimestone.swf");
myLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, loadProgressHandler);
myLoader.load(url);
function loadProgressHandler(event:Event):void {
if(myLoader.content) {
addChild(myLoader.content);
myLoader.contentLoaderInfo.removeEventListener(ProgressEvent.PROGRESS, loadProgressHandler);
}
}
OK, fixed.
The main problem was in naming your Document classes. In both files, the Document class was Main. Flashplayer caches all class definitions so they can be reused and shared between loaded swfs. This is really useful feature if you're aware of it. Otherwise it can cause quite a headache. The errors seem to pop out for no apparent reason etc. I renamed the Document class of first swf to Index. Make sure you never ever have two document classes with the same name. You should change the Main also to CutLimestone if you plan on loading other galleries.
I also made some smaller changes - make sure to copy them to new galleries so they all behave the same.
Good luck!
North America
Europe, Middle East and Africa
Asia Pacific