-
##NEED HELP AS3...Error Transitions #1009##
Hi I am using a gallery in one frame in my flash website that once it loads up it does not leave the page when going to another frame. This error pops up:
## [Tweener] Error: [object MovieClip] raised an error while executing the 'onComplete'handler.
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at website_final2_fla::MainTimeline/go_in()
at Function/http://adobe.com/AS3/2006/builtin::apply()
at caurina.transitions::Tweener$/updateTweenByIndex()
at caurina.transitions::Tweener$/updateTweens()
at caurina.transitions::Tweener$/onEnterFrame()
And here is my code:
stop();
import caurina.transitions.*;
var filename_list = new Array();
var url_list = new Array();
var url_target_list:Array = new Array();
var title_list = new Array();
var description_list = new Array();
var i:Number;
var tn:Number = 0;
var tween_duration:Number = 0.4;
var move_x:Number = 200;
var move_y:Number = -300;
//var fm_tween:Tween;
var total:Number;
var flashmo_xml:XML = new XML();
var folder:String = "photos/";
var xml_loader:URLLoader = new URLLoader();
xml_loader.load(new URLRequest("flashmo_130_photo_list.xml"));
xml_loader.addEventListener(Event.COMPLETE, create_thumbnail);
var thumbnail_group:MovieClip = new MovieClip();
stage.addChild(thumbnail_group);
thumbnail_group.x = tn_group.x;
var default_y:Number = thumbnail_group.y = tn_group.y;
tn_group.visible = false;
url_button.visible = false;
tn_title.text = "";
tn_desc.text = "";
tn_url.text = "";
tn_url_target.text = "";
function create_thumbnail(e:Event):void
{
flashmo_xml = XML(e.target.data);
total = flashmo_xml.thumbnail.length();
for( i = 0; i < total; i++ )
{
filename_list.push( flashmo_xml.thumbnail[i].@filename.toString() );
url_list.push( flashmo_xml.thumbnail[i].@url.toString() );
url_target_list.push( flashmo_xml.thumbnail[i].@target.toString() );
title_list.push( flashmo_xml.thumbnail[i].@title.toString() );
description_list.push( flashmo_xml.thumbnail[i].@description.toString() );
}
load_tn();
}
function load_tn():void
{
var pic_request:URLRequest = new URLRequest( folder + filename_list[tn] );
var pic_loader:Loader = new Loader();
pic_loader.load(pic_request);
pic_loader.contentLoaderInfo.addEventListener(Even t.COMPLETE, on_loaded);
tn++;
}
function on_loaded(e:Event):void
{
if( tn < total )
{
load_tn();
tn_desc.text = "Loading " + tn + " of " + total + " photos";
}
else
{
tn_title.text = title_list[0];
tn_desc.text = description_list[0];
tn_url.text = url_list[0];
tn_url_target.text = url_target_list[0];
var mc:MovieClip = MovieClip( thumbnail_group.getChildAt(total-2) );
mc.addEventListener( MouseEvent.CLICK, go_out );
Tweener.addTween( mc, { rotation: 0, time: tween_duration, transition: "easeOut" } );
url_button.visible = true;
url_button.addEventListener(MouseEvent.CLICK, goto_URL);
}
var flashmo_bm:Bitmap = new Bitmap();
var flashmo_mc:MovieClip = new MovieClip();
flashmo_bm = Bitmap(e.target.content);
flashmo_bm.x = - flashmo_bm.width * 0.5;
flashmo_bm.y = - flashmo_bm.height * 0.5;
flashmo_bm.smoothing = true;
var bg_width = flashmo_bm.width + 16;
var bg_height = flashmo_bm.height + 16;
flashmo_mc.addChild(flashmo_bm);
flashmo_mc.graphics.lineStyle(1, 0x999999);
flashmo_mc.graphics.beginFill(0xFFFFFF);
flashmo_mc.graphics.drawRect( - bg_width * 0.5, - bg_height * 0.5, bg_width, bg_height );
flashmo_mc.graphics.endFill();
flashmo_mc.x = move_x;
flashmo_mc.y = move_y;
flashmo_mc.rotation = 45;
flashmo_mc.name = "flashmo_" + thumbnail_group.numChildren;
Tweener.addTween( flashmo_mc, { x: Math.random() * 20 - 10, y: Math.random() * 20 - 10,
rotation: Math.random() * 20 - 10,
time: tween_duration * 2, transition: "easeOut" } );
thumbnail_group.addChildAt(flashmo_mc, 0);
}
function go_out(e:MouseEvent):void
{
var mc:MovieClip = MovieClip(e.target);
mc.removeEventListener( MouseEvent.CLICK, go_out );
Tweener.addTween( mc, { x: 220, y: -180, rotation: 45, time: tween_duration,
transition: "easeInQuart", onComplete: go_in } );
}
function go_in():void
{
var mc:MovieClip = MovieClip( thumbnail_group.getChildAt(total-1) );
var mc2:MovieClip = MovieClip( thumbnail_group.getChildAt(total-2) );
var s_no:Number = parseInt( mc.name.slice(8,10) ) + 1;
if(s_no == total) s_no = 0;
Tweener.addTween( mc, { x: Math.random() * 20 - 10, y: Math.random() * 20 - 10,
rotation: Math.random() * 20 - 10, time: tween_duration,
transition: "easeOut", onComplete: add_click } );
Tweener.addTween( mc2, { rotation: 0, time: tween_duration, transition: "easeOut" } );
thumbnail_group.addChildAt( mc, 0 );
tn_title.text = title_list[s_no];
tn_desc.text = description_list[s_no];
tn_url.text = url_list[s_no];
tn_url_target.text = url_target_list[s_no];
}
function add_click():void
{
var mc:MovieClip = MovieClip(thumbnail_group.getChildAt(total-1) );
mc.addEventListener( MouseEvent.CLICK, go_out );
}
function goto_URL(me:MouseEvent)
{
navigateToURL(new URLRequest(tn_url.text), tn_url_target.text);
}
link_to_205.addEventListener( MouseEvent.CLICK, goto_205 );
function goto_205(me:MouseEvent)
{
navigateToURL(new URLRequest("http://www.flashmo.com/preview/flashmo_205_stack_gallery"), "_parent");
}
stop();
...If anyone could help me solve my problem it would be greatly appreciated thanks!
-
Senior Member
From your error it seems that the MovieClip mc is null in the onComplete handler function go_in. You need to trace mc and mc2 inside of the go_in() function and see if one of them is null.
- The right of the People to create Flash movies shall not be infringed. -
-
Add this code before going to another frame...
Code:
stage.removeChild(thumbnail_group);
Also, when adding event listeners use weak reference, to aid in garbage collection.
Code:
// like this...
url_button.addEventListener(MouseEvent.CLICK, goto_URL, false, 0, true);
-
Originally Posted by dawsonk
Add this code before going to another frame...
Code:
stage.removeChild(thumbnail_group);
Also, when adding event listeners use weak reference, to aid in garbage collection.
Code:
// like this...
url_button.addEventListener(MouseEvent.CLICK, goto_URL, false, 0, true);
thank you so much that work perfectly!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|