Access object on the stage using an as3 widget
I am trying to use a FlashPro as3 widget and Captivate 6, to toggle an image on the Captivate stage (hide/show) and can't find enough information on how to access the stage objects.
I can use
var numKids:int = parent.parent.parent.numChildren()
to see the number of children (of the stage object?) , but can't seem to figure out how to hide or show the child objects (image, button or anything).
My image names in my Captivate Project are Img_Einstein1 and Img_Einstein2. They reside on a blank slide along with two buttons and another widget.
I have looked at Tristen's web site and found a lot of useful information, but I guess I am just not putting it all together. Because I am a contractor I can't use the Widget Factory or purchase outside widgets.
Any help will be greatly appreciated!
On 6 you don't have shared actions yet. I don't understand the explanation with 20 and 10. There are several examples of toggle buttons on my blog. For showing/hiding here a simple one:
http://blog.lilybiri.com/blog-after-posterous-clickclick
Similar Messages
-
Adding objects to the stage & acceessing stage properties - I'm a bit confused..
Hi,
I'm a little confused on two fronts regarding display
programming:
A. What the best way to add objects to the stage?
B. How to access stage properties.
I can do both of these when the project is an 'Action Script
Project', but I'm having trouble when it is a 'Flex Project' (e.g.
an MXML file). See the two attached files with questions included
in the comment to see exactly what I mean.
A. What the best way to add objects to the stage?
=====================================
In an action script project that extends Sprite I can just
call addChild()
In an MXML project I can add objects to the stage by first
adding them to a UIComponent, then adding that to the stage.
1. Is that the best way to do it?
In this doc:
http://livedocs.adobe.com/flex/3/html/help.html?content=05_Display_Programming_02.html
it says that
quote:
Each SWF file has an associated ActionScript class, known as
the main class of the SWF file. When Flash Player opens a SWF file
in an HTML page, Flash Player calls the constructor function for
that class and the instance that is created (which is always a type
of display object) is added as a child of the Stage object. The
main class of a SWF file always extends the Sprite class
2. why cant I just add a sprite object direct to the stage
without the UIComponent?
3. What is the 'main class', and how can i get access to it?
B. How to access stage properties.
=========================
In an action script project that extends Sprite I can just
call trace(stage.framerate)
But in an MXML file I cannot figure out how to access the
stage properties.
See the attached code for the things that I tried, but which
didnt work.
In the page:
http://www.actionscript.org/forums/showthread.php3?t=140655
It says
quote:
For stage access you have a couple of rules:
* natively, only display objects have inherent access to
stage
* display objects only have a valid reference to stage if
they're within the stage's display list (on the screen, after added
to it with addChild)
* The only display objects which immediately have access to
the stage before the use of addChild (in their constructor) are the
document/application class instance (root) and any instance from
the library placed on the timeline (not created with AS).
* Non-display object classes have to be passed or assigned a
reference to the stage from another object which already has access
to it - they cannot access it otherwise.
4. How do I access the stage properties in the MXML project?
5. I suspect this is related to the "main class", which I
dont yet understand - is it?
Sorry for the long post.
cheers
tom"tom saffell" <[email protected]> wrote in
message
news:gd7cm9$d1v$[email protected]..
> Thanks Luigi - that helps a lot.
> I hadnt seen the Flex 3 Developer Guide before - it's
very useful.
>
> I now see that I can access properties of the
application object directly
> with
> this.<property>.
> However, the framerate property cannot be set by
actionscript, only in
> MXML (I
> can set it in the <mx:application> tag). But I
need to be able to set it
> programatically, dependent on user input.
>
> 5. Is there a way around this?
> 6. Can I set the stage's framerate to achieve the same
outcome?
>
> I still dont understand why I cannot access the stage
object. When I call
> either
this.stage or
uic.stage * then I get
quote:
Cannot access
> a
> property or method of a null object reference.
My understanding is
> that I
> can access the stage object via any display object on
the display list.
> I'm
> confused about this bit..
>
> * - uic is a UIComponent that has been added to the
display list (i think)
> by
> calling addChild(uic) from the AS3 within the
application
>
> 7. How do I access stage properties in AS3 in an MXML
project?
http://www.adobe.com/livedocs/flex/3/html/help.html?content=05_Display_Programming_10.html
It seems like possibly your real problem is that you're
having trouble
searching the Help effectively:
http://flexdiary.blogspot.com/2008/07/getting-help-in-flex-builder.html -
How to access objects in the Child Form from Parent form.
I have a requirement in which I have to first open a Child Form from a Parent Form. Then I want to access objects in the Child Form from Parent form. For example, I want to insert a record into a block present in Child Form by executing statements from a trigger present in Parent Form.
I cannot use object groups since I cannot write code into Child Form to first create object groups into Child Form.
I have tried to achieved it using the following (working of my testcase) :
1) Created two new Forms TESTFORM1.fmb (parent) and TESTFORM2.fmb (child).
2) Created a block named BLK1 manually in TESTFORM1.
3) Created two items in BLK1:
1.PJC1 which is a text item.
2.OPEN which is a push button.
4) Created a new block using data block wizard for a table EMPLOYEE_S1. Created items corresponding to all columns present in EMPLOYEE_S1 table.
5) In WHEN-NEW-FORM-INSTANCE trigger of TESTFORM1 set the first navigation block to BLK1. In BLK1 first navigable item is PJC1.
6) In WHEN-NEW-ITEM-INSTANCE of PJC1, code has been written to automatically execute the WHEN-BUTTON-PRESSED trigger for the "Open" button.
7) In WHEN-BUTTON-PRESSED trigger of OPEN item, TESTFORM2 is opened using the following statement :
open_form(‘TESTFORM2',no_activate,no_session,SHARE_LIBRARY_DATA);
Since its NO_ACTIVATE, the code flows without giving handle to TESTFORM2.
8) After invoking OPEN_FORM, a GO_FORM(‘TESTFORM2’) is now called to set the focus to TESTFORM2
PROBLEM AT HAND
===============
After Step 8, I notice that it passes the focus to TESTFORM2, and statements after go_form (in Parent Form trigger) doesnot executes.
I need go_form with no_activate, similar to open_form.
Edited by: harishgupt on Oct 12, 2008 11:32 PMisn't it easier to find a solution without a second form? If you have a second window, then you can navigate and code whatever you want.
If you must use a second form, then you can handle this with WHEN-WINDOW-ACTIVATED and meta-data, which you have to store in global variables... ( I can give you hints if the one-form-solution is no option for you ) -
Deleting objects from the stage
Hi all,
I've got some items on my stage that I'm removing with
RemoveChild(). The items no longer show, however, as stated in
LiveDocs, the item is not actually destroyed. This means any
bindings/listeners created by that object are still in existence
and are creating errors (Specifically, I'm getting "The supplied
DisplayObject must be a child of the
caller").
LiveDocs mentions that if I want to actually delete an object
from the stage entirely, I should use the "delete operator", but
for the life of me, I can not find any documentation on the
existence of such an operator. Any advice would be much
appreciated.
-HobIt IS ridiculously hard to find. Searcing Live Docs for
delete oprator will turn up a slew of hits, but which is the right
one?
This is from old docs, but it is still valid:
http://livedocs.adobe.com/flash/8/main/00001865.html
Tracy -
DropTarget check against all objects on the stage
Hey all,
Not sure the best way to do this. I have a class we will call DropActivity, here is the code
package com.activitycontrol
import com.activitycontrol.DropCheck;
public class DropActivity
// Constants:
// Public Properties:
// Private Properties:
private var _selectedClip:Object;
// Initialization:
public function DropActivity(/*selectedClip:Object*/)
// Public Methods:
public function set selectedClip(selectedClip:Object):void
_selectedClip = selectedClip;
public function stopDraggingMe():void
var dropCheck:DropCheck = new DropCheck();
//dropCheck.checkAgainst = dropTarget.name; ///***********
if (dropCheck.canBeDropped == true)
_selectedClip.stopDrag();
// Protected Methods:
when the stopDraggingMe() method is called from another object (code shown below) I need to see all the objects on the stage to see what objects on the stage my currently selected movie clip is over and assign it to the dropCheck.checkAgainst method (that will be checked against an array to see if it can in fact be dropped, if so set the canBeDropped value to true and therefor run the .stopDrag() ). I have read using root is not a good coding practice in AS 3.
call to the stopDraggingme() mehod.
private function setDown(event:MouseEvent):void
var droppedItem:DropActivity = new DropActivity();
droppedItem.selectedClip = this;
droppedItem.stopDraggingMe();No, I think I can use drop target, I just need to use it from the DropActivity class and not a document class. I just don't know how to use it from a non-document class.
"and you need to loop through all displayobjects to see which have a positive hitTest with your dropped object, correct?"
I am trying to say..... ok, what movie clip is currently under the one I have selected, the drop activity class knows what object I have selcted as it is in the selectedClip variable. so I need to find out what clip is under it ......... the light just came on!
answer duh......dropCheck.checkAgainst = _selectedClip.dropTarget.parent.name;
thanks a bunch kglad you have helped me out once again, you are the man. I might just have to buy you a beer one of these days. -
Accessing object of the main class from the thread
Hi, I'm having problem accessing object of the main class from the thread. I have only one Thread and I'm calling log.append() from the Thread. Object log is defined and inicialized in the main class like this:
public Text log; // Text is SWT component
log = new Text(...);Here is a Thread code:
...while((line = br.readLine())!=null) {
try {
log.append(line + "\r\n");
} catch (SWTException swte) {
ErrorMsg("SWT error: "+swte.getMessage());
}Error is: org.eclipse.swt.SWTException: Invalid thread access
When I replace log.append(...) with System.out.println(..) it works just fine, so my question is do the log.append(..) the right way.This is NOT a Java problem but a SWT specific issue.
It is listed on the SWT FAQ page http://www.eclipse.org/swt/faq.php#uithread
For more help with this you need to ask your question on a SWT specific forum, there is not a thing in these forums. This advice isn't just about SWT by the way but for all specific API exceptions/problems. You should take those questions to the forum or mailing list for that API. This forum is for general problems and exceptions arising from using the "core" Java libraries. -
Can't edit objects on the stage
Hi,
I'm stumped helping my colleague on the issue below so I'm logging this question.
Issue: My colleague is trying to edit a slide but can't edit any of the objects on the stage. However, it works fine when I open the same project on my machine. Is there a setting on her machine that's causing the issue?
In the screenshot below, check out Slide 2 (selected) notice how:
in the thumbnail there are multiple objects (white image on the left, blue text caption in the center) on the slide.
in the timeline multiple objects are available and selectable. All are set to be visible (the little "eye" isn't switched to off).
when you look at the stage, the only things that we see are the background and a single button.
The objects also appear fine in Preview.
On the stage, can "phatomly" select objects, but she can't change the characteristics of them (e.g., change text in a text caption, resize object, move object).
Screenshot:
OS: Windows 7
Captivate: v5.5 (running as Administrator)
Background info:
This project was initially created in an older Captivate version (4.0 or 5.0) and is now being edited/updated.
Last week, my colleague was trying to edit the same project (using v5.0). When she clicked play on the timeline, her audio wouldn't play. When she watched the Preview or tried to edit the audio, the audio would play just fine. Also, on my machine (running v5.5) it worked fine. This prompted me to suggest that she update to v5.5. Alas, it seems this fixed the audio issue, only to create this video issue.
Thanks,
- DinoHere's a bigger/better quality image. I hope it helps.
Notice how the Text Caption is selected in the timeline and it's properties are visible on the right. Yet the item itself is nowhere to be seen on the stage. Also, now it seems to have disappeared from the thumbnail. -
Duplicating the motion of an object across the stage
Suppose I have a single moving object on the stage is it possible to replicate the object at regular intervals across the stage WITH the motion?
Is this motion achieved through actionscript or is it a tween on the stage? If this is a tween on the main timeline on the stage, then you could make that animation a movieClip and play the movieClip at an interval, maybe using a timer. If the animation is achieved using actionscript then write the animation as a function and call the function at an interval, again, possibly using a timer.
-
Hide objects outside the stage
Hi there!
I have recently downloaded a sample FLA file and I see the stage is FIXED on top-left side of the flash screen and objects outside the stage does not appear on screen (Like a mask, but there is no mask layer).
And when I create a new file the stage appears in middle of the screen and objects outside the stage are not masked.
Would you please help me what should I do in this case?
(I always use a very big White layer in top of all other layers, to cover out of stage, OR use a mask layer)
Regards,
AliHi!
Sorry if my question was not clear. here is the link (adobe TV):
http://downloads.tv.adobe.com/2012-00-24/WebChallenge_FL_3.zip
I have uploaded that single FLA file to the address below :
http://www.howallah.com/Mobile.fla
To simplify my question, each flash scene is indeed divided into 3 sections based on colors (white, light grey, dark grey) as marked below :
(the Zoom is 20% to cover them all).
Section 1. is called Stage (I know)
Section 2. it expands automatically as you move an object outside the stage (image, movieclip etc.) and it works like a mask (I dont know the name of this section)
Section 3. is something like "out of Scene" (I don't know the name of this section as well)
What I want to do is sort of FITTING Section 1 (Stage) to Section 2.
Exactly like the FLA sample file above.
What is that good for?? to help me only see the stuff INSIDE the stage, without any need to make a mask layer or a LARGE white layer above all layers etc.!
Anybody knows what I am talking about and having a clue please?
Regards,
Ali -
Positioning and temporarily hiding objects on the stage
(Flash newbie here - bear with me...)
I have two graphic objects on the stage overlapping each
other. The first I was able to position to the document boundaries
just fine. When adding the second object, however, the first object
covers the boundaries so I cannot see them to align the second
object.
The question: Is it possible to temporarily hide an object on
the stage so I can see the stage boundaries to position another? I
don't see any options that will allow me to do this.
Thx!there is a little colored square on each layer, to the right
of the layer name, click that square on the layer that the first
object resides, it will then just show an outline. click it again
to bring it back. You can also click the first 'dot' next to the
layer name, it will completely hide the contents of that
layer. -
Accessing display object on the stage from another class
I've googled this to no avail, I've only found how to manipulate the stage itself and not a display object on it, and I'm noob enough to not be able to figure it out from there. :/
I have a movie clip on the main timeline with instance name displayName. I created a button that should change what frame displayName goes to (in order to...did you guess it?! diplay the Name of the button. Awesome. )
So I am trying to write the code in a reusable fashion and have the buttons all linked to a class called GeoPuzzle. Inside GeoPuzzle I instantiate a touch event and run the code. However, the function has to be able to change displayName in the main part of the timeline and, of course, the compiler says displayName doesn't exist because I'm in a class and I'm talking about the stage.
Here is the simplified code in the class:
package com.freerangeeggheads.puzzleography {
import flash.display.MovieClip;
import flash.events.TouchEvent;
public class GeoPuzzle extends MovieClip {
//declare variables
public function setInitial (abbrev:String, fullName:String, isLocked:Boolean):void {
//set parameters
this.addEventListener(TouchEvent.TOUCH_BEGIN, geoTouchBeginHandler);
public function GeoPuzzle (): void {
public function geoTouchBeginHandler (e:TouchEvent): void {
e.target.addEventListener(TouchEvent.TOUCH_END, geoTouchEndHandler);
//some other methods
nameDisplay.gotoAndStop(e.target.abbrev);
public function geoTouchEndHandler (e:TouchEvent): void {
//some other methods
nameDisplay.gotoAndStop("USA");
The lines in bold are my problem. Now this code doesn't actually execute as is so if you see an error in it, yeah, I have no idea what the problem is, but it DID execute before and these lines still gave me trouble so I'm trying to troubleshoot on multiple fronts.
How can I tell displayName to change it's current frame from within display object class?
Thanks!if displayName is a GeoPuzzle instance, use:
package com.freerangeeggheads.puzzleography {
import flash.display.MovieClip;
import flash.events.TouchEvent;
public class GeoPuzzle extends MovieClip {
//declare variables
public function setInitial (abbrev:String, fullName:String, isLocked:Boolean):void {
//set parameters
this.addEventListener(TouchEvent.TOUCH_BEGIN, geoTouchBeginHandler);
public function GeoPuzzle (): void {
public function geoTouchBeginHandler (e:TouchEvent): void {
e.target.addEventListener(TouchEvent.TOUCH_END, geoTouchEndHandler);
//some other methods
this.gotoAndStop(this.abbrev);
public function geoTouchEndHandler (e:TouchEvent): void {
//some other methods
this.gotoAndStop("USA"); -
Accessing display objects via the stage var
I'm passing a stage reference to my class, but when I try to
access a movieclip on the stage I get an error.
this gives me an error:
var mc = targetStage.myMovieClip;
Thanks!var myClass = new MyClass (this.stage);
That would be the same thing, this.stage would refer to the
Stage instance. Each .swf has one Stage instance. In a Flash
project, the stage has one child, the MainTimeline instance.
MainTimeline is basically a big MovieClip, and it contains all your
objects, scenes and timelines you create in Flash.
So, if you instantiate from the main timeline itself (either
on a frame script or Document class) you are already inside
MainTimeline, which is what you want to pass along a reference to,
so you would pass in "this" as Colin said, or "root".
Colin mentioned that MovieClip(root) would work anyway; if I
understand he is referring to the fact that every DisplayObject
(such as MovieClips and SimpleButtons created in Flash) already
have a "root" property that usually refers to the MainTimeline
instance. However, your class "MyClass" does not extend
DisplayObject so there is no root property available, which is why
you need to manually pass in a reference to the root
timeline. -
Problem removing Objects from the stage in Flash CS4 (AS3.0)
I have a problem with this code:
this.addEventListener(Event.ENTER_FRAME, vanish);
function vanish(event:Event):void{
if(character_mc.hitTestObject(vanish_mc)){
vanish_mc.parent.removeChild(vanish_mc);
There are two overlapping objects on my stage: character_mc and vanish_mc.
As soon as i start the scene[Ctrl+Enter] vanish_mc is VISUALLY removed. But the code still sees a collision somehow. How can i Entirely remove the object vanish_mc?
Thank you for help and advice.Ah I think the problem is what my problem not which I proposed, my bad I was trying to keep it simple.
the remove code in my problem actually looks like this:
if(character_mc.hitTestObject(this["dollar_mc_"+String(i)])){
removeChild(this["dollar_mc_"+String(i)]);
I wanted it to be that way so I could add infinite "dollar_mc_" ' s without writing myself to death with code and or getting confused.
Imagine it like a game where a character it picking up dollars, which would disappear once they intersect.
And that exactly is what gives me that argument.
Do you know a way i could write this code, or do you suggest to leave it that way...because it does run and work im just getting this argument while debugging.
Thank you for all the help~ -
Any help on this would be greatly appreciated. I have an
object that is serving as a background for a flash website. The
background object (a table) moves and rotates around when clicked,
exposing different parts of the table on the stage when the user
clicks.
Here is as close an example as I can find:
http://www.vermeersch.ca/
My problem is when i want to transition between two points on
the table, the table has to rotate and move.. and by just using a
motion tween between the two points results in the table rotating
off the stage for a few frames (thus exposing the background and
making it look really cheezy). I was trying my hand at using motion
guides, but can't do it with any accuracy.
So, my question is: Is there a way to guide an object as it
rotates and moves so that it doesn't move off screen? (there is
plenty of room on the table if i can just guide its path through
the 2 second transition). Thanks for any support.http://www.personal.psu.edu/jwc5062/
So far you can't really see it moving off the stage.. but the
beginning is awkward because i had to zoom in really tight before i
could rotate to avoid the problem. I can't transition between
"resume" and "portfolio" without it moving off the stage for half
the transition.
Thanks for the help -
Hello,
I am using the ActionScript 3 in a aplication and i have
problem to access the MovieClips that is on the Stage. Let me
explain.
I the stage i have two MovieClips, with instance of mc1 and
mc2. Inside of mc1 i try to access some proprerties from mc2 but
without success.
I try using this:
trace(parent.mc2.width);
But the Flash return the error 1119, undefined propertie.
So, how can i access the MovieClips that is on my stage from
another MovieClip.
Thanks:
Maybe you are looking for
-
IPhone does not sync Calendar events with iCloud
I have a Calendar which is synced with my iPhone, iCloud and MacBook Air. Calendar events are synced between iCloud and the MacBook, but not between iCloud and iPhone. I tried Reset, but it still does not synce between iCloud and iPhone.
-
Should I be able to see my movies and tv shows because of itunes match?
I purchased iTunes match, and at first I could see my downloaded movies and tv shows on my devices. However I cannot see them anymore. I do not know if this is a setting in iTunes match or a different setting that changed? Any ideas?
-
Creation of Production Order for Deleted Material
How can I prevent a production order from being created for a material that has been marked for deletion? Currently, our system generates a warning but allows the order to be created.
-
Chinese in System Info (Russian OS X).
I have a problem with russian language in System Info of OS X Lion (10.7.4). In item where i see information about RAID i see Chinese symbols! Can i fix it or i must to learn Chinese?)
-
Itunes cannot connect to istore
itunes cannot connect to istore