1 Replies - 5335 Views - Last Post: 01 October 2012 - 01:06 PM

#1 Zarlach   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 26
  • Joined: 14-May 12

A button within a movieclip problem

Posted 29 September 2012 - 04:32 AM

Hi, I'm working no this small project where I have a virtual "notepad" (movieclip) laying on a desktop with buttons within that movieclip. I've made so when someone clicks on the notepad, actionscript changes its coordinates and scales it up to center the notepad and make it bigger. One of the buttons on the notepad is to go back to the desktop (scale the notepad back to its original size and position).
This is what I currently have:
var notepadView:Boolean = false; //False = notepad is not scaled up.
var notepadStartY:Number = notepad.y;
var notepadStartX:Number = notepad.x;
var notepadStartScaleX:Number = notepad.scaleX;
var notepadStartScaleY:Number = notepad.scaleY;
var stageMiddle:Number = 275;

notepad.addEventListener(MouseEvent.CLICK, viewNotepad);
notepad.notepadDesktop.addEventListener(MouseEvent.CLICK, gotoDesktop); //Goes back to the virtual desktop (scales down notepad).

function viewNotepad(evt)
	if (!notepadView)
		//"open" notepad
		notepad.scaleX *=2;
		notepad.scaleY *=2;
		notepad.x = stageMiddle;
		notepadView = true; //notepad is opened
		trace("Open"); //This is returned when trying to go back to desktop

function gotoDesktop(evt){
	if (notepadView){
		trace("notepadView = true"); //This one was returned
		notepad.scaleX *= 0.5;
		notepad.scaleY *= 0.5;
		notepad.x = notepadStartX;
		notepadView = false; //Sets notepad to closed
		trace("notepadView = false"); //This one was not returned

When I click on the button to go back to the desktop, it just traces "Notepad = true" (opened). It does not scale the notepad and set notepadView to false.

I also tried using root.notepad to scale it, but that gave an error saying:
1119: Access of possibly undefined property notepad through a reference with static type flash.display:DisplayObject.

This post has been edited by Zarlach: 29 September 2012 - 04:35 AM

Is This A Good Question/Topic? 0
  • +

Replies To: A button within a movieclip problem

#2 chinchang   User is offline

  • Indie Game Developer
  • member icon

Reputation: 192
  • View blog
  • Posts: 727
  • Joined: 22-December 08

Re: A button within a movieclip problem

Posted 01 October 2012 - 01:06 PM

Change your trace statement to:

trace('notepad is ' + notepad);
trace('scaleX is ' + notepad.scaleX);

and see what you get.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1