I just started to learn how to write classes, or external AS files. I have a few movies and they are receiving the same error: #1120 Access of Undefined Property. I’ve checked Curtis Morley, but I don’t think the problem is the instance names. Since I’m adding the the movieclips with the codes. Both movies’ errors occur where it contains “e.bytesLoaded / e.bytesTotal;” Does any know what’s happening? I’m confused…
package com {
import flash.net.URLRequest;
import flash.events.Event;
import flash.events.ProgressEvent;
import flash.display.Loader;
import flash.display.MovieClip;
import flash.text.*;
public class PreloaderIndex extends MovieClip {
public var l:Loader = new Loader();
public var perc:Number = e.bytesLoaded / e.bytesTotal;
public function PreloaderIndex (event:Event):void {
l.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, loop);
l.contentLoaderInfo.addEventListener(Event.COMPLETE, done);
l.load(new URLRequest("index02.swf"));
}
public function loop(event:ProgressEvent):void {
percent.text = Math.ceil(perc*100).toString();
}
public function done(event:Event):void {
removeChildAt(0);
percent = null;
addChild(l);
}
}
}
package com {
import fl.transitions.Tween;
import fl.transitions.easing.*;
import flash.display.Loader;
import flash.display.MovieClip;
import flash.net.*;
import flash.events.*;
import flash.text.*;
public class Content extends MovieClip {
public var xmlPath:String = "menu.xml";
public var settingsXML:XML;
public var tweensArray:Array = new Array();
public var buttonTween:Tween;
public var loader = new URLLoader();
public function Content(){
loader.load (new URLRequest(xmlPath));
loader.addEventListener (Event.COMPLETE, xmlLoaded);
}
public function xmlLoaded (e:Event):void {
if ((e.target as URLLoader) != null ) {
settingsXML = new XML(loader.data);
settingsXML.ignoreWhitespace = true;
createMenu ();
}
}
public var menuItem:MenuItem;
public var i:uint = 0;
public var orgAlpha:Number = 0.5;
public var newAlpha:Number = 1;
public function createMenu ():void {
for each (var link:XML in settingsXML..link) {
menuItem = new MenuItem();
menuItem.id = i;
menuItem.menuLabel.text = link.@name;
menuItem.menuLabel.autoSize = TextFieldAutoSize.LEFT;
menuItem.x = 0;
menuItem.y = 0 + i*30;
menuItem.alpha = 0.5;
menuItem.buttonMode = true;
menuItem.mouseChildren = false;
menuItem.addEventListener (MouseEvent.MOUSE_OVER, mouseOverHandler);
menuItem.addEventListener (MouseEvent.MOUSE_OUT, mouseOutHandler);
menuItem.addEventListener (MouseEvent.CLICK, mouseClickHandler);
addChild (menuItem);
i++;
}
}
public var targetID:int;
public var pathToSWF:String;
public var swfloader:Loader = new Loader();
public function swfLoader ():void {
swfloader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgress);
swfloader.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete);
swfloader.x = 200;
}
public var request:URLRequest = new URLRequest(pathToSWF);
public function mouseClickHandler(e:MouseEvent):void {
targetID = e.currentTarget.id;
pathToSWF = String(settingsXML..link[targetID].@swfurl);
swfloader.load(request);
}
public var p:Number = (e.bytesLoaded / e.bytesTotal) * 100;
public function onProgress(e:ProgressEvent):void {
trace(p);
}
public function onComplete(e:Event):void {
addChild(swfloader);
}
public function mouseOverHandler (e:Event):void {
buttonTween = new Tween(e.target, "alpha", Regular.easeOut, orgAlpha, newAlpha, 0.25, true);
}
public function mouseOutHandler (e:Event):void {
buttonTween = new Tween(e.target, "alpha", Regular.easeOut, newAlpha, orgAlpha, 0.25, true);
}
}
}