submenus wont work action script 3 flash cc professional - actionscript-3

Hi and sorry in advance I'm super new and took me like 5 hours to reach this point!
I'm working on a project to teach young and not so young how to use windows.
so far I'm almost done but I'm having trouble on making my submenus live.
Yet so far I've completed 2 mc's on flash cc 2015 professional, its a windows start button that calls all the menu or buttons like allapps, power, settings etc..
once the menu moves can give any action to the rest of the mc's allapps, power. settings etc... get "Scene 1, Layer 'actions', Frame 1, Line 16, Column 1 1120: Access of undefined property menu1_btn."
the current ac is the following:
import fl.transitions.Tween;
import fl.transitions.easing.*;
import fl.transitions.TweenEvent;
startbtn_mc.buttonMode=true;
dropdown_mc.buttonMode=true;
startbtn_mc.addEventListener(MouseEvent.CLICK,dropUp);
function dropUp(e:MouseEvent):void
{
var enterTween:Tween;
enterTween = new Tween(dropdown_mc,"y",Regular.easeOut, dropdown_mc.y, 15.3, 30, false);
}
menu1_btn.addEventListener(MouseEvent.CLICK, gotoMovie);
function gotoMovie(e:MouseEvent):void
{
var moviescene:MovieClip = new movie();
stage.addChild(moviescene);
}
enterTween.addEventListener(TweenEvent.MOTION_FINISH,dropUpEventListener);
}
function dropUpEventListener(e:TweenEvent):void
{
startbtn_mc.removeEventListener(MouseEvent.CLICK,dropUp);
startbtn_mc.addEventListener(MouseEvent.CLICK,dropdown);
}
function dropdown(e:Event):void
{
var enterTween:Tween;
enterTween = new Tween(dropdown_mc,"y",Regular.easeOut, dropdown_mc.y, 470, 30, false);
enterTween.addEventListener(TweenEvent.MOTION_FINISH,dropdownEventListener);
}
function dropdownEventListener(e:TweenEvent):void
{
startbtn_mc.removeEventListener(MouseEvent.CLICK,dropdown);
startbtn_mc.addEventListener(MouseEvent.CLICK,dropUp);
}
I realize there are 9 buttons to go and I'm not able to move forward.
Please help!!!!!

Layer 'actions', Frame 1, Line 16, Column 1 1120: Access of undefined
property menu1_btn.
The error messages have specific meanings and refer you to exactly where and why the error is occuring:
on Frame 1
in Layer "actions:"
on line 16
you are referencing menu1_btn
BOOM – it is undefined.
Does menu1_btn exist? Is it named something else? A great mystery.
None of us can tell just from the code you posted what is going on in your .fla file – e.g. how it is structured, what elements are in what frames, etc.
Half of programming is debugging. Tuck in.
(and it is completely unclear what this question has to do with "sub-menus")

Related

AC3 Error 1119 - dynamic instance?

I'm not very familiar with scripting in general or in Actionscript 3, but at current I am working on a sort of motion comic project.
At the end of each 'chapter' I want the comic panel to close, a new button to appear and the layer that prevents pressing on stuff in the background to move outside of the screen. This is the code I use.
this.addEventListener(MouseEvent.CLICK, endcomic);
function endcomic(event: MouseEvent): void {
parent.parent.x = -480;
parent.parent.y = 0;
parent.parent.gotoAndStop(1);
parent.parent.parent.comicclose.x = -1920;
parent.parent.parent.btn02.x = 1476,2;
}
But I keep getting the error
Symbol 'window01', Layer 'Actions', Frame 8, Line 8, Column 23 1119: Access of possibly undefined property btn02 through a reference with static type flash.display:DisplayObjectContainer.
So apparently it has something do to with the loads of instances in instances I have, yet I cannot quite understand where the problem exaclty lies.
According to your code, I think You can put comicclose and btn02 in same parent, and set btn02's visible property to false at first. Then in your endcomic function, set btn02's visible to true and set its x position.

How to create bmi calculator inside flash cs5.5 using actionscript 3.0?

I'm not very familiar with flash so this is my current problem to deal with. I've found some code but it's in actionscript 2.0, when i tried to run it in my project, it shows the following error.
Here are my errors:
1. Scene 1, Layer 'Layer 2', Frame 1, Line 6
1067: Implicit coercion of a value of type Number to an unrelated type flash.text:TextField.
Scene 1, Layer 'Layer 2', Frame 1, Line 8
1180: Call to a possibly undefined method on.
Scene 1, Layer 'Layer 2', Frame 1, Line 8
1120: Access of undefined property release.
var weight_BMI;
var height_BMI;
var BMI_FINAL;
total_BMI=Number(weight_BMI.text)/(Number(height_BMI.text)*Number(height_BMI.text));
on(release){
trace(weight_BMI.text)
trace(height_BMI.text)
trace(BMI_FINAL)
}
AS2 is very different from AS3. AS3 works by using methods (in the same way as Java, for example). See the code below as an example (note, you may need to edit/rename your fields to get it to compile)
It works by attaching a Click EventListener to your calculate button which when triggered it runs the calculateBMI method. This method then performs the calculation and prints the result to your text field.
var myBmi:TextField;
var total_BMI:Number;
function calculateBMI(e:MouseEvent):void
{
total_BMI = Number(weight_BMI.text)/(Number(height_BMI.text)*Number(height_BMI.text));
myBmi.text = String(total_BMI);
}
btnCalculate.addEventListener(MouseEvent.CLICK, calculateBMI);

Loading movie with a button

I am trying to load movies via buttons interaction with ActionScript 3.0. I am creating this movie from Flash CS 5.5.
I could get the first button (I called 'Preface') to work. When adding the second button, I got this error at runtime:
Scene 1, Layer 'Actions', Frame 1, Line 22 1023: Incompatible override.
Scene 1, Layer 'Actions', Frame 1, Line 22 1021: Duplicate function definition.
There dun seem to be any duplicate that could initiate any overrides:
//import flash.events.MouseEvent;
preface.addEventListener(MouseEvent.CLICK, preface1);
sq.addEventListener(MouseEvent.CLICK, sq);
function preface1(event:MouseEvent):void
{
// Start your custom code
// This example code displays the words "Mouse clicked" in the Output panel.
trace("Mouse clicked");
var preface:Preface= new Preface;
addChild(preface);
preface.removeEventListener(MouseEvent.CLICK, preface1);
// End your custom code
}
function sq(event:MouseEvent):void
{
//Get sample menus
}
Any pointers is highly appreciated.
You have an instance of a MovieClip named sq, and you declare a function with name sq. This is no longer possible to do with Actionscript 3. You have to name your function something other than sq or preface, as this name is occupied by your another MC.

How to fix AS3 TypeError: Error #1009: Cannot access a property or method of a null object reference?

I am getting this error:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at Skool_fla::MainTimeline/frame1()[Skool_fla.MainTimeline::frame1:10]
at flash.display::MovieClip/gotoAndStop()
at Skool_fla::MainTimeline/goback()[Skool_fla.MainTimeline::frame2:22]
What is causing this error and how do I fix it?
This is my code for both the frames:
Frame 1: This is the main menu screen where you can access the credit section
import flash.events.MouseEvent;
//setting up the variables
//events
//stop the timeline
stop();
//the play button
play_btn.addEventListener(MouseEvent.CLICK, playani);
function playani(e:MouseEvent)
{
//asking it to progress to the load menu
gotoAndStop(3);
}
//the credits button
credit_btn.addEventListener(MouseEvent.CLICK, creditslide);
function creditslide(e:MouseEvent)
{
//asking it to go the credits frame
gotoAndStop(2);
}
Frame 2: This is where the credits appear
//
//
//all the imports
//events
var credit:credits_bck = new credits_bck ();
var credits_name: credit_nm = new credit_nm ();
var back_butn: back_button = new back_button ();
addChild (credit);
addChild (credits_name);
addChild (back_butn);
back_butn.addEventListener(MouseEvent.CLICK,goback);
function goback(G:MouseEvent)
{
removeChild (credit);
removeChild (credits_name);
gotoAndStop(1);
}
Either play_btn or back_butn is null. Your error message's line numbers don't correspond to your code so it's hard to say. But the gist is you're trying to access a property of something that isn't anything. Check to make sure you're initializing your variables/references properly.
Maybe your problem is Flash bug too.
In my FLA there was a layer with one empty keyframe. If I puted a vector graphics on it, the error was gone. If there was one or multiple MovieClips and there was no vector graphic - the error was there again.
Then I made a new layer and copy pasted all the objects from damaged layer to new and deleted the damaged layer. It solved the problem.
NOTE: Don't copy the keyframes. Only copy the contents.
Now my project is much more complicated and sadly the error came back again.
Test movie frequently and if the error comes back, check the last keyframes and layers you created.

Flash CS5.5 Output Error

I have been creating a hypermedia player, and i have got to a stage where it is glitching out and it is apparently a...
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at AvalancheCityHypermediaPlayer_fla::MainTimeline/fl_CustomMouseCursor()
Here is my code:
import flash.events.Event;
cust_cursor.mouseEnabled= false;
cust_cursor.addEventListener(Event.ENTER_FRAME, fl_CustomMouseCursor);
function fl_CustomMouseCursor(event:Event)
{
cust_cursor.x = stage.mouseX;
cust_cursor.y = stage.mouseY;
}
Mouse.hide();
I am not sure why it is not working properly, basically when a button is hovered over it is meant to jump to frame 2 and stop, but it is jumping to that frame, and then jumping straight to frame 1 without stopping on frame 2, and stops on frame 1.
1 . Your error isn't producing a line number. You (and I) will find this invaluable for debugging; if in the Flash IDE, you can turn this on in the Publish Settings under swf preferences as a toggle titled "Permit debugging".
2 . Is this code inside a class, or in document code (e.g., Flash IDE "Actions" tab)? If it's inside a class, make sure you pass a reference of the stage to the constructor of your class and assign it to an internally persistent variable so that fl_CustomMouseCursor can address it. By default, classes have no internal way of referencing the stage, and I'm assuming that's what's producing your #1009 error.
For example, inside your class constructor...
package com.example {
public class MyClass {
private var stage;
public function MyClass(arg) {
stage = arg;
}
}
}
And outside when instantiating the class...
var myObj:MyClass = new MyClass(stage);
3 . If you want your code to stop on a frame, use stop(); or gotoAndStop()
4 . Finally, if you're compiling with Flash IDE, you can debug this and see exactly which variable in the stack the runtime environment is having issues with. You can access it from the debug menu or by compiling with control-shift-enter.