View Full Version : 1120: Access of undefined property stage.
Raziel
January 27th, 2008, 09:56 AM
[edit] excuse my stupidyt, already fixed that problem myself ^^
posted another question below this one.
Raziel
January 27th, 2008, 09:58 AM
Ah right.. nm.. fixed it *doh*
[edit]
I'll just change my question if you don't mind the spam:
The logo doesn't change position when a resize occurs so i put the function inside the onStageResize function except nothing happens now after a resize: /
As for the Background scaling, i think there's a flaw in my code there that i can't figure out, at certain spots there's a black edge next to or underneath the image so that would mean it doesn't scale properly.
package {
import flash.display.Loader;
import flash.events.Event;
import flash.display.MovieClip;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.net.URLRequest;
public class Main extends MovieClip {
public var logo:Loader;
public function Main() {
init();
}
private function init():void {
initStage();
initLogo();
initBG();
initListeners();
}
private function initStage():void {
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;
}
private function initLogo():void {
var logo:Loader = new Loader();
addChild(logo);
logo.load(new URLRequest("images/logo.png"));
logo.x = 2;
logo.y = stage.stageHeight - 92;
}
private function initListeners():void {
stage.addEventListener(Event.RESIZE, onStageResize);
}
private function initBG():void {
bgMC.x = 0;
bgMC.y = 0;
bgMC.width = stage.stageWidth;
bgMC.height = stage.stageHeight;
}
private function onStageResize(event:Event):void {
//als width > height dan code resize 1, als height > width dan code resize 2
if (stage.stageHeight > stage.stageWidth) {;
bgMC.width = stage.stageWidth;
bgMC.height = stage.stageWidth * 0.55;
} else if (stage.stageHeight < stage.stageWidth) {
bgMC.height = stage.stageHeight;
bgMC.width = stage.stageHeight * 1.8;
}
logo.y = stage.stageHeight - 92;
}
}
}
I keep getting
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at Main/::onStageResize()
And i know what it means just slightly at a loss at how to fix it.
daleth
January 27th, 2008, 03:40 PM
Hehe, Dutch looks so similar to German sometimes X-)
Anyway, I don't see where you've declared bgMC. That's probably the "null object reference" the error is referring to. Is it something that's already on the stage in your document?
Raziel
January 27th, 2008, 04:51 PM
No i load the logo.png
i put it on stage with
private function initLogo():void {
var logo:Loader = new Loader();
addChild(logo);
logo.load(new URLRequest("images/logo.png"));
logo.x = 2;
logo.y = stage.stageHeight - 92;
}
and then set the new position if the channel resizes
logo is declared however
aneuryzma
February 10th, 2009, 04:05 AM
how ?
I also get 1120: Access of undefined property stage.
This is my code:
package {
import flash.display.Sprite;
import flash.events.Event;
public class ParticleDemo extends Sprite {
private var emitterX:Number=stage.stageWidth/2;
private var emitterY:Number=stage.stageHeight/2;
public function ParticleDemo() {
stage.addEventListener(Event.ENTER_FRAME, onLoop, false, 0, true);
}
private function onLoop(evt:Event):void {
var p:Particle=new Particle(emitterX,emitterY,Math.random()*11-6,Math.random()*-20,1,Math.random()*0xFFFFFF);
addChild(p);
}
}
}
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.