ActionScript 3.0 :: Load SWF And Add Linked Classes To Stage
Jun 24, 2009
- I have a player.as with code to control playback of videos
- I have a skin.as with code to control and organise skin components
- The skin.as file loads a "shared library" (quotes as I don't think I'm doing this correctly) which is essentially a swf file with nothing on the stage. It's library contains things like: play buttons, scrub bars etc. all these assets have associated, linked class files to add functionality.
1. Load the containing swfs
2. Create new instances of the linked classes
3. Add them to the stage to be used.
However, there is an issue preventing me from using the linked assets in this way - I can't use the linked assets unless-
- I add something to the stage of the "shared library" swf
- I then do something like skinSwf.addChild(libraryFile)
What I want to do is just use the linked assets, not have to deal with any other parts of the "shared library" file.
View 4 Replies
Similar Posts:
Oct 28, 2009
I have been struggling with what seems to be simple concept in ActionScript 3.0 - how to communicate between classes. I have a very simple experiment with two movieclips on the stage. They are named YellowBox and RedBox in my library. I have linked the following code to the YellowBox movieclip:
package{ import flash.display.MovieClip; import flash.events.MouseEvent; public class YellowBox extends MovieClip { public function YellowBox() { this.addEventListener(MouseEvent.ROLL_OVER, rollOverHandler); } public function rollOverHandler(event:MouseEvent):void { this.x = x + 3; } }}
What I would like to do is call the YellowBox() function on my RedBox MovieClip with the following code:
package{ import flash.display.MovieClip; import flash.events.MouseEvent; public class RedBox extends MovieClip { public function RedBox() { YellowBox(); } }}
I get the following message when I compile: 1136: Incorrect number of arguments. Expected 1.
View 2 Replies
Sep 15, 2010
So I have a menu built inside of Flash CS4 that has a graphic for a background and five text fields that sit on it for menu options. The whole thing is saved as a movie clip in the library. The text fields all have instance names like infoBtn and mapBtn etc. and the menu is already on the stage and linked to it's own class in the library. My problem is accessing those text fields on the menu from the class. I keep getting "Error #1009: Cannot access a property or method of a null object reference." and the menu doesn't work. But if I trace the infoBtn.text in the class it outputs the text that is in the text field. So the code is accessing it but it's still not working?
Code:
package classes
{
import flash.display.*;
import flash.events.*;
[cODE].....
View 0 Replies
Apr 2, 2010
I'm building a video player using Flash CS4 (hereby referred to as "Flash") to create the graphic symbols and compiling and debugging with Flash Builder 4 ("FB4"). Here are the steps I take in my current workflow: --Create the graphic symbols in Flash. I've created a few different symbols for the player, but I'll focus on just the play/pause button ("ppbutton") here. --In the Library panel, I go to the ppbutton symbol's Linkage properties and link to a class named assets.PlayPauseButtonAsset that extends MovieClip. I do not actually have an assets package nor do I have a class file for PlayPauseButtonAsset as Flash will create them for me when I publish.
--In Flash's Publish settings, I set the project to export a SWC that will be used in FB4, called VideoPlayerAssets.swc. --After the SWC is created, I create my FB4 project called "VideoPlayer" and add the SWC to my path. FB4 creates the class VideoPlayer in the default package automatically. --In VideoPlayer.as, I import assets.*, which imports all of the symbol classes I created in Flash and are available via VideoPlayerAssets.swc. I can now instantiate the ppbutton and add to the stage, like this:
[Code]...
View 2 Replies
Oct 12, 2011
I'm trying to add a sprite to a stage made from bitmapData I link to from the library with the identifier pointerGraphic, here's my code:
Pointer.as
package com.George.BMIapp
{
import pointerGraphic;
import flash.display.BitmapData;
[Code]....
Yet nothing appears on the stage, yet there are no errors (I'm in strict mode with debugging enabled).
View 2 Replies
Nov 28, 2007
I'm trying to link a clip to a class, and it goes well until I try to access MovieClips or TextFields placed on the stage within that clip from code in the class. My code is below; there is a TextField called output_txt on the stage within this clip.
class Main extends MovieClip{
public function Main() {
//trace("123"); <--if I replace the line below with this, it traces nicely
output_txt.text = "123";
stop();
}
}
View 3 Replies
Mar 31, 2009
Using flash 8 pro, I've imported a video clip and embedded cue points at the first and last frames - these are named 'intro' and 'outro'. I have the flv paused at the first and last frames via the component inspector, and it is a 'talking head' type affair - all good so far.
At the very end of the video clip I want the 'outro' cue point to dynamically load a movie clip from the library with the linkage name 'p-overlay_mc' which will, in effect, blend a logo over the video when it ends. Can this be done?
I guess this sort of cue point triggered event is the equivalent of an 'enterFrame' event. My guess is that i will need a script from the root timeline targetting the cue point within the .flv, but i really don't know the script needed.
View 1 Replies
Nov 29, 2011
How can find out the linked url of the image in the flash of a website? I looked for the image url some time. but couldn't find itif find the linked url of the image, and i want to alter an image linked url address. where is the code in?
View 3 Replies
Aug 28, 2010
i've been all afternoon trying to figure out a solution to my problem, and I can't seem to find it, or cannot implement it. Let me lay it out for you: I have an actionscript file linked to a movieclip. (movieclip:skate class linked: generic_skate).I have it set up that way so I can create an array of skates easily (i'm using a for loop to create them), and each skate has its own attributes (name, description, price and the image that is supposed to go on the deck)In the stage, i have three text boxes, one for the price, other for the name, and another one for the description.In the generic_skate class, I'm handling all the mouse events (in this case mouseOver and mouseOut.
What i want to accomplish is: when the user hovers over a skate, the info shows up in the text fields and when he hovers out, the info goes away. My problem: Since I'm doing all the mouse interaction in the class file, my guess is that I have to access the stage to get to the text boxes that are placed there to change its info or somehow create a "middle" man to do all the handling.
View 5 Replies
Jul 27, 2009
On the mxmlc command line, I can include paths to RSL files. I can choose to link these RSLs at runtime by setting
-static-link-runtime-shared-libraries=false What if I need to link to some rsls and embed (static-link) other rsls? Is there a way to set the link settings for each rsl?
View 1 Replies
May 18, 2010
im trying to make a website based on flash.and im trying to link flash to XML.And here is my problem.I have a layer called "Pages", and im working in one of the pages.I made a timeline, which also had few more pages (5 to be exact).I want to load 1 linked image (as in you click on the image and then load something) on each of the 5 layer based on XML File, and when its clicked it loads on a new page in the "MAIN" site. If thats possible. How would I make that happen?
View 3 Replies
Apr 6, 2009
I am dynamically loading external SWFs in a Main Fla in response to clicks on a menu.
The loading code is standard and works fine for all of the SWFs except one. When I try to load it I get the following error: Error #2044: Unhandled IOErrorEvent:. text=Error #2035: URL Not Found.
I am certain that the URL to the problem SWF is correct. The SWF itself doesn't load any other SWFs or images. The problem SWF is linked to an external class file and compiled with it. i.e. in the properties panel of the main timeline of the problem SWF's Fla I have entered the path to the external class.
1. there is no problem compiling this SWF with the class (it works fine by itself)2. if I remove the external class from the properties panel and don't use it the resulting SWF imports without a problem into the Main Fla mentioned before So the problem seems to be the fact that the external class is linked in the properties panel. Is this a path problem?
View 3 Replies
Nov 30, 2009
I am on my second big AS3 project and I need a better way of adding Display Objects to the main stage from within other classes.
I have my Main.as which starts everything off and is an extension of MovieClip. I have a LevelManager class which I have to load levels, track level progress, and switch between other levels of my game.
I have a Level class which has partly the duty of populating the assets to the screen for that level of the game. However, I can't just add them to the stage like I can in the Main class. (obviously)
My previous solution was to pass an instance of Main's stage through multiple classes until it got to the one who's job it was to populate display objects. It still makes me cringe.
View 4 Replies
Jul 21, 2011
I am having is trying to add objects to stage. At the moment I can not put anything onto the stage unless it is in my Main document class (Main). How would I add to stage in my player class and bullet class?
Code:
package game{
import flash.display.*;
public class Main extends MovieClip{
[Code].....
View 2 Replies
Jun 2, 2010
I'm aware that ActionScript 3.0 is designed from the ground up to be a largely object-oriented language and using it means less or even no timeline code in Flash documents.I'm quite experienced with OOP and am comfortable writing classes. However, since I mostly use Flash for animations, I hardly ever need to write ActionScript code other than for preloaders, subtitles, quality controls, website links and so on. In fact, I still set my Flash movies to use AS2 to this day because I'm used to gotoAndPlay()/gotoAndStop(), AS2 preloaders, subtitles, quality controls and even getURL(). Of course, I really want to move on now that practically everyone's on Flash Player 9 or 10 and now that I've dabbled with other OO languages like Java, C# and Objective-C too.
I'm a complete newcomer to AS3 and am not very learned with AS2 either. Considering my current use of ActionScript, are there any cases where it's still OK to use very simple AS3 code in the timeline instead of moving code to a class, especially since moving to a class might mean unnecessarily increasing the number of LOC from 4 to 40?
View 2 Replies
Oct 18, 2009
I have one class, which I am adding to stage, here is part of the code:
[Code]...
I dont get this, when I say addChild(_thumbArea); shouldnt all the code in _thumbArea execute first and then continue with code in my parent class?
View 1 Replies
Aug 10, 2009
I'm new to as3 and although I am able to build classes that don't error but also don't put anything on the stage. I have Starter_1.as file stored in a folder called com...this is the script for that file:
Code:
package com {
import flash.display.Sprite;
import flash.text.TextField;
public class Starter_1 extends Sprite {
private var tField:TextField;
public function Starter_1 () {
[Code] .....
From what I can see the problem is because the addChild(tField) is not referencing the stage in anyway because the script is in an external .as file and not on the timeline (good coding practice I read somewhere?) I use this on the timeline to try put the text field on the stage:
Code:
import com.Starter_1;
var f1:Starter_1 = new Starter_1();
How do I get this working?
View 4 Replies
Mar 16, 2011
Access stage objects (like Movie Clip or text fields) from sub classes.The problem came when I define a subclass and try to access stage objects. How can I do that?Imagine I have a movie clip named redBox_mc on the stage.I want to change it`s alpha after I get my xml loaded.(or any other action in subclass)
Main class:
package src{
// ..
public class code01 extends MovieClip {
public var rt:xmlReader = new xmlReader("art.xml"); // my subclass
[code]...
View 1 Replies
Dec 31, 2009
I have a document class of particles and i'm trying to add multiple instances of the class...
[Code]....
is this the correct way to add multiple instances of the class to the stage?
View 3 Replies
Jan 12, 2010
I am making a video player class that will be imported as a custom class into a fla (not document class). how i can add clips to the display object without having to return them from the class?
is there something like stage.addChild or root.addChild or something that i can use?
View 2 Replies
Feb 10, 2012
Im trying to create a class which can access a movie clip on stage. I've searched many forums/google cant seem to find the solution im after. If i have a movie clip on stage with instance name 'mc1' for example. how can i access this movie clip from a class im creating. Eventually id be able to access the movieclip via a dynamic name but need to get past this simple stage first.
View 1 Replies
Jul 22, 2009
Im trying to get used to packages and classes in AS3. Im used to put all code on the first frame of the timeline, but now i have 442 lines of code on the first frame. Yeah 442. And this is for a game engine so i thought i should put it inside some classes to make it easier to read an reusable. But i have noticed that if i create a class called Code and make a instance of that class like this:[AS]var codeObject:Code = new Code();[/AS]i get a bunch of errors because the class cant Acess the stage and the display list.i found a workaround by linking the class to a movieClip and and do this:[AS]MovieClip(parent);[/AS?
View 1 Replies
Oct 27, 2010
I have been trying to reference to the stage from outside Document class and tried many different ways I found on google and it seems none of them works (maybe there were some changes in flash since they were posted.For example TopLevel approach by Senocular doesn't work either I do it as described in here.URL...The only way it seemed to work is by passing a stage as a variable. Has anyone any idea of a way to do it without the need of passing it by.
View 7 Replies
Mar 1, 2011
I'm developing my first flash app. I'm trying to use classes because they'll be very important in my future app. I created a simple movieclip with a star. However, instead of putting it directly on the stage, I'm calling it from library, using the addChild method to place the star in the stage. To do that, I simple right click over the movieclip icon->properties->check export to action script->and I give a name to the class (for example: myMC)
Then, inside the class I wrote:
package {
import flash.display.*;
import flash.events.*;
public class myMC extends MovieClip {
var star:myMC=new myMC();
public function myMC() {
[Code] .....
As I am placing the two variables origin_x and origin_y inside the constructor, I'm expecting to get 250 and 200 respectively. After drop the star, I want to send it to it's original place, and that's why I need to keep this values. And here's the problem, origin_x and origin_y are both ZERO, instead of 250 and 200... The value is not relative to stage. I managed a little bit and I found this post : [URL]. Unfortunately I tried to replace by the suggested code, but both values remain zero. An interesting thing, is that if I put the star directly in the stage instead of calling it from the library as I am doing, I get correct values in origin_x and origin_y.
View 1 Replies
Aug 5, 2011
I have a Flash file for an xml driven menu. There is the document Class, called Main. There is also a Navigation class. In the Navigation class, I position the location of main buttons and sub menu buttons for the menu. I want to position the buttons in the Navigation class relative to the stage. Currently, they are just fixed at certain positions (like 20); To do this, I have read that because this is not happening in the document class.
I must add an event listener to the constructor that listens for the added to stage event. I am not sure how to do this, as when I try and add an event listener for added to stage in the Navigation class nothing happens, (or all menu items diaspear). How to position movie clips relative to the stage (i.e. stage.stageWidth - 50) from a class that is not document class? How to do so in the document class, too.
View 2 Replies
Nov 19, 2009
[code]Also pass the Stage reference still it not showing any error and text box is also blank,text is embed ed and the code is.[code]If I put import flash. display. List; it shows an error 1172: Definition flash.display:List could not be found.
View 5 Replies
Nov 6, 2010
I found this code for a contact form at msinghinteractive easy-to-use-flash-as3-contact-us-form-class and it dynamically creates input fields and buttons. I didnt like the dynamically drawn submit and reset buttons, so I added my own MCs(my 'buttons') to the stage. I tried modifying the code and took out the dynamically drawn buttons..However, I cant figure out how to add Event Listeners to the buttons which exist on the stage--Im getting undefined errors...The fla is directly associated to a main.as class which just determines the parameters of the .as class it is tied to -to set the size of the Contact form.This is the entire class:
Code:
package{
import classes.*;
import flash.display.*;
[code]....
where btn is the instance name of my submit button MC.My problem is that because my buttons exist on the stage I dont know how to add Event listeners within that class---or rather doing that doesnt work because the listeners are throwing that undefined property errors--I gave them instance names...
View 7 Replies
Jul 9, 2011
I having trouble nesting classes then calling them on the main stage.I have one AS file that contains all the functionality to create a simple button with a text field that can be customized from the FLA file. I want to use this AS file to create another AS file for a form.I have called the simple button from the AS file into my other AS using import RoundRectButton.
View 2 Replies
Oct 20, 2009
I am using Gaia framework with a fluid layout at here is what I get
This is the error:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at com.gaiaframework.FluidLayout::FluidObject/reposition()
[Code]....
View 7 Replies
Mar 31, 2010
This is my first attempt at external as classes and I can't get them right. I've a button set up on the stage and an external as file with the following code:
Code:
package {
import flash.display.*;
import flash.events.MouseEvent.*;
import flash.display.SimpleButton.*;
public class myTasteButton extends SimpleButton {
[Code] .....
Basically I need to link an external class to the button, which will in turn when clicked play the beat_mc. I've given the button the class of myTasteButton. It's not working but I'm not getting any errors.
View 4 Replies